Updated fruit spawner
This commit is contained in:
@@ -26,15 +26,14 @@ namespace Fruitomation.Game
|
||||
[SerializeField] private GameObject PitayaPrefab;
|
||||
[SerializeField] private GameObject KiwiPrefab;
|
||||
[SerializeField] private GameObject BuddhasHandPrefab;
|
||||
|
||||
[Header("Read only")]
|
||||
[SerializeField, InspectorReadOnly] private List<FruitBehaviour> ActiveFruits;
|
||||
|
||||
private float TimeUntilNextSpawn;
|
||||
|
||||
private int CurrentItemCount => FruitSpawnParent.childCount;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (ActiveFruits.Count <= MaxSpawned && GameStateController.Is(GameState.Simulation))
|
||||
if (CurrentItemCount <= MaxSpawned && GameStateController.Is(GameState.Simulation))
|
||||
{
|
||||
TimeUntilNextSpawn -= Time.deltaTime;
|
||||
|
||||
@@ -77,10 +76,7 @@ namespace Fruitomation.Game
|
||||
FruitBehaviour behaviour = go.GetComponent<FruitBehaviour>();
|
||||
Debug.Assert(behaviour is not null, "Could not find FruitBehaviour");
|
||||
|
||||
ActiveFruits.Add(behaviour);
|
||||
behaviour.InitBehaviour(GameCanvas);
|
||||
}
|
||||
|
||||
public void RemoveFruit(FruitBehaviour fruit) => ActiveFruits.Remove(fruit);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user