From 4e06f1facc8e23e0b602954f02ec56fafba4c50c Mon Sep 17 00:00:00 2001 From: IDMhan Date: Mon, 22 Jan 2024 12:06:16 +0900 Subject: [PATCH] #146 Drink Order --- BlueWater/Assets/02.Scripts/DataManager.cs | 1 + .../02.Scripts/Npc/Guest/FoodOrderState.cs | 85 ++++++++++++------- .../Assets/02.Scripts/Tycoon/TycoonNpc.cs | 1 + .../Assets/02.Scripts/Tycoon/TycoonPlayer.cs | 45 ++++++++-- .../Assets/02.Scripts/Utility/GlobalValue.cs | 4 +- 5 files changed, 97 insertions(+), 39 deletions(-) diff --git a/BlueWater/Assets/02.Scripts/DataManager.cs b/BlueWater/Assets/02.Scripts/DataManager.cs index 90290aa1e..e9bc3b18c 100644 --- a/BlueWater/Assets/02.Scripts/DataManager.cs +++ b/BlueWater/Assets/02.Scripts/DataManager.cs @@ -33,6 +33,7 @@ namespace BlueWaterProject public Sprite tomato; public Sprite onion; public Sprite kingCrabMeat; + public Sprite beer; private void Init() { diff --git a/BlueWater/Assets/02.Scripts/Npc/Guest/FoodOrderState.cs b/BlueWater/Assets/02.Scripts/Npc/Guest/FoodOrderState.cs index be2e5127e..ce5217e59 100644 --- a/BlueWater/Assets/02.Scripts/Npc/Guest/FoodOrderState.cs +++ b/BlueWater/Assets/02.Scripts/Npc/Guest/FoodOrderState.cs @@ -1,4 +1,3 @@ -using BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject; using UnityEngine; // ReSharper disable once CheckNamespace @@ -7,8 +6,9 @@ namespace BlueWaterProject public class FoodOrderState : INpcState { private TycoonNpc npc; - private float fillTime = 15f; // 15초 동안 채워짐 - private float elapsedTime = 0f; // 경과 시간 + private float maxWaitTime = 30f; // 15초 동안 채워짐 + private float foodEt; // 음식 경과 시간 + private float drinkEt; // 음료 경과 시간 public FoodOrderState(TycoonNpc npc) { @@ -19,47 +19,72 @@ namespace BlueWaterProject { npc.BarkImg.gameObject.SetActive(true); npc.BarkFillImg.gameObject.SetActive(true); + npc.FoodImg.sprite = DataManager.Inst.beer; npc.FoodImg.gameObject.SetActive(true); - elapsedTime = 0f; + foodEt = 0f; + drinkEt = 0f; npc.IsGetFood = false; + npc.IsGetDrink = false; } public void OnUpdate(NpcStateMachine npcStateMachine) { - if (elapsedTime < fillTime) + if (npc.IsGetDrink == false) { - elapsedTime += Time.deltaTime; - npc.BarkFillImg.fillAmount = Mathf.Clamp(elapsedTime / fillTime, 0, 1); - - if (npc.IsGetFood) + 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 (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.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); - - 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; + npc.AssignedSeat.IsUsing = false; + npc.AssignedSeat.IsDirty = false; + npc.DoSeat = false; - npcStateMachine.ChangeState(new WalkOutSate(npc)); + npcStateMachine.ChangeState(new WalkOutSate(npc)); + } } } diff --git a/BlueWater/Assets/02.Scripts/Tycoon/TycoonNpc.cs b/BlueWater/Assets/02.Scripts/Tycoon/TycoonNpc.cs index e728a2a05..3f22ff4f8 100644 --- a/BlueWater/Assets/02.Scripts/Tycoon/TycoonNpc.cs +++ b/BlueWater/Assets/02.Scripts/Tycoon/TycoonNpc.cs @@ -25,6 +25,7 @@ namespace BlueWaterProject public Image FoodImg { get; set; } public Transform EmojiTransform { get; set; } public bool IsGetFood { get; set; } + public bool IsGetDrink { get; set; } [Title("PayState")] public PayController PayController { get; set; } diff --git a/BlueWater/Assets/02.Scripts/Tycoon/TycoonPlayer.cs b/BlueWater/Assets/02.Scripts/Tycoon/TycoonPlayer.cs index 350be9407..fad4e487d 100644 --- a/BlueWater/Assets/02.Scripts/Tycoon/TycoonPlayer.cs +++ b/BlueWater/Assets/02.Scripts/Tycoon/TycoonPlayer.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using BlueWaterProject.Type; using PixelCrushers.DialogueSystem; @@ -167,14 +168,20 @@ namespace BlueWaterProject transform.position = position; } - public void TakeFoodFromKitchen() + public void TakeKingCrab() { - if (!foodTransform.gameObject.activeSelf) - { - foodVisual.sprite = DataManager.Inst.kingCrabMeat; - foodTransform.gameObject.SetActive(true); - foodOnHand = GlobalValue.FoodOnHand.KING_CRAB; - } + if (foodTransform.gameObject.activeSelf) return; + foodVisual.sprite = DataManager.Inst.kingCrabMeat; + foodTransform.gameObject.SetActive(true); + foodOnHand = GlobalValue.FoodOnHand.KING_CRAB; + } + + public void TakeBeer() + { + if (foodTransform.gameObject.activeSelf) return; + foodVisual.sprite = DataManager.Inst.beer; + foodTransform.gameObject.SetActive(true); + foodOnHand = GlobalValue.FoodOnHand.BEER; } public void TakeFoodFromPlayer() @@ -185,7 +192,29 @@ namespace BlueWaterProject var tycoonNpc = proximitySelector.CurrentUsable.gameObject.GetComponent(); if (tycoonNpc != null && tycoonNpc.DoSeat) { - tycoonNpc.IsGetFood = true; + switch (foodOnHand) + { + case GlobalValue.FoodOnHand.NONE: + break; + case GlobalValue.FoodOnHand.KING_CRAB: + case GlobalValue.FoodOnHand.JELLYFISH: + case GlobalValue.FoodOnHand.ONION: + case GlobalValue.FoodOnHand.TOMATO: + case GlobalValue.FoodOnHand.SCALLION: + case GlobalValue.FoodOnHand.CLAM: + case GlobalValue.FoodOnHand.SALT: + case GlobalValue.FoodOnHand.CHILI_POWDER: + case GlobalValue.FoodOnHand.DINOSAUR_EGG: + case GlobalValue.FoodOnHand.DINOSAUR_MEAT: + tycoonNpc.IsGetFood = true; + break; + case GlobalValue.FoodOnHand.BEER: + case GlobalValue.FoodOnHand.WINE: + tycoonNpc.IsGetDrink = true; + break; + default: + throw new ArgumentOutOfRangeException(); + } foodTransform.gameObject.SetActive(false); foodOnHand = GlobalValue.FoodOnHand.NONE; } diff --git a/BlueWater/Assets/02.Scripts/Utility/GlobalValue.cs b/BlueWater/Assets/02.Scripts/Utility/GlobalValue.cs index c15ae6c68..6c7935dc2 100644 --- a/BlueWater/Assets/02.Scripts/Utility/GlobalValue.cs +++ b/BlueWater/Assets/02.Scripts/Utility/GlobalValue.cs @@ -18,7 +18,9 @@ namespace BlueWaterProject SALT, CHILI_POWDER, DINOSAUR_EGG, - DINOSAUR_MEAT + DINOSAUR_MEAT, + BEER, + WINE } public enum InIslandPlayerMode