|
@@ -1,6 +1,7 @@
|
|
|
using CommonAI.Zone;
|
|
|
+using CommonAI.Zone.Helper;
|
|
|
using CommonAI.Zone.Instance;
|
|
|
-
|
|
|
+using CommonLang;
|
|
|
|
|
|
namespace XmdsCommonServer.Plugin.Units
|
|
|
{
|
|
@@ -78,7 +79,56 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
|
|
|
base.Disposing();
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ protected override bool TryAtkSelfEnemy()
|
|
|
+ {
|
|
|
+ bool ret = false;
|
|
|
+ using (var list = ListObjectPool<InstanceUnit>.AllocAutoRelease())
|
|
|
+ {
|
|
|
+ //找到离自己最近的单位攻击.
|
|
|
+ Parent.getObjectsRoundRange<InstanceUnit>(Collider.Object_BlockBody_TouchRound, X, Y, Info.GuardRange, list, AoiStatus);
|
|
|
+ DoAndRemoveCollection.UpdateAndRemove<InstanceUnit>(list, (InstanceUnit u) =>
|
|
|
+ {
|
|
|
+ return !u.IsActive;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (list != null && list.Count > 0)
|
|
|
+ {
|
|
|
+ list.Sort((a, b) =>
|
|
|
+ {
|
|
|
+ //选距离最近的单位.
|
|
|
+ float da = CMath.getDistanceSquare(a.X, a.Y, this.X, this.Y);
|
|
|
+ float db = CMath.getDistanceSquare(b.X, b.Y, this.X, this.Y);
|
|
|
+ return (int)(da - db);
|
|
|
+ });
|
|
|
+
|
|
|
+ foreach (SkillState skill in SkillStatus)
|
|
|
+ {
|
|
|
+ if (skill.LaunchSkill.AutoLaunch && skill.TryLaunch())
|
|
|
+ {
|
|
|
+ foreach (InstanceUnit u in list)
|
|
|
+ {
|
|
|
+ if (this.IsCanAttack(u) && Parent.IsAttackable(this, u, skill.Data.ExpectTarget, AttackReason.Attack, skill.Data))
|
|
|
+ {
|
|
|
+ //是否在守卫范围内.
|
|
|
+ if (CheckInAtkRange(u, this.Info.GuardRange + skill.Data.AttackRange))
|
|
|
+ {
|
|
|
+ //检测是否有可释放技能//
|
|
|
+ if (tryAutoLaunch(skill, u))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|