Started implementing mixers
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Fruitomation.Game.Items;
|
||||
using Fruitomation.Global;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
@@ -27,9 +29,14 @@ namespace Fruitomation.Game
|
||||
[SerializeField] private GameObject KiwiPrefab;
|
||||
[SerializeField] private GameObject BuddhasHandPrefab;
|
||||
|
||||
private static FruitSpawner Instance;
|
||||
|
||||
private float TimeUntilNextSpawn;
|
||||
|
||||
private int CurrentItemCount => FruitSpawnParent.childCount;
|
||||
|
||||
private void Awake()
|
||||
=> Instance = this;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -70,13 +77,25 @@ namespace Fruitomation.Game
|
||||
if (UpgradeManager.Is(BasicUpgrade.Pitayas))
|
||||
unlocked.Add(ItemType.Pitaya);
|
||||
|
||||
SpawnItem(unlocked[Random.Range(0, unlocked.Count)]);
|
||||
}
|
||||
|
||||
public static ItemBehaviour SpawnItem(ItemType item, Vector3? pos = null)
|
||||
=> Instance.SpawnItemInternal(item, pos);
|
||||
|
||||
private ItemBehaviour SpawnItemInternal(ItemType item, Vector3? pos = null)
|
||||
{
|
||||
GameObject parent = Instantiate(BaseItemPrefab, FruitSpawnParent);
|
||||
ItemType type = unlocked[Random.Range(0, unlocked.Count)];
|
||||
|
||||
ItemBehaviour behaviour = parent.GetComponent<ItemBehaviour>();
|
||||
Debug.Assert(behaviour is not null, "Could not find ItemBehaviour");
|
||||
|
||||
if (pos != null)
|
||||
{
|
||||
parent.transform.position = (Vector3)pos;
|
||||
}
|
||||
|
||||
behaviour.InitBehaviour(GameCanvas, type);
|
||||
behaviour.InitBehaviour(GameCanvas, item);
|
||||
return behaviour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user