Added basic presser
This commit is contained in:
47
Assets/Scripts/Game/Buildings/Automation/PresserBuilding.cs
Normal file
47
Assets/Scripts/Game/Buildings/Automation/PresserBuilding.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Fruitomation.Global;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class PresserBuilding : Building
|
||||
{
|
||||
[Header("Presser Specific Buildings")]
|
||||
[SerializeField] private Animator PresserAnimator;
|
||||
[SerializeField] private Collider2D TopCollider;
|
||||
[SerializeField] private Collider2D BottomCollider;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (GameStateController.Is(GameState.Simulation))
|
||||
{
|
||||
if (PresserAnimator.speed == 0)
|
||||
{
|
||||
PresserAnimator.Play(0, 0, 0f); // Play from beginning
|
||||
PresserAnimator.speed = 0.2f; // Playing
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (PresserAnimator.speed != 0)
|
||||
{
|
||||
PresserAnimator.Play(0, 0, 0f); // Jump back to default frame
|
||||
PresserAnimator.speed = 0; // Paused
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Preserve, UsedImplicitly] public void OpenTop() => TopCollider.enabled = false;
|
||||
[Preserve, UsedImplicitly] public void CloseTop() => TopCollider.enabled = true;
|
||||
|
||||
[Preserve, UsedImplicitly] public void OpenBottom() => BottomCollider.enabled = false;
|
||||
[Preserve, UsedImplicitly] public void CloseBottom() => BottomCollider.enabled = true;
|
||||
|
||||
[Preserve, UsedImplicitly] public void Press()
|
||||
{
|
||||
Debug.Log("Presser Press");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user