Files
Fruitomation/Assets/Scripts/Game/Buildings/Automation/PeelerBuilding.cs
2026-04-28 11:05:02 +01:00

59 lines
1.9 KiB
C#

using Fruitomation.Game.Items;
using UnityEngine;
namespace Fruitomation.Game
{
public class PeelerBuilding : Building
{
[Header("Grinder Specific")]
[SerializeField] private RectTransform OutputLocation;
[SerializeField] private TriggerDetector Trigger;
private void Start()
{
Trigger.SetAction(other =>
{
bool isItem = other.transform.parent.TryGetComponent(out ItemBehaviour item1);
if (!isItem)
{
return;
}
ItemBehaviour item2 = null;
switch (item1.CurrentType)
{
case ItemType.Banana:
if (UpgradeManager.Is(BasicUpgrade.BananaPeeler))
{
item2 = FruitSpawner.SpawnItem(ItemType.BananaSkin);
item1.CurrentType = ItemType.MushedBanana;
}
break;
case ItemType.Pitaya:
if (UpgradeManager.Is(BasicUpgrade.PitayaPeeler))
{
item2 = FruitSpawner.SpawnItem(ItemType.PitayaSkin);
item1.CurrentType = ItemType.MushedPitaya;
}
break;
case var _:
item1.CurrentType = item1.CurrentType;
break;
}
item1.transform.position = OutputLocation.position;
item1.SendToTheGhostRealm();
if (item2 is not null)
{
item2.transform.position = OutputLocation.position;
item2.SendToTheGhostRealm();
}
}, TriggerType.Enter);
}
}
}