41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using BehaviorDesigner.Runtime.Tasks;
|
|
using Gameplay.BT.Variables;
|
|
using Gameplay.Unit;
|
|
using Gameplay.AI;
|
|
using Framework;
|
|
|
|
public class BTEventMoveTo : Action
|
|
{
|
|
public SharedBattleInfo SharedBattleInfo;
|
|
|
|
private GameUnit _owner;
|
|
private GameUnit _target;
|
|
private AIUtils.AvoidanceContext avoidContext;
|
|
|
|
public override void OnStart()
|
|
{
|
|
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerID);
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (_owner == null) return TaskStatus.Failure;
|
|
|
|
// 避开其他AI
|
|
AIUtils.TryAvoidOtherUnit(_owner, ref avoidContext, SharedBattleInfo.Value.targetID);
|
|
|
|
if (SharedBattleInfo.Value.targetID != Constants.INVALID_UINT_ID && !AIUtils.IsNeedStop(_owner))
|
|
{
|
|
{
|
|
if (GameUnitManager.instance.infightUnits.Contains(SharedBattleInfo.Value.targetID))
|
|
{
|
|
var target = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.targetID);
|
|
if (target != null)
|
|
AIUtils.CheckAndMove(_owner, target.transData.cellIndex);
|
|
}
|
|
}
|
|
}
|
|
|
|
return TaskStatus.Failure;
|
|
}
|
|
} |