47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class PumpButton : MonoBehaviour
|
|
{
|
|
private SpriteButton _button;
|
|
private CoolingMachineViewer _coolingMachine;
|
|
|
|
private void Awake()
|
|
{
|
|
_coolingMachine = GetComponentInParent<CoolingMachineViewer>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_button = new SpriteButton(gameObject);
|
|
_button.OnButtonDown += OnButtonDown;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_button.OnButtonDown -= OnButtonDown;
|
|
_button = null;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_button.CheckButtonClick();
|
|
}
|
|
|
|
private void OnButtonDown()
|
|
{
|
|
if (!_coolingMachine.CanPump()) return;
|
|
|
|
if (_coolingMachine.isMachineEmpty)
|
|
{
|
|
_coolingMachine.PumpCooling();
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("in");
|
|
_coolingMachine.InjectCool();
|
|
}
|
|
}
|
|
}
|
|
} |