Started implementing mixers

This commit is contained in:
Pasha Bibko
2026-04-28 10:08:27 +01:00
parent ba9b895f03
commit d53b760546
4 changed files with 125 additions and 23 deletions

View File

@@ -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;
}
}
}