public List<Hex> HexesWithinRangeContainingAllies(Hex location, int range, Faction faction) { List<Hex> hexes_in_range = new List<Hex>(); foreach (Unit enemy in faction.GetAllAllyUnits()) { if (this.InRange(location, enemy.location, range)) { hexes_in_range.Add(enemy.location); } } return hexes_in_range; /* List<Hex> hexes_in_range = new List<Hex>(); int x = (int)location.coordinate.x; int xMin = Mathf.Max(0, x - range * 2); int xMax = Mathf.Min(x_max, x + range * 2); int y = (int)location.coordinate.y; int yMin = Mathf.Max(0, y - range * 2); int yMax = Mathf.Min(y_max, y + range * 2); for (int cur_x = xMin; cur_x <= xMax; cur_x++) { for (int cur_y = yMin; cur_y <= yMax; cur_y++) { Hex cur_hex; hex_dictionary.TryGetValue(cur_x + "," + cur_y, out cur_hex); if (cur_hex.occupying_unit != null && faction.IsAlly(cur_hex.occupying_unit)) hexes_in_range.Add(cur_hex); } } return hexes_in_range;*/ }