41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
![]() |
using System;
|
||
|
using BehaviorDesigner.Runtime.Tasks;
|
||
|
using BlueWater.Npcs.Customers;
|
||
|
using BlueWater.Tycoons;
|
||
|
using UnityEngine;
|
||
|
using Random = UnityEngine.Random;
|
||
|
|
||
|
namespace BlueWater.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()
|
||
|
{
|
||
|
_customer.MoveMoneyCounter();
|
||
|
var random = Random.Range(0f, 100f);
|
||
|
if (random <= TycoonManager.Instance.TycoonStageController.StageDataSo.VomitingPercent)
|
||
|
{
|
||
|
_canVomit = true;
|
||
|
_vomitingPosition = _customer.AIMovement.SetRandomPoint();
|
||
|
_customer.AIMovement.Move(_vomitingPosition);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override TaskStatus OnUpdate()
|
||
|
{
|
||
|
return _canVomit ? TaskStatus.Success : TaskStatus.Failure;
|
||
|
}
|
||
|
}
|
||
|
}
|