48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using DDD.Npcs.Customers;
|
|
using DDD.Tycoons;
|
|
using DDD.Utility;
|
|
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
namespace DDD.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class CanVomit : Conditional
|
|
{
|
|
private Customer _customer;
|
|
private bool _canVomit;
|
|
private bool _isVomiting;
|
|
private Vector3 _vomitingPosition;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_customer = GetComponent<Customer>();
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
if (!_customer.CanVomit)
|
|
{
|
|
_canVomit = false;
|
|
return;
|
|
}
|
|
|
|
_customer.MoveMoneyCounter();
|
|
var random = Random.Range(0f, 100f);
|
|
if (random <= TycoonManager.Instance.TycoonStageController.StageDataSo.VomitingPercent)
|
|
{
|
|
_canVomit = true;
|
|
_vomitingPosition = Utils.RandomPositionOnGraph(1);
|
|
_customer.AIMovement.Move(_vomitingPosition);
|
|
}
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
return _canVomit ? TaskStatus.Success : TaskStatus.Failure;
|
|
}
|
|
}
|
|
} |