38 lines
919 B
C#
38 lines
919 B
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using DDD.Npcs.Customers;
|
|
using UnityEngine;
|
|
using Action = BehaviorDesigner.Runtime.Tasks.Action;
|
|
|
|
namespace DDD.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class EatCocktail : Action
|
|
{
|
|
private Customer _customer;
|
|
private float _elapsedTime;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_customer = GetComponent<Customer>();
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
_elapsedTime = 0;
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_elapsedTime <= _customer.CurrentLevelData.EatingTime)
|
|
{
|
|
_elapsedTime += Time.deltaTime;
|
|
return TaskStatus.Running;
|
|
}
|
|
|
|
_customer.FinishFood();
|
|
return TaskStatus.Success;
|
|
}
|
|
}
|
|
} |