mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-09 23:23:44 +00:00
Assembling Main scene.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DefectMaterialVisualizer: MonoBehaviour, IDefectVisualizer
|
||||
public class DefectMaterialVisualizer : MonoBehaviour, IDefectVisualizer
|
||||
{
|
||||
public MeshRenderer MeshRenderer;
|
||||
|
||||
|
||||
private List<DefectType> supportedDefects = new()
|
||||
{
|
||||
DefectType.Hex_MissingMaterial_1,
|
||||
@@ -13,17 +13,19 @@ public class DefectMaterialVisualizer: MonoBehaviour, IDefectVisualizer
|
||||
DefectType.Hex_MissingMaterial_4,
|
||||
DefectType.Hex_MissingMaterial_5,
|
||||
};
|
||||
|
||||
|
||||
public void VisualizeDefect(DefectType defectType)
|
||||
{
|
||||
var materials = MeshRenderer.sharedMaterials;
|
||||
|
||||
for (var i = 0; i < supportedDefects.Count; i++)
|
||||
{
|
||||
if (!defectType.HasFlag(supportedDefects[i]))
|
||||
if (defectType.HasFlag(supportedDefects[i]))
|
||||
{
|
||||
continue;
|
||||
materials[i + 1] = null;
|
||||
}
|
||||
|
||||
MeshRenderer.materials[i] = GameAssets.Instance.MissingMaterial;
|
||||
}
|
||||
|
||||
MeshRenderer.sharedMaterials = materials;
|
||||
}
|
||||
}
|
@@ -15,6 +15,9 @@ public class ProductType : ScriptableObject
|
||||
public int Probability;
|
||||
}
|
||||
|
||||
public AudioClip[] normalClips;
|
||||
public AudioClip[] defectiveClips;
|
||||
|
||||
public DefectProbability[] DefectProbabilities;
|
||||
|
||||
public static void SpawnProduct(ProductType type, Transform origin)
|
||||
@@ -42,4 +45,13 @@ public class ProductType : ScriptableObject
|
||||
|
||||
return DefectType.None;
|
||||
}
|
||||
|
||||
public AudioClip SelectClip(bool defective)
|
||||
{
|
||||
var clips = defective ? defectiveClips : normalClips;
|
||||
|
||||
int index = Random.Range(0, clips.Length);
|
||||
|
||||
return clips[index];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user