+ 상호작용 오브젝트 외곽선 기능 추가 + 손님 계산 기능 추가 + 손님 계산 시 Ui 출력 및 파티클, 효과 추가 + 대화 시스템 로직 수정 + 테이블 수정 + 캐릭터 스파인 교체
88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using BlueWater.Npcs.Customers;
|
|
using BlueWater.Uis;
|
|
using PixelCrushers.DialogueSystem;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class PayMoney : Conditional
|
|
{
|
|
private Customer _customer;
|
|
private CustomerData _customerData;
|
|
private FoodBalloonUi _foodBalloonUi;
|
|
private int _goldIdx;
|
|
private bool _isPaidMoney;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_customer = GetComponent<Customer>();
|
|
_customerData = _customer.CustomerData;
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
_foodBalloonUi = _customer.FoodBalloonUi;
|
|
_foodBalloonUi.PayMoney(_customerData.WaitTime, _customerData.HurryTime);
|
|
_customer.OnInteraction += HandlePayMoneyInteraction;
|
|
_customer.RegisterPlayerInteraction();
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_isPaidMoney)
|
|
{
|
|
return TaskStatus.Success;
|
|
}
|
|
|
|
if (_foodBalloonUi.IsWaitTimeOver())
|
|
{
|
|
_customer.OnInteraction -= HandlePayMoneyInteraction;
|
|
_customer.UnregisterPlayerInteraction();
|
|
_foodBalloonUi.CancelOrder();
|
|
_foodBalloonUi.HideUi();
|
|
// _customer.AddHappyPoint(-3);
|
|
// if (_customer.HappyPoint <= 0)
|
|
// {
|
|
// _foodBalloonUi.CancelOrder();
|
|
// _customer.Bark("CancelOrder");
|
|
// }
|
|
return TaskStatus.Failure;
|
|
}
|
|
|
|
return TaskStatus.Running;
|
|
}
|
|
|
|
private async void HandlePayMoneyInteraction()
|
|
{
|
|
var tycoonPlayer = GameManager.Instance.CurrentTycoonPlayer;
|
|
var foodPrice = _customer.ItemData.Price;
|
|
var tip = _customer.HappyPoint switch
|
|
{
|
|
>= 3 => 2f,
|
|
2 => 1.5f,
|
|
1 => 1.1f,
|
|
_ => 1f
|
|
};
|
|
var finalPrice = (int)(foodPrice * tip);
|
|
tycoonPlayer.GetMoney(finalPrice);
|
|
_customer.PayMoney(finalPrice);
|
|
_foodBalloonUi.HideUi();
|
|
_customer.OnInteraction -= HandlePayMoneyInteraction;
|
|
|
|
await Awaitable.WaitForSecondsAsync(1f);
|
|
|
|
_customer.UnregisterPlayerInteraction();
|
|
_foodBalloonUi.CancelOrder();
|
|
|
|
// TODO : 대화 안나옴
|
|
DialogueLua.SetVariable("HappyPoint", _customer.HappyPoint);
|
|
_customer.Bark("PayMoney", BarkOrder.FirstValid);
|
|
|
|
_isPaidMoney = true;
|
|
}
|
|
}
|
|
} |