Made fruit be randomised
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using Fruitomation.Global;
|
||||
using PashaBibko.Pacore.Attributes;
|
||||
using UnityEngine.UI;
|
||||
using Fruitomation.Global;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
@@ -11,7 +9,6 @@ namespace Fruitomation.Game
|
||||
[Header("References")]
|
||||
[SerializeField] private RectTransform RectTransform;
|
||||
[SerializeField] private Rigidbody2D Body2D;
|
||||
[SerializeField] private Button Button;
|
||||
|
||||
[Header("Read only")]
|
||||
[InspectorReadOnly, SerializeField] private Canvas AttachedCanvas;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user