mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-09 07:13:42 +00:00
Fixed level loading, added level reset
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioAlarm : MonoBehaviour
|
||||
{
|
||||
public float Duration;
|
||||
|
||||
private bool _isPlaying;
|
||||
|
||||
public void PlayAlarm()
|
||||
{
|
||||
Debug.Log("Playing alarm");
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c996d1be4ecb4e8d92bc4344f7f98854
|
||||
timeCreated: 1723921340
|
4
Assets/Scripts/Machines/IResetable.cs
Normal file
4
Assets/Scripts/Machines/IResetable.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
public interface IResetable
|
||||
{
|
||||
public void ResetMachine();
|
||||
}
|
3
Assets/Scripts/Machines/IResetable.cs.meta
Normal file
3
Assets/Scripts/Machines/IResetable.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b152b88cf564370bd89748f325284b6
|
||||
timeCreated: 1724010368
|
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Converter: MonoBehaviour
|
||||
public class Converter: MonoBehaviour, IResetable
|
||||
{
|
||||
public List<Product> inputProducts;
|
||||
|
||||
@@ -31,9 +31,16 @@ public class Converter: MonoBehaviour
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
ResetMachine();
|
||||
}
|
||||
|
||||
public void ResetMachine()
|
||||
{
|
||||
_conversionTimer = conversionDuration;
|
||||
CurrentHealth = MaxHealth;
|
||||
|
||||
inputProducts.Clear();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
|
@@ -3,12 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProductReceiver : MonoBehaviour
|
||||
{
|
||||
///HashSet<Rigidbody> enteredBodies = new HashSet<Rigidbody>();
|
||||
|
||||
public int normalProductCount;
|
||||
public int defectiveProductCount;
|
||||
|
||||
{
|
||||
private void OnTriggerEnter(Collider otherCollider)
|
||||
{
|
||||
var product = otherCollider.GetComponentInParent<Product>();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProductSpawner : MonoBehaviour
|
||||
public class ProductSpawner : MonoBehaviour, IResetable
|
||||
{
|
||||
public enum ProductionPhaseType
|
||||
{
|
||||
@@ -24,19 +24,34 @@ public class ProductSpawner : MonoBehaviour
|
||||
}
|
||||
|
||||
public List<ProductionPhase> ProductionPhases;
|
||||
private List<ProductionPhase> RuntimeProductionPhases;
|
||||
|
||||
public float _remainingDuration;
|
||||
public float _spawnTimer;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
ResetMachine();
|
||||
}
|
||||
|
||||
public void ResetMachine()
|
||||
{
|
||||
enabled = true;
|
||||
_remainingDuration = 0f;
|
||||
_spawnTimer = 0f;
|
||||
|
||||
RuntimeProductionPhases = new(ProductionPhases);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (ProductionPhases.Count == 0)
|
||||
if (RuntimeProductionPhases.Count == 0)
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var currentPhase = ProductionPhases[0];
|
||||
var currentPhase = RuntimeProductionPhases[0];
|
||||
|
||||
if (_remainingDuration <= 0)
|
||||
{
|
||||
@@ -54,7 +69,7 @@ public class ProductSpawner : MonoBehaviour
|
||||
{
|
||||
if (_remainingDuration <= 0)
|
||||
{
|
||||
ProductionPhases.RemoveAt(0);
|
||||
RuntimeProductionPhases.RemoveAt(0);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -67,7 +82,7 @@ public class ProductSpawner : MonoBehaviour
|
||||
|
||||
if (_remainingDuration <= 0)
|
||||
{
|
||||
ProductionPhases.RemoveAt(0);
|
||||
RuntimeProductionPhases.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,12 +3,17 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class StationaryDefectDetector : MonoBehaviour
|
||||
public class StationaryDefectDetector : MonoBehaviour, IResetable
|
||||
{
|
||||
public List<Product> _knownProducts;
|
||||
|
||||
public AudioClip goodSound;
|
||||
public AudioClip badSound;
|
||||
|
||||
public void ResetMachine()
|
||||
{
|
||||
_knownProducts.Clear();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
Reference in New Issue
Block a user