public Ship getClosestNPC(ref Hero hero, ref SpaceStation ss, ref Portals portals, ArrayList NPCsToExclude, bool[] clb, string[] NPCsNames, double maxdistance) { ArrayList list = new ArrayList(); int num8 = clb.Count <bool>() - 1; for (int i = 0; i <= num8; i++) { if (clb[i]) { list.Add(NPCsNames[i]); } } if (list.Count > 0) { ArrayList list2 = new ArrayList(); int num9 = list.Count - 1; for (int j = 0; j <= num9; j++) { int num10 = this.ships.Count - 1; for (int k = 0; k <= num10; k++) { Ship ship2 = (Ship)this.ships[k]; if (((ship2.getIsNPC() && !ship2.getTaken()) && ship2.getUsername().Equals(Conversions.ToString(list[j]))) && !this.isExcludedID(ship2.getID(), NPCsToExclude)) { list2.Add(ship2); } } } if (list2.Count > 0) { Ship ship3; if (list2.Count == 1) { ship3 = (Ship)list2[0]; } else { ship3 = (Ship)list2[0]; double num4 = this._getDistance(hero.getPosX(), hero.getPosY(), ship3.getPosX(), ship3.getPosY()); int num11 = list2.Count - 1; for (int m = 0; m <= num11; m++) { Ship ship4 = (Ship)list2[m]; double num6 = this._getDistance(hero.getPosX(), hero.getPosY(), ship4.getPosX(), ship4.getPosY()); if (!(Math.Min(num4, num6) == num4)) { ship3 = ship4; num4 = num6; } } } if ((!this.isExcludedID(ship3.getID(), NPCsToExclude) && (Math.Sqrt(this._getDistance(hero.getPosX(), hero.getPosY(), ship3.getPosX(), ship3.getPosY())) < maxdistance)) && (Conversions.ToBoolean(Operators.NotObject(this.isCloseToSpaceStation(ship3, ss))) && !this.isCloseToPortal(ship3, portals))) { return(ship3); } } } return(null); }
public Ship getClosestNPC(ref Hero hero, ref SpaceStation ss, ref Portals portals, ArrayList NPCsToExclude, bool[] clb, string[] NPCsNames, double maxdistance) { ArrayList list = new ArrayList(); int num8 = clb.Count<bool>() - 1; for (int i = 0; i <= num8; i++) { if (clb[i]) { list.Add(NPCsNames[i]); } } if (list.Count > 0) { ArrayList list2 = new ArrayList(); int num9 = list.Count - 1; for (int j = 0; j <= num9; j++) { int num10 = this.ships.Count - 1; for (int k = 0; k <= num10; k++) { Ship ship2 = (Ship) this.ships[k]; if (((ship2.getIsNPC() && !ship2.getTaken()) && ship2.getUsername().Equals(Conversions.ToString(list[j]))) && !this.isExcludedID(ship2.getID(), NPCsToExclude)) { list2.Add(ship2); } } } if (list2.Count > 0) { Ship ship3; if (list2.Count == 1) { ship3 = (Ship) list2[0]; } else { ship3 = (Ship) list2[0]; double num4 = this._getDistance(hero.getPosX(), hero.getPosY(), ship3.getPosX(), ship3.getPosY()); int num11 = list2.Count - 1; for (int m = 0; m <= num11; m++) { Ship ship4 = (Ship) list2[m]; double num6 = this._getDistance(hero.getPosX(), hero.getPosY(), ship4.getPosX(), ship4.getPosY()); if (!(Math.Min(num4, num6) == num4)) { ship3 = ship4; num4 = num6; } } } if ((!this.isExcludedID(ship3.getID(), NPCsToExclude) && (Math.Sqrt(this._getDistance(hero.getPosX(), hero.getPosY(), ship3.getPosX(), ship3.getPosY())) < maxdistance)) && (Conversions.ToBoolean(Operators.NotObject(this.isCloseToSpaceStation(ship3, ss))) && !this.isCloseToPortal(ship3, portals))) { return ship3; } } } return null; }
public bool isCloseToPortal(Ship s, Portals p) { int num2; int num = p.getCount(); int num3 = (int)-((num2 == (num - 1)) > false); for (num2 = 0; num2 <= num3; num2++) { if ((p.getID(num2) != -1) && (Math.Sqrt(this._getDistance(s.getPosX(), s.getPosY(), (double)p.getPosX(num2), (double)p.getPosY(num2))) < 1000.0)) { return(true); } } return(false); }
public bool isCloseToPortal(Ship s, Portals p) { int num2; int num = p.getCount(); int num3 = (int) -((num2 == (num - 1)) > false); for (num2 = 0; num2 <= num3; num2++) { if ((p.getID(num2) != -1) && (Math.Sqrt(this._getDistance(s.getPosX(), s.getPosY(), (double) p.getPosX(num2), (double) p.getPosY(num2))) < 1000.0)) { return true; } } return false; }