Made fruit be randomised

This commit is contained in:
2026-04-12 14:21:33 +01:00
parent 559248cbae
commit c68d64ab1d
8 changed files with 325 additions and 169 deletions

View File

@@ -14,7 +14,7 @@ namespace Fruitomation.Game
[Header("References")]
[SerializeField] private Transform FruitSpawnParent;
[SerializeField] private GameObject FruitPrefab;
[SerializeField] private GameObject[] FruitPrefabs;
[SerializeField] private Canvas GameCanvas;
[Header("Read only")]
@@ -38,9 +38,11 @@ namespace Fruitomation.Game
private void SpawnFruit()
{
GameObject go = Instantiate(FruitPrefab, FruitSpawnParent);
GameObject prefab = FruitPrefabs[Random.Range(0, FruitPrefabs.Length)];
GameObject go = Instantiate(prefab, FruitSpawnParent);
FruitBehaviour behaviour = go.GetComponent<FruitBehaviour>();
Debug.Assert(behaviour != null, "Could not find FruitBehaviour");
Debug.Assert(behaviour is not null, "Could not find FruitBehaviour");
ActiveFruits.Add(behaviour);
behaviour.InitFruitBehaviour