71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class FoodOrderState : INpcState
|
|
{
|
|
private TycoonNpc npc;
|
|
private float fillTime = 15f; // 15초 동안 채워짐
|
|
private float elapsedTime = 0f; // 경과 시간
|
|
|
|
public FoodOrderState(TycoonNpc npc)
|
|
{
|
|
this.npc = npc;
|
|
}
|
|
|
|
public void OnEnter(NpcStateMachine npcStateMachine)
|
|
{
|
|
npc.BarkImg.gameObject.SetActive(true);
|
|
npc.BarkFillImg.gameObject.SetActive(true);
|
|
npc.FoodImg.gameObject.SetActive(true);
|
|
|
|
elapsedTime = 0f;
|
|
npc.IsGetFood = false;
|
|
}
|
|
|
|
public void OnUpdate(NpcStateMachine npcStateMachine)
|
|
{
|
|
if (elapsedTime < fillTime)
|
|
{
|
|
elapsedTime += Time.deltaTime;
|
|
npc.BarkFillImg.fillAmount = Mathf.Clamp(elapsedTime / fillTime, 0, 1);
|
|
|
|
if (npc.IsGetFood)
|
|
{
|
|
npc.BarkImg.gameObject.SetActive(false);
|
|
npc.BarkFillImg.gameObject.SetActive(false);
|
|
npc.FoodImg.gameObject.SetActive(false);
|
|
|
|
npcStateMachine.InstantiateUi(DataManager.Inst.emojiHeart, npc.EmojiTransform);
|
|
|
|
npc.AssignedSeat.IsUsing = false;
|
|
npc.AssignedSeat.IsDirty = true;
|
|
npc.DoSeat = false;
|
|
|
|
npcStateMachine.ChangeState(new PayState(npc));
|
|
}
|
|
}
|
|
else if (elapsedTime >= fillTime)
|
|
{
|
|
npcStateMachine.InstantiateUi(DataManager.Inst.emojiAnger, npc.EmojiTransform);
|
|
|
|
npc.BarkImg.gameObject.SetActive(false);
|
|
npc.BarkFillImg.gameObject.SetActive(false);
|
|
npc.FoodImg.gameObject.SetActive(false);
|
|
|
|
npc.AssignedSeat.IsUsing = false;
|
|
npc.AssignedSeat.IsDirty = false;
|
|
npc.DoSeat = false;
|
|
|
|
npcStateMachine.ChangeState(new WalkOutSate(npc));
|
|
}
|
|
}
|
|
|
|
public void OnExit(NpcStateMachine npcStateMachine)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |