public Claimable GetClosestClaimable(Vector2 p) { if (claimables.Count > 0) { Claimable closest = null; float minDist = float.PositiveInfinity; foreach (Claimable a in claimables) { if (!a.taken) { float aDist = PathHelper.DistanceSquared(p, a.GetOriginPosition()); if (aDist < minDist) { closest = a; minDist = aDist; } } } return(closest); } return(null); }
public Claimable GetClosestClaimable(Vector2 p, ManagerHelper mH) { if (claimables.Count > 0) { Claimable closest = claimables.First(); float minDist = PathHelper.DistanceSquared(p, closest.GetOriginPosition()); foreach (Claimable a in claimables) { if (!a.taken) { float aDist = PathHelper.DistanceSquared(p, a.GetOriginPosition()); if (aDist < minDist) { closest = a; minDist = aDist; } } } if (closest.taken) { return(null); } else { return(closest); } } return(null); }
protected override void DeathmatchPath(ManagerHelper mH) { var temp = (Deathmatch)mH.GetGametype(); Claimable c = temp.GetClosestClaimable(GetOriginPosition(), mH); if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected override void SurvivalPath(ManagerHelper mH) { pathTimerEnd = .5; var temp = (Survival)mH.GetGametype(); Claimable c = temp.GetClosestClaimable(GetOriginPosition()); NPC enemy = mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black), GetOriginPosition()); if (enemy != null && PathHelper.DistanceSquared(GetOriginPosition(), enemy.GetOriginPosition()) < 200 * 200) { mH.GetPathHelper().FindEscapePath(GetOriginPosition(), enemy.GetOriginPosition(), 400, mH, 200, path); } else if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } else { RandomPath(mH); } }