Updated fruit spawner
This commit is contained in:
@@ -2192,7 +2192,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 1fc36d0808cf971459d9e430faaeadd9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
MaxSpawned: 30
|
||||
MaxSpawned: 200
|
||||
MinSpawnTime: 0
|
||||
MaxSpawnTime: 0.2
|
||||
FruitSpawnParent: {fileID: 1944344878}
|
||||
@@ -2213,7 +2213,6 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
BuddhasHandPrefab: {fileID: 4062657912758122058, guid: ebddb1b81a288cc4c993a25bc9efe894,
|
||||
type: 3}
|
||||
ActiveFruits: []
|
||||
--- !u!1 &1944344877
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -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