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 void getClosestPortal(ref Hero hero, ref int outx, ref int outy) { ArrayList list = new ArrayList(); ArrayList list2 = new ArrayList(); ArrayList list3 = new ArrayList(); int num11 = this.portalID.Count - 1; for (int i = 0; i <= num11; i++) { int num2 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(this.portalID[i]))); if ((((num2 != 50) && (num2 != 70)) && ((num2 != 60) && (num2 != 0x1f))) && ((num2 != 0x21) && (num2 != 0x23))) { list.Add(RuntimeHelpers.GetObjectValue(this.portalID[i])); list2.Add(RuntimeHelpers.GetObjectValue(this.posX[i])); list3.Add(RuntimeHelpers.GetObjectValue(this.posY[i])); } } if (list.Count == 1) { outx = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list2[0]))); outy = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list3[0]))); } else if (list.Count > 1) { int num4 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list2[0]))); int num5 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list3[0]))); double num3 = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), num4, num5); int num12 = list.Count - 1; for (int j = 1; j <= num12; j++) { int num7 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list2[j]))); int num8 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list3[j]))); double num9 = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), num7, num8); if (!(Math.Min(num3, num9) == num3)) { num4 = num7; num5 = num8; num3 = num9; } } outx = num4; outy = num5; } else { outx = -1; outy = -1; } }
public BonusBox getClosestBonusBox(ref Hero hero, ref double outdist) { if (this.bonusBoxes.Count == 1) { outdist = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), ((BonusBox) this.bonusBoxes[0]).getPosX(), ((BonusBox) this.bonusBoxes[0]).getPosY()); return (BonusBox) this.bonusBoxes[0]; } if (this.bonusBoxes.Count > 1) { BonusBox box2 = (BonusBox) this.bonusBoxes[0]; double num = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), box2.getPosX(), box2.getPosY()); int num5 = this.bonusBoxes.Count - 1; for (int i = 1; i <= num5; i++) { BonusBox box3 = (BonusBox) this.bonusBoxes[i]; double num3 = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), box3.getPosX(), box3.getPosY()); if (!(Math.Min(num, num3) == num)) { box2 = box3; num = num3; } } outdist = num; return box2; } outdist = double.MaxValue; return null; }
public void getClosestPortal(ref Hero hero, ref int outx, ref int outy) { ArrayList list = new ArrayList(); ArrayList list2 = new ArrayList(); ArrayList list3 = new ArrayList(); int num11 = this.portalID.Count - 1; for (int i = 0; i <= num11; i++) { int num2 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(this.portalID[i]))); if ((((num2 != 50) && (num2 != 70)) && ((num2 != 60) && (num2 != 0x1f))) && ((num2 != 0x21) && (num2 != 0x23))) { list.Add(RuntimeHelpers.GetObjectValue(this.portalID[i])); list2.Add(RuntimeHelpers.GetObjectValue(this.posX[i])); list3.Add(RuntimeHelpers.GetObjectValue(this.posY[i])); } } if (list.Count == 1) { outx = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list2[0]))); outy = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list3[0]))); } else if (list.Count > 1) { int num4 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list2[0]))); int num5 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list3[0]))); double num3 = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), num4, num5); int num12 = list.Count - 1; for (int j = 1; j <= num12; j++) { int num7 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list2[j]))); int num8 = Conversions.ToInteger(Conversion.Fix(RuntimeHelpers.GetObjectValue(list3[j]))); double num9 = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), num7, num8); if (!(Math.Min(num3, num9) == num3)) { num4 = num7; num5 = num8; num3 = num9; } } outx = num4; outy = num5; } else { outx = -1; outy = -1; } }
public BonusBox getClosestBonusBox(ref Hero hero, ref double outdist) { if (this.bonusBoxes.Count == 1) { outdist = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), ((BonusBox)this.bonusBoxes[0]).getPosX(), ((BonusBox)this.bonusBoxes[0]).getPosY()); return((BonusBox)this.bonusBoxes[0]); } if (this.bonusBoxes.Count > 1) { BonusBox box2 = (BonusBox)this.bonusBoxes[0]; double num = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), box2.getPosX(), box2.getPosY()); int num5 = this.bonusBoxes.Count - 1; for (int i = 1; i <= num5; i++) { BonusBox box3 = (BonusBox)this.bonusBoxes[i]; double num3 = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), box3.getPosX(), box3.getPosY()); if (!(Math.Min(num, num3) == num)) { box2 = box3; num = num3; } } outdist = num; return(box2); } outdist = double.MaxValue; return(null); }
public Resource getClosestResource(ref Hero hero, ref double outdist, int type) { ArrayList list = this.getResources(type); if (list == null) { outdist = double.MaxValue; return(null); } if (list.Count == 1) { outdist = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), ((Resource)list[0]).getPosX(), ((Resource)list[0]).getPosY()); return((Resource)list[0]); } if (list.Count > 1) { Resource resource2 = (Resource)list[0]; double num = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), resource2.getPosX(), resource2.getPosY()); int num5 = list.Count - 1; for (int i = 1; i <= num5; i++) { Resource resource3 = (Resource)list[i]; double num3 = this._getDistance((int)Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int)Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), resource3.getPosX(), resource3.getPosY()); if (!(Math.Min(num, num3) == num)) { resource2 = resource3; num = num3; } } outdist = num; return(resource2); } outdist = double.MaxValue; return(null); }
public Resource getClosestResource(ref Hero hero, ref double outdist, int type) { ArrayList list = this.getResources(type); if (list == null) { outdist = double.MaxValue; return null; } if (list.Count == 1) { outdist = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), ((Resource) list[0]).getPosX(), ((Resource) list[0]).getPosY()); return (Resource) list[0]; } if (list.Count > 1) { Resource resource2 = (Resource) list[0]; double num = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), resource2.getPosX(), resource2.getPosY()); int num5 = list.Count - 1; for (int i = 1; i <= num5; i++) { Resource resource3 = (Resource) list[i]; double num3 = this._getDistance((int) Math.Round(Conversion.Fix(Math.Round(hero.getPosX()))), (int) Math.Round(Conversion.Fix(Math.Round(hero.getPosY()))), resource3.getPosX(), resource3.getPosY()); if (!(Math.Min(num, num3) == num)) { resource2 = resource3; num = num3; } } outdist = num; return resource2; } outdist = double.MaxValue; return null; }