78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
![]() |
using System;
|
||
|
using BlueWater.Interfaces;
|
||
|
using BlueWater.Players.Tycoons;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BlueWater.Tycoons
|
||
|
{
|
||
|
[Serializable]
|
||
|
public class Vomiting : InteractionFurniture
|
||
|
{
|
||
|
private Sprite vomitingImage;
|
||
|
private bool _isInteracting;
|
||
|
private float _elapsedTime;
|
||
|
|
||
|
protected override void OnEnable()
|
||
|
{
|
||
|
base.OnEnable();
|
||
|
|
||
|
Initialize();
|
||
|
}
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
if (_isInteracting)
|
||
|
{
|
||
|
if (InteractionCanvas.BalloonUi.IsWaitTimeOver())
|
||
|
{
|
||
|
var damageable = GameManager.Instance.CurrentTycoonPlayer.GetComponent<IDamageable>();
|
||
|
damageable?.TakeDamage(1);
|
||
|
Destroy();
|
||
|
}
|
||
|
|
||
|
var clamp = Mathf.Clamp(_elapsedTime / 3f, 0f, 1f);
|
||
|
EventManager.OnInteracting?.Invoke(clamp);
|
||
|
if (_elapsedTime > 3f)
|
||
|
{
|
||
|
Destroy();
|
||
|
}
|
||
|
|
||
|
_elapsedTime += Time.deltaTime;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void Initialize()
|
||
|
{
|
||
|
InteractionMessage = "치우기";
|
||
|
vomitingImage = VisualLook.GetComponent<SpriteRenderer>().sprite;
|
||
|
InteractionCanvas.BalloonUi.OrderItem(vomitingImage, 0, TycoonManager.Instance.TycoonStageController.StageDataSo.VomitingWaitTime);
|
||
|
}
|
||
|
|
||
|
public override void Interaction()
|
||
|
{
|
||
|
_elapsedTime = 0f;
|
||
|
EventManager.OnInteracting?.Invoke(_elapsedTime);
|
||
|
GameManager.Instance.CurrentTycoonPlayer.SpineController.PlayAnimation(TycoonPlayerSpineAnimation.Cleaning, true);
|
||
|
_isInteracting = true;
|
||
|
}
|
||
|
|
||
|
public override void CancelInteraction()
|
||
|
{
|
||
|
_elapsedTime = 0f;
|
||
|
EventManager.OnInteracting?.Invoke(_elapsedTime);
|
||
|
GameManager.Instance.CurrentTycoonPlayer.SpineController.PlayAnimation(TycoonPlayerSpineAnimation.Idle, true);
|
||
|
_isInteracting = false;
|
||
|
}
|
||
|
|
||
|
public override bool CanInteraction()
|
||
|
{
|
||
|
return !GameManager.Instance.CurrentTycoonPlayer.TycoonPickupHandler.IsPickedUpCocktail();
|
||
|
}
|
||
|
|
||
|
private void Destroy()
|
||
|
{
|
||
|
GameManager.Instance.CurrentTycoonPlayer.SpineController.PlayAnimation(TycoonPlayerSpineAnimation.Idle, true);
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
}
|
||
|
}
|