+ 상호작용 오브젝트 외곽선 기능 추가 + 손님 계산 기능 추가 + 손님 계산 시 Ui 출력 및 파티클, 효과 추가 + 대화 시스템 로직 수정 + 테이블 수정 + 캐릭터 스파인 교체
86 lines
2.9 KiB
C#
86 lines
2.9 KiB
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using BlueWater.Items;
|
|
using BlueWater.Npcs.Customers;
|
|
using BlueWater.Uis;
|
|
using PixelCrushers.DialogueSystem;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class OrderBeverage : Conditional
|
|
{
|
|
private Customer _customer;
|
|
private CustomerData _customerData;
|
|
private FoodBalloonUi _foodBalloonUi;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_customer = GetComponent<Customer>();
|
|
_customerData = _customer.CustomerData;
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
_foodBalloonUi = _customer.FoodBalloonUi;
|
|
// TODO : 음료가 다양해질 때 수정해야함
|
|
_foodBalloonUi.OrderFood(40001, _customerData.WaitTime, _customerData.HurryTime);
|
|
|
|
_customer.OnInteraction += HandleBeverageInteraction;
|
|
_customer.RegisterPlayerInteraction();
|
|
_customer.Bark("OrderBeverage", BarkOrder.FirstValid);
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_foodBalloonUi.IsFoodReceive())
|
|
{
|
|
_customer.OnInteraction -= HandleBeverageInteraction;
|
|
_customer.UnregisterPlayerInteraction();
|
|
return TaskStatus.Success;
|
|
}
|
|
|
|
if (_foodBalloonUi.IsWaitTimeOver())
|
|
{
|
|
_customer.OnInteraction -= HandleBeverageInteraction;
|
|
_customer.UnregisterPlayerInteraction();
|
|
_customer.AddHappyPoint(-3);
|
|
if (_customer.HappyPoint <= 0)
|
|
{
|
|
_foodBalloonUi.CancelOrder();
|
|
DialogueLua.SetVariable("HappyPoint", _customer.HappyPoint);
|
|
_customer.Bark("PayMoney", BarkOrder.FirstValid);
|
|
}
|
|
return TaskStatus.Failure;
|
|
}
|
|
|
|
return TaskStatus.Running;
|
|
}
|
|
|
|
private void HandleBeverageInteraction()
|
|
{
|
|
var tycoonPlayer = GameManager.Instance.CurrentTycoonPlayer;
|
|
var carriedBeverageData = tycoonPlayer.GetCurrentItemData();
|
|
if (carriedBeverageData == null)
|
|
{
|
|
Debug.Log("플레이어가 가지고 있는 음식의 데이터가 없습니다.");
|
|
return;
|
|
}
|
|
|
|
// TODO : 음료가 다양해질 때 수정해야함
|
|
if (carriedBeverageData.Idx == 40001)
|
|
{
|
|
tycoonPlayer.GiveItem();
|
|
_foodBalloonUi.ReceiveFood();
|
|
_customer.SetFood(carriedBeverageData);
|
|
if (carriedBeverageData.Quality == ItemQuality.High)
|
|
{
|
|
_customer.AddHappyPoint(1);
|
|
}
|
|
_customer.SpineController.PlayAnimation(CustomerSpineAnimation.Eat.ToString(), true);
|
|
}
|
|
}
|
|
}
|
|
} |