Updated fruit spawner
This commit is contained in:
@@ -2192,7 +2192,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 1fc36d0808cf971459d9e430faaeadd9, type: 3}
|
m_Script: {fileID: 11500000, guid: 1fc36d0808cf971459d9e430faaeadd9, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
MaxSpawned: 30
|
MaxSpawned: 200
|
||||||
MinSpawnTime: 0
|
MinSpawnTime: 0
|
||||||
MaxSpawnTime: 0.2
|
MaxSpawnTime: 0.2
|
||||||
FruitSpawnParent: {fileID: 1944344878}
|
FruitSpawnParent: {fileID: 1944344878}
|
||||||
@@ -2213,7 +2213,6 @@ MonoBehaviour:
|
|||||||
type: 3}
|
type: 3}
|
||||||
BuddhasHandPrefab: {fileID: 4062657912758122058, guid: ebddb1b81a288cc4c993a25bc9efe894,
|
BuddhasHandPrefab: {fileID: 4062657912758122058, guid: ebddb1b81a288cc4c993a25bc9efe894,
|
||||||
type: 3}
|
type: 3}
|
||||||
ActiveFruits: []
|
|
||||||
--- !u!1 &1944344877
|
--- !u!1 &1944344877
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -26,15 +26,14 @@ namespace Fruitomation.Game
|
|||||||
[SerializeField] private GameObject PitayaPrefab;
|
[SerializeField] private GameObject PitayaPrefab;
|
||||||
[SerializeField] private GameObject KiwiPrefab;
|
[SerializeField] private GameObject KiwiPrefab;
|
||||||
[SerializeField] private GameObject BuddhasHandPrefab;
|
[SerializeField] private GameObject BuddhasHandPrefab;
|
||||||
|
|
||||||
[Header("Read only")]
|
|
||||||
[SerializeField, InspectorReadOnly] private List<FruitBehaviour> ActiveFruits;
|
|
||||||
|
|
||||||
private float TimeUntilNextSpawn;
|
private float TimeUntilNextSpawn;
|
||||||
|
|
||||||
|
private int CurrentItemCount => FruitSpawnParent.childCount;
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (ActiveFruits.Count <= MaxSpawned && GameStateController.Is(GameState.Simulation))
|
if (CurrentItemCount <= MaxSpawned && GameStateController.Is(GameState.Simulation))
|
||||||
{
|
{
|
||||||
TimeUntilNextSpawn -= Time.deltaTime;
|
TimeUntilNextSpawn -= Time.deltaTime;
|
||||||
|
|
||||||
@@ -77,10 +76,7 @@ namespace Fruitomation.Game
|
|||||||
FruitBehaviour behaviour = go.GetComponent<FruitBehaviour>();
|
FruitBehaviour behaviour = go.GetComponent<FruitBehaviour>();
|
||||||
Debug.Assert(behaviour is not null, "Could not find FruitBehaviour");
|
Debug.Assert(behaviour is not null, "Could not find FruitBehaviour");
|
||||||
|
|
||||||
ActiveFruits.Add(behaviour);
|
|
||||||
behaviour.InitBehaviour(GameCanvas);
|
behaviour.InitBehaviour(GameCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveFruit(FruitBehaviour fruit) => ActiveFruits.Remove(fruit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user