You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
namespace Game
|
|
{
|
|
public partial class AIEntityBase<T> where T : new()
|
|
{
|
|
protected void MoveTo()
|
|
{
|
|
_moveTo("向前移动", true, 0.6f, 45, 0);
|
|
}
|
|
|
|
protected void MoveAroundTo()
|
|
{
|
|
_moveTo("向前环绕", true, 1, 180, 90);
|
|
}
|
|
|
|
protected void MoveAround()
|
|
{
|
|
_moveTo("横向环绕", true, 1, 180, 120);
|
|
}
|
|
|
|
protected void MoveBack()
|
|
{
|
|
_moveTo("向后移动", false, 0.6f, 45, 0);
|
|
}
|
|
|
|
private void _moveTo(string name, bool toward, float randChance, float randAngle, float forbidAngle)
|
|
{
|
|
Do(name, () =>
|
|
{
|
|
var target = Util.GetEntity(_entity.Target());
|
|
var dir = target.Pos() - _entity.Pos();
|
|
dir.y = 0;
|
|
if (GameRandom.Roll(randChance))
|
|
{
|
|
dir = GameRandom.RandomDir(dir, randAngle, forbidAngle);
|
|
}
|
|
|
|
Util.EntityMove(_entity.ID(), dir);
|
|
return ETaskStatus.Success;
|
|
});
|
|
}
|
|
|
|
private void _stop()
|
|
{
|
|
Do($"停止移动", () =>
|
|
{
|
|
Util.EntityStopMove(_entity.ID());
|
|
return ETaskStatus.Success;
|
|
});
|
|
}
|
|
}
|
|
} |