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.
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
namespace Game
|
|
{
|
|
public partial class AIEntityBase<T> : AIObjectBase<T> where T : new()
|
|
{
|
|
protected void FindTarget()
|
|
{
|
|
Selector(() =>
|
|
{
|
|
Condition("是否有目标", () => _entity.Target() != 0);
|
|
Do("重新寻找目标", () =>
|
|
{
|
|
//TODO 现在直接设置为玩家
|
|
_entity.SetTarget(Util.GetMaster().ID());
|
|
return ETaskStatus.Success;
|
|
});
|
|
});
|
|
}
|
|
|
|
protected void CheckStagger()
|
|
{
|
|
Condition($"检查硬直状态", () => !Util.EntityIsStagger(_entity));
|
|
}
|
|
|
|
protected void CheckModuleType(EAIModuleType moduleType)
|
|
{
|
|
Condition($"检查模块类型-{moduleType}", () => _entity.aI.ModuleType.Value == moduleType);
|
|
}
|
|
|
|
protected void CheckDistance(float min, float max)
|
|
{
|
|
Condition($"距离在{min}到{max}之间", () =>
|
|
{
|
|
var distance = Util.EntityDistance(_entity.ID(), _entity.Target());
|
|
return distance >= min && distance <= max;
|
|
});
|
|
}
|
|
|
|
protected void CastSkill(int index, bool needPermit)
|
|
{
|
|
Sequence(($"释放技能[{index}],{needPermit}"), () =>
|
|
{
|
|
if (needPermit) _checkAttackPermit();
|
|
_stop();
|
|
_castSkill(index);
|
|
if (needPermit) _resetAttackPermit();
|
|
});
|
|
}
|
|
|
|
private void _castSkill(int index)
|
|
{
|
|
Do($"释放技能[{index}]", () =>
|
|
{
|
|
var target = Util.GetEntity(_entity.Target());
|
|
var dir = target.Pos() - _entity.Pos();
|
|
Util.CastSkillMonster(_entity, index, dir);
|
|
return ETaskStatus.Success;
|
|
});
|
|
}
|
|
|
|
private void _checkAttackPermit()
|
|
{
|
|
Condition("检查攻击权限", () => _entity.aI.AttackPermit.Value);
|
|
}
|
|
|
|
private void _resetAttackPermit()
|
|
{
|
|
Do("重置攻击权限", () =>
|
|
{
|
|
_entity.aI.AttackPermit.Value = false;
|
|
return ETaskStatus.Success;
|
|
});
|
|
}
|
|
}
|
|
} |