115 lines
4.4 KiB
C#
115 lines
4.4 KiB
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using DDD.Items;
|
|
using DDD.Npcs.Customers;
|
|
using DDD.Uis;
|
|
using PixelCrushers.DialogueSystem;
|
|
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
namespace DDD.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class OrderFood : Conditional
|
|
{
|
|
// private Customer _customer;
|
|
// private CustomerData _customerData;
|
|
// private BalloonUi _balloonUi;
|
|
// private string _orderFoodIdx;
|
|
//
|
|
// public override void OnAwake()
|
|
// {
|
|
// _customer = GetComponent<Customer>();
|
|
// _customerData = _customer.CustomerData;
|
|
// }
|
|
//
|
|
// public override void OnStart()
|
|
// {
|
|
// SetPreferredFoods();
|
|
//
|
|
// _balloonUi = _customer.BalloonUi;
|
|
// _balloonUi.OrderItem(_orderFoodIdx, _customerData.WaitTime, _customerData.HurryTime);
|
|
// _customer.OnInteraction += HandleFoodInteraction;
|
|
// _customer.RegisterPlayerInteraction();
|
|
// _customer.Bark("OrderFood", BarkOrder.FirstValid);
|
|
// }
|
|
//
|
|
// public override TaskStatus OnUpdate()
|
|
// {
|
|
// if (_balloonUi.IsFoodReceive())
|
|
// {
|
|
// _customer.OnInteraction -= HandleFoodInteraction;
|
|
// _customer.UnregisterPlayerInteraction();
|
|
// return TaskStatus.Success;
|
|
// }
|
|
//
|
|
// if (_balloonUi.IsWaitTimeOver())
|
|
// {
|
|
// _customer.OnInteraction -= HandleFoodInteraction;
|
|
// _customer.UnregisterPlayerInteraction();
|
|
// _customer.AddHappyPoint(-3);
|
|
// if (_customer.HappyPoint <= 0)
|
|
// {
|
|
// _balloonUi.CancelOrder();
|
|
// var barkName = _customer.HappyPoint switch
|
|
// {
|
|
// >= 3 => "SatisfactoryEvaluation",
|
|
// >= 2 => "MediocreEvaluation",
|
|
// >= 1 => "MediocreEvaluation",
|
|
// _ => "UnsatisfactoryEvaluation"
|
|
// };
|
|
// _customer.Bark(barkName, BarkOrder.FirstValid);
|
|
// }
|
|
// return TaskStatus.Failure;
|
|
// }
|
|
//
|
|
// return TaskStatus.Running;
|
|
// }
|
|
//
|
|
// private void HandleFoodInteraction()
|
|
// {
|
|
// var tycoonPlayer = GameManager.Instance.CurrentTycoonPlayer;
|
|
// var carriedFoodData = tycoonPlayer.GetCurrentItemData();
|
|
// if (carriedFoodData == null)
|
|
// {
|
|
// Debug.Log("플레이어가 가지고 있는 음식의 데이터가 없습니다.");
|
|
// return;
|
|
// }
|
|
//
|
|
// if (carriedFoodData.Idx == _orderFoodIdx)
|
|
// {
|
|
// tycoonPlayer.GiveItem();
|
|
// _balloonUi.ReceiveFood();
|
|
// var itemData = ItemManager.Instance.ItemDataSo.GetDataByIdx(carriedFoodData.Idx);
|
|
// _customer.SetFood(itemData);
|
|
// if (itemData.Quality == ItemQuality.High)
|
|
// {
|
|
// _customer.AddHappyPoint(1);
|
|
// }
|
|
//
|
|
// _customer.SpineController.PlayAnimation(CustomerSpineAnimation.Eat2.ToString(), true);
|
|
// }
|
|
// }
|
|
//
|
|
// private void SetPreferredFoods()
|
|
// {
|
|
// var dailyFoodSlotUis = TycoonUiManager.Instance.TycoonManagementUi.CookMenuUi.DailyFoodMenuUi.DailyFoodSlotUis;
|
|
// FoodTaste[] preferredTastes = { _customerData.GetPreferredFood(0), _customerData.GetPreferredFood(1), _customerData.GetPreferredFood(2) };
|
|
//
|
|
// foreach (var taste in preferredTastes)
|
|
// {
|
|
// var preferredFoods = dailyFoodSlotUis.FindAll(food => food.FoodData.Taste == taste);
|
|
// if (preferredFoods.Count > 0)
|
|
// {
|
|
// var randomIndex = Random.Range(0, preferredFoods.Count);
|
|
// _orderFoodIdx = preferredFoods[randomIndex].FoodData.Idx;
|
|
// return;
|
|
// }
|
|
// }
|
|
//
|
|
// var randomDailyFoodIndex = Random.Range(0, dailyFoodSlotUis.Count);
|
|
// _orderFoodIdx = dailyFoodSlotUis[randomDailyFoodIndex].FoodData.Idx;
|
|
// }
|
|
}
|
|
} |