120 lines
4.2 KiB
C#
120 lines
4.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using PixelCrushers.DialogueSystem;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class KitchenController : MonoBehaviour
|
|
{
|
|
private bool isFoodInSot;
|
|
private bool isCooking;
|
|
public Image cookingProcess;
|
|
private Dictionary<GlobalValue.FoodOnHand, int> ingredientsInPot = new Dictionary<GlobalValue.FoodOnHand, int>();
|
|
private Dictionary<GlobalValue.FoodOnHand, int> kingCrabRecipe = new Dictionary<GlobalValue.FoodOnHand, int>
|
|
{
|
|
{ GlobalValue.FoodOnHand.ONION, 1 },
|
|
{ GlobalValue.FoodOnHand.SCALLION, 1 },
|
|
{ GlobalValue.FoodOnHand.TOMATO, 1 }
|
|
};
|
|
|
|
public void AddIngredient()
|
|
{
|
|
var player = GameManager.Inst.TycoonPlayer;
|
|
if (player.foodTransform.gameObject.activeSelf)
|
|
{
|
|
var ingredient = player.foodOnHand;
|
|
if (!ingredientsInPot.ContainsKey(ingredient))
|
|
ingredientsInPot[ingredient] = 0;
|
|
|
|
ingredientsInPot[ingredient]++;
|
|
player.foodTransform.gameObject.SetActive(false);
|
|
player.foodOnHand = GlobalValue.FoodOnHand.NONE;
|
|
}
|
|
else if (isFoodInSot)
|
|
{
|
|
player.foodVisual.sprite = DataManager.Inst.kingCrabMeat;
|
|
player.foodTransform.gameObject.SetActive(true);
|
|
player.foodOnHand = GlobalValue.FoodOnHand.KING_CRAB;
|
|
cookingProcess.fillAmount = 0;
|
|
isFoodInSot = false;
|
|
}
|
|
}
|
|
|
|
public bool CheckRecipe(Dictionary<GlobalValue.FoodOnHand, int> recipe)
|
|
{
|
|
foreach (var ingredient in recipe)
|
|
{
|
|
if (!ingredientsInPot.ContainsKey(ingredient.Key) || ingredientsInPot[ingredient.Key] != ingredient.Value)
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void Cook()
|
|
{
|
|
if (CheckRecipe(kingCrabRecipe))
|
|
{
|
|
ingredientsInPot.Clear();
|
|
StartCoroutine(CookingProcess());
|
|
}
|
|
}
|
|
|
|
private IEnumerator CookingProcess()
|
|
{
|
|
isCooking = true;
|
|
float duration = 3.0f; // 조리 시간 3초
|
|
float elapsed = 0; // 경과 시간
|
|
|
|
while (elapsed < duration)
|
|
{
|
|
elapsed += Time.deltaTime;
|
|
cookingProcess.fillAmount = Mathf.Clamp01(elapsed / duration);
|
|
yield return null;
|
|
}
|
|
|
|
// 조리 완료 후 처리
|
|
isCooking = false;
|
|
isFoodInSot = true;
|
|
}
|
|
|
|
public void ScallionBox()
|
|
{
|
|
var player = GameManager.Inst.TycoonPlayer;
|
|
if (player.foodTransform.gameObject.activeSelf) return;
|
|
player.foodVisual.sprite = DataManager.Inst.scallion;
|
|
player.foodTransform.gameObject.SetActive(true);
|
|
player.foodOnHand = GlobalValue.FoodOnHand.SCALLION;
|
|
}
|
|
|
|
public void OnionBox()
|
|
{
|
|
var player = GameManager.Inst.TycoonPlayer;
|
|
if (player.foodTransform.gameObject.activeSelf) return;
|
|
player.foodVisual.sprite = DataManager.Inst.onion;
|
|
player.foodTransform.gameObject.SetActive(true);
|
|
player.foodOnHand = GlobalValue.FoodOnHand.ONION;
|
|
}
|
|
|
|
public void TomatoBox()
|
|
{
|
|
var player = GameManager.Inst.TycoonPlayer;
|
|
if (player.foodTransform.gameObject.activeSelf) return;
|
|
player.foodVisual.sprite = DataManager.Inst.tomato;
|
|
player.foodTransform.gameObject.SetActive(true);
|
|
player.foodOnHand = GlobalValue.FoodOnHand.TOMATO;
|
|
}
|
|
|
|
public void KingCrab()
|
|
{
|
|
var player = GameManager.Inst.TycoonPlayer;
|
|
if (player.foodTransform.gameObject.activeSelf) return;
|
|
player.foodVisual.sprite = DataManager.Inst.kingCrabMeat;
|
|
player.foodTransform.gameObject.SetActive(true);
|
|
player.foodOnHand = GlobalValue.FoodOnHand.KING_CRAB;
|
|
}
|
|
}
|
|
} |