mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-09 07:13:42 +00:00
Assembling Main scene.
This commit is contained in:
@@ -10,8 +10,10 @@ public class Converter: MonoBehaviour
|
||||
public Transform outputPoint;
|
||||
public ProductType conversionProduct;
|
||||
|
||||
public bool isBroken;
|
||||
public float conversionTime = 5f;
|
||||
public int CurrentHealth;
|
||||
public int MaxHealth;
|
||||
|
||||
public float conversionDuration = 5f;
|
||||
private float _conversionTimer;
|
||||
|
||||
public Transform refuseLauncher;
|
||||
@@ -28,9 +30,15 @@ public class Converter: MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_conversionTimer = conversionDuration;
|
||||
CurrentHealth = MaxHealth;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (isBroken)
|
||||
if (CurrentHealth <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +64,7 @@ public class Converter: MonoBehaviour
|
||||
inputProducts.RemoveAt(0);
|
||||
}
|
||||
|
||||
_conversionTimer = conversionTime;
|
||||
_conversionTimer = conversionDuration;
|
||||
}
|
||||
|
||||
_conversionTimer -= Time.deltaTime;
|
||||
|
@@ -9,18 +9,11 @@ public class ProductReceiver : MonoBehaviour
|
||||
public int normalProductCount;
|
||||
public int defectiveProductCount;
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
private void OnTriggerEnter(Collider otherCollider)
|
||||
{
|
||||
var rb = collision.rigidbody;
|
||||
var product = otherCollider.GetComponentInParent<Product>();
|
||||
|
||||
if (!rb)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//enteredBodies.Add(rb);
|
||||
|
||||
if (rb.TryGetComponent(out Product product))
|
||||
if (product != null)
|
||||
{
|
||||
if (product.Defect != DefectType.None)
|
||||
{
|
||||
@@ -31,7 +24,7 @@ public class ProductReceiver : MonoBehaviour
|
||||
normalProductCount++;
|
||||
}
|
||||
|
||||
Destroy(rb.gameObject);
|
||||
Destroy(product.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,45 +5,28 @@ using UnityEngine.Events;
|
||||
|
||||
public class StationaryDefectDetector : MonoBehaviour
|
||||
{
|
||||
public UnityEvent AlarmEvent;
|
||||
|
||||
[Range(0, 100)]
|
||||
public int FalsePositiveChance;
|
||||
[Range(0, 100)]
|
||||
public int FalseNegativeChance;
|
||||
|
||||
public List<Product> _knownProducts;
|
||||
|
||||
public AudioClip goodSound;
|
||||
public AudioClip badSound;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.TryGetComponent(out Product product))
|
||||
var product = other.GetComponentInParent<Product>();
|
||||
|
||||
if (product == null)
|
||||
{
|
||||
if (_knownProducts.Contains(product))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_knownProducts.Add(product);
|
||||
|
||||
if (product.Defect == DefectType.None)
|
||||
{
|
||||
var falseNegativeRoll = Random.Range(0, 100);
|
||||
|
||||
if (falseNegativeRoll > FalseNegativeChance)
|
||||
{
|
||||
AlarmEvent.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var falsePositiveRoll = Random.Range(0, 100);
|
||||
|
||||
if (falsePositiveRoll < FalsePositiveChance)
|
||||
{
|
||||
AlarmEvent.Invoke();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_knownProducts.Contains(product))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_knownProducts.Add(product);
|
||||
|
||||
NAudio.Play(product.Defect == DefectType.None ? goodSound : badSound, transform.position);
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
|
Reference in New Issue
Block a user