mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-16 08:25:20 +01:00
43 lines
932 B
C#
43 lines
932 B
C#
using BehaviorDesigner.Runtime;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace MoleMole
|
|
{
|
|
public class GetDistance : Action
|
|
{
|
|
public SharedFloat Distance;
|
|
|
|
private IAIEntity _aiEntity;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
BaseMonoAnimatorEntity component = GetComponent<BaseMonoAnimatorEntity>();
|
|
if (component is BaseMonoAvatar)
|
|
{
|
|
_aiEntity = (BaseMonoAvatar)component;
|
|
}
|
|
else if (component is BaseMonoMonster)
|
|
{
|
|
_aiEntity = (BaseMonoMonster)component;
|
|
}
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_aiEntity.AttackTarget == null || !_aiEntity.AttackTarget.IsActive())
|
|
{
|
|
return TaskStatus.Success;
|
|
}
|
|
Vector3 xZPosition = _aiEntity.XZPosition;
|
|
Vector3 xZPosition2 = _aiEntity.AttackTarget.XZPosition;
|
|
Distance.SetValue(Vector3.Distance(xZPosition, xZPosition2));
|
|
return TaskStatus.Success;
|
|
}
|
|
}
|
|
}
|