protected override List <int> sort_targets(List <int> targets) { Game_Unit unit = get_unit(); targets.Sort(delegate(int a, int b) { Vector2 loc1, loc2; int dist1, dist2; if (mode == 1) { loc1 = new Vector2(a % Global.game_map.width, a / Global.game_map.width); loc2 = new Vector2(b % Global.game_map.width, b / Global.game_map.width); dist1 = (int)(Math.Abs(unit.loc.X - loc1.X) + Math.Abs(unit.loc.Y - loc1.Y)); dist2 = (int)(Math.Abs(unit.loc.X - loc2.X) + Math.Abs(unit.loc.Y - loc2.Y)); } else { Game_Unit unit1 = Global.game_map.units[a]; Game_Unit unit2 = Global.game_map.units[b]; loc1 = unit1.loc_on_map(); loc2 = unit2.loc_on_map(); dist1 = Global.game_map.unit_distance(Unit_Id, a); dist2 = Global.game_map.unit_distance(Unit_Id, b); } int angle1 = ((360 - unit.angle(loc1)) + 90) % 360; int angle2 = ((360 - unit.angle(loc2)) + 90) % 360; return(angle1 == angle2 ? (loc1.Y == loc2.Y ? dist1 - dist2 : (int)(loc1.Y - loc2.Y)) : angle1 - angle2); }); return(targets); }
protected virtual List <T> sort_targets(List <T> targets) { Game_Unit unit = get_unit(); targets.Sort(delegate(T a, T b) { Vector2 loc1 = target_loc(a); Vector2 loc2 = target_loc(b); int angle1 = ((360 - unit.angle(loc1)) + 90) % 360; int angle2 = ((360 - unit.angle(loc2)) + 90) % 360; return(angle1 == angle2 ? (loc1.Y == loc2.Y ? distance_to_target(a) - distance_to_target(b) : (int)(loc1.Y - loc2.Y)) : angle1 - angle2); }); return(targets); }