43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using DDD.Interfaces;
|
|
using UnityEngine;
|
|
using Action = BehaviorDesigner.Runtime.Tasks.Action;
|
|
|
|
namespace DDD.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom")]
|
|
[Serializable]
|
|
public class SelfStun : Action
|
|
{
|
|
[SerializeField]
|
|
private float _stunDuration = 4f;
|
|
|
|
private IStunnable _iStunnable;
|
|
private float _elapsedTime;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_iStunnable = transform.GetComponent<IStunnable>();
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
_iStunnable?.Stun(_stunDuration);
|
|
_elapsedTime = 0f;
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_iStunnable == null)
|
|
{
|
|
Debug.Log("_iStunnable을 찾을 수 없습니다.");
|
|
return TaskStatus.Success;
|
|
}
|
|
|
|
_elapsedTime += Time.deltaTime;
|
|
|
|
return _elapsedTime <= _stunDuration ? TaskStatus.Running : TaskStatus.Success;
|
|
}
|
|
}
|
|
} |