Moved slicer building
This commit is contained in:
75
Assets/Scripts/Game/Buildings/Automation/SlicerBuilding.cs
Normal file
75
Assets/Scripts/Game/Buildings/Automation/SlicerBuilding.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Fruitomation.Game.Items;
|
||||
using Fruitomation.Global;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class SlicerBuilding : Building
|
||||
{
|
||||
[Header("Slicer Specific Items")]
|
||||
[SerializeField] private TriggerDetector TriggerDetector;
|
||||
[SerializeField] private Animator SlicerAnimator;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TriggerDetector.SetAction(other =>
|
||||
{
|
||||
bool isItem = other.transform.parent.TryGetComponent(out ItemBehaviour item);
|
||||
if (!isItem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
item.CurrentType = item.CurrentType switch
|
||||
{
|
||||
ItemType.Apple => UpgradeManager.Is(BasicUpgrade.AppleSlices)
|
||||
? ItemType.AppleSlices
|
||||
: ItemType.Apple,
|
||||
|
||||
ItemType.Banana => UpgradeManager.Is(BasicUpgrade.BananaSlices)
|
||||
? ItemType.BananaSlices
|
||||
: ItemType.Banana,
|
||||
|
||||
ItemType.Kiwi => UpgradeManager.Is(BasicUpgrade.SlicedKiwi)
|
||||
? ItemType.SlicedKiwi
|
||||
: ItemType.Kiwi,
|
||||
|
||||
ItemType.Mango => UpgradeManager.Is(BasicUpgrade.MangoSlices)
|
||||
? ItemType.MangoSlices
|
||||
: ItemType.Mango,
|
||||
|
||||
ItemType.Durian => UpgradeManager.Is(BasicUpgrade.DurianSlices)
|
||||
? ItemType.DurianSlices
|
||||
: ItemType.Durian,
|
||||
|
||||
ItemType.BuddhasHand => UpgradeManager.Is(BasicUpgrade.BuddhasHandSlices)
|
||||
? ItemType.BuddhasHandSlices
|
||||
: ItemType.BuddhasHand,
|
||||
|
||||
var _ => item.CurrentType // Default
|
||||
};
|
||||
}, TriggerType.Enter);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (GameStateController.Is(GameState.Simulation))
|
||||
{
|
||||
if (SlicerAnimator.speed == 0)
|
||||
{
|
||||
SlicerAnimator.Play(0, 0, 0f); // Play from beginning
|
||||
SlicerAnimator.speed = 1; // Playing
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (SlicerAnimator.speed != 0)
|
||||
{
|
||||
SlicerAnimator.Play(0, 0, 0f); // Jump back to default frame
|
||||
SlicerAnimator.speed = 0; // Paused
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2a0d2e92ab8436a8854e59ee269188a
|
||||
timeCreated: 1776341863
|
||||
Reference in New Issue
Block a user