107 lines
3.9 KiB
C#
107 lines
3.9 KiB
C#
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class FoodOrderState : INpcState
|
|
{
|
|
private TycoonNpc npc;
|
|
private float maxWaitTime = 30f; // 15초 동안 채워짐
|
|
private float foodEt; // 음식 경과 시간
|
|
private float drinkEt; // 음료 경과 시간
|
|
|
|
public FoodOrderState(TycoonNpc npc)
|
|
{
|
|
this.npc = npc;
|
|
}
|
|
|
|
public void OnEnter(NpcStateMachine npcStateMachine)
|
|
{
|
|
npc.BarkImg.gameObject.SetActive(true);
|
|
npc.BarkFillImg.gameObject.SetActive(true);
|
|
npc.FoodImg.sprite = DataManager.Inst.beer;
|
|
npc.FoodImg.gameObject.SetActive(true);
|
|
|
|
foodEt = 0f;
|
|
drinkEt = 0f;
|
|
npc.IsGetFood = false;
|
|
npc.IsGetDrink = false;
|
|
}
|
|
|
|
public void OnUpdate(NpcStateMachine npcStateMachine)
|
|
{
|
|
if (npc.IsGetDrink == false)
|
|
{
|
|
if (drinkEt < maxWaitTime)
|
|
{
|
|
drinkEt += Time.deltaTime;
|
|
npc.BarkFillImg.fillAmount = Mathf.Clamp(drinkEt / maxWaitTime, 0, 1);
|
|
if (npc.IsGetDrink)
|
|
{
|
|
npc.BarkImg.gameObject.SetActive(false);
|
|
npc.BarkFillImg.gameObject.SetActive(false);
|
|
npc.FoodImg.gameObject.SetActive(false);
|
|
|
|
npcStateMachine.InstantiateUi(DataManager.Inst.emojiHeart, npc.EmojiTransform);
|
|
|
|
npc.BarkFillImg.fillAmount = 0;
|
|
}
|
|
}
|
|
else if (drinkEt >= maxWaitTime)
|
|
{
|
|
npcStateMachine.InstantiateUi(DataManager.Inst.emojiAnger, npc.EmojiTransform);
|
|
npc.Satisfaction -= 10;
|
|
|
|
npc.BarkFillImg.fillAmount = 0;
|
|
|
|
npc.IsGetDrink = true;
|
|
}
|
|
}
|
|
else if (npc.IsGetDrink)
|
|
{
|
|
npc.FoodImg.sprite = DataManager.Inst.kingCrabMeat;
|
|
if (foodEt < maxWaitTime)
|
|
{
|
|
foodEt += Time.deltaTime;
|
|
npc.BarkFillImg.fillAmount = Mathf.Clamp(foodEt / maxWaitTime, 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.AssignedSeat.Dirty.SetActive(true);
|
|
npc.DoSeat = false;
|
|
|
|
npcStateMachine.ChangeState(new PayState(npc));
|
|
}
|
|
}
|
|
else if (foodEt >= maxWaitTime)
|
|
{
|
|
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.AssignedSeat.Dirty.SetActive(false);
|
|
npc.DoSeat = false;
|
|
|
|
npcStateMachine.ChangeState(new WalkOutSate(npc));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnExit(NpcStateMachine npcStateMachine)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |