多轮审查和修复
This commit is contained in:
33
Assets/Scripts/Enemies/AI/BD_WaitRandom.cs
Normal file
33
Assets/Scripts/Enemies/AI/BD_WaitRandom.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#if GRAPH_DESIGNER
|
||||
using UnityEngine;
|
||||
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
||||
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
|
||||
|
||||
namespace BaseGames.Enemies.AI
|
||||
{
|
||||
/// <summary>
|
||||
/// BD Action:在 [Min, Max] 范围内随机等待后返回 Success。
|
||||
/// 适用于巡逻间隔、随机攻击延迟等自然行为。
|
||||
/// </summary>
|
||||
public class BD_WaitRandom : Action
|
||||
{
|
||||
[UnityEngine.SerializeField] private float m_Min = 0.5f;
|
||||
[UnityEngine.SerializeField] private float m_Max = 2.0f;
|
||||
|
||||
private float _elapsed;
|
||||
private float _target;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
_elapsed = 0f;
|
||||
_target = Random.Range(m_Min, m_Max);
|
||||
}
|
||||
|
||||
public override TaskStatus OnUpdate()
|
||||
{
|
||||
_elapsed += Time.deltaTime;
|
||||
return _elapsed >= _target ? TaskStatus.Success : TaskStatus.Running;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user