feat: add combat and deleveling AI
This commit is contained in:
34
Client/Domain/AI/State/MoveToTargetState.cs
Normal file
34
Client/Domain/AI/State/MoveToTargetState.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Client.Domain.AI.Combat;
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Service;
|
||||
using Client.Infrastructure.Service;
|
||||
|
||||
namespace Client.Domain.AI.State
|
||||
{
|
||||
public class MoveToTargetState : BaseState
|
||||
{
|
||||
public MoveToTargetState(AI ai) : base(ai)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DoExecute(WorldHandler worldHandler, Config config, AsyncPathMoverInterface asyncPathMover, Hero hero)
|
||||
{
|
||||
var target = hero.Target;
|
||||
if (target == null)
|
||||
{
|
||||
target = hero;
|
||||
}
|
||||
|
||||
var distance = hero.Transform.Position.HorizontalDistance(target.Transform.Position);
|
||||
|
||||
if (asyncPathMover.IsLocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (distance >= Helper.GetAttackDistanceByConfig(worldHandler, config, hero, target))
|
||||
{
|
||||
asyncPathMover.MoveAsync(target.Transform.Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user