Changed how items work

This commit is contained in:
2026-04-18 13:18:06 +01:00
parent 8a6d2eb95f
commit 97a1659359
14 changed files with 460 additions and 995 deletions

View File

@@ -1,4 +1,3 @@
using PashaBibko.Pacore.Attributes;
using System.Collections.Generic;
using Fruitomation.Game.Items;
using Fruitomation.Global;
@@ -18,6 +17,7 @@ namespace Fruitomation.Game
[SerializeField] private Canvas GameCanvas;
[Header("Prefabs")]
[SerializeField] private GameObject BaseItemPrefab;
[SerializeField] private GameObject ApplePrefab;
[SerializeField] private GameObject GrapePrefab;
[SerializeField] private GameObject BananaPrefab;
@@ -47,36 +47,38 @@ namespace Fruitomation.Game
private void SpawnFruit()
{
List<GameObject> unlocked = new() { ApplePrefab };
List<(ItemType, GameObject)> unlocked = new() { (ItemType.Apple, ApplePrefab) };
if (UpgradeManager.Is(BasicUpgrade.Grapes))
unlocked.Add(GrapePrefab);
unlocked.Add((ItemType.Grape, GrapePrefab));
if (UpgradeManager.Is(BasicUpgrade.Bananas))
unlocked.Add(BananaPrefab);
unlocked.Add((ItemType.Banana, BananaPrefab));
if (UpgradeManager.Is(BasicUpgrade.Kiwi))
unlocked.Add(KiwiPrefab);
unlocked.Add((ItemType.Kiwi, KiwiPrefab));
if (UpgradeManager.Is(BasicUpgrade.Mangoes))
unlocked.Add(MangoPrefab);
unlocked.Add((ItemType.Mango, MangoPrefab));
if (UpgradeManager.Is(BasicUpgrade.Durian))
unlocked.Add(DurianPrefab);
unlocked.Add((ItemType.Durian, DurianPrefab));
if (UpgradeManager.Is(BasicUpgrade.BuddhasHand))
unlocked.Add(BuddhasHandPrefab);
unlocked.Add((ItemType.BuddhasHand, BuddhasHandPrefab));
if (UpgradeManager.Is(BasicUpgrade.Pitayas))
unlocked.Add(PitayaPrefab);
unlocked.Add((ItemType.Pitaya, PitayaPrefab));
GameObject prefab = unlocked[Random.Range(0, unlocked.Count)];
GameObject go = Instantiate(prefab, FruitSpawnParent);
GameObject parent = Instantiate(BaseItemPrefab, FruitSpawnParent);
FruitBehaviour behaviour = go.GetComponent<FruitBehaviour>();
Debug.Assert(behaviour is not null, "Could not find FruitBehaviour");
(ItemType type, GameObject prefab) = unlocked[Random.Range(0, unlocked.Count)];
GameObject go = Instantiate(prefab, parent.transform);
ItemBehaviour behaviour = parent.GetComponent<ItemBehaviour>();
Debug.Assert(behaviour is not null, "Could not find ItemBehaviour");
behaviour.InitBehaviour(GameCanvas);
behaviour.InitBehaviour(GameCanvas, type);
}
}
}