|
@@ -25,11 +25,14 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
|
|
|
private InstanceUnit mCurAtkUnit = null;
|
|
|
|
|
|
+ //跟随最大距离的平方
|
|
|
+ private float mMaxFollowDistance = 10;
|
|
|
+
|
|
|
public XmdsInstancePet(InstanceZone zone, UnitInfo info, string name, int force, int level)
|
|
|
: base(zone, info, name, force, level)
|
|
|
{
|
|
|
-
|
|
|
- }
|
|
|
+ this.mMaxFollowDistance = (float)Math.Pow(Templates.CFG.PET_FOLLOW_DISTANCE_MAX, 2);
|
|
|
+ }
|
|
|
|
|
|
public override bool IsActive
|
|
|
{
|
|
@@ -464,29 +467,31 @@ namespace XmdsCommonServer.Plugin.Units
|
|
|
//两圆相切.
|
|
|
var atkr = this.GetSkillAttackRange(skillrange);
|
|
|
|
|
|
- if (Collider.Object_HitBody_TouchRound(target, this.X, this.Y, atkr))
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- else if(this.SummonerUnit != null)
|
|
|
+ if (Collider.Object_HitBody_TouchRound(target, this.X, this.Y, atkr))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else if (this.SummonerUnit != null && target != null)
|
|
|
{
|
|
|
- //宠物可以离开宿主的最大范围.
|
|
|
- float da = (float)Math.Pow(Templates.CFG.PET_FOLLOW_DISTANCE_MAX, 2);
|
|
|
-
|
|
|
- CommonLang.Geometry.Vector2 v1 = new CommonLang.Geometry.Vector2(this.X, this.Y);
|
|
|
- CommonLang.Geometry.Vector2 v2 = new CommonLang.Geometry.Vector2(target.X, target.Y);
|
|
|
- //方向.
|
|
|
- CommonLang.Geometry.Vector2 dir = (v2 - v1);
|
|
|
- dir.Normalize();
|
|
|
- var pos = v2 - dir * (atkr * target.BodyHitSize);
|
|
|
- float rd = CMath.getDistanceSquare(pos.X, pos.Y, this.SummonerUnit.X, this.SummonerUnit.Y);
|
|
|
-
|
|
|
- //在范围内.
|
|
|
- if (rd < da)
|
|
|
- {
|
|
|
- ret = true;
|
|
|
- }
|
|
|
- }
|
|
|
+ ////宠物可以离开宿主的最大范围.
|
|
|
+ //float da = (float)Math.Pow(Templates.CFG.PET_FOLLOW_DISTANCE_MAX, 2);
|
|
|
+
|
|
|
+ //CommonLang.Geometry.Vector2 v1 = new CommonLang.Geometry.Vector2(this.X, this.Y);
|
|
|
+ //CommonLang.Geometry.Vector2 v2 = new CommonLang.Geometry.Vector2(target.X, target.Y);
|
|
|
+ ////方向.
|
|
|
+ //CommonLang.Geometry.Vector2 dir = (v2 - v1);
|
|
|
+ //dir.Normalize();
|
|
|
+ //var pos = v2 - dir * (atkr * target.BodyHitSize);
|
|
|
+ //float rd = CMath.getDistanceSquare(pos.X, pos.Y, this.SummonerUnit.X, this.SummonerUnit.Y);
|
|
|
+
|
|
|
+ ////在范围内.
|
|
|
+ //if (rd < da)
|
|
|
+ //{
|
|
|
+ // ret = true;
|
|
|
+ //}
|
|
|
+ ret = CMath.getDistanceSquare(target.X, target.Y, this.SummonerUnit.X, this.SummonerUnit.Y) < this.mMaxFollowDistance;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return ret;
|
|
|
}
|