//Map bounds constructor (creates an empty map of specified size) public Board(short x_lower, short x_upper, short y_lower, short y_upper, short z_lower, short z_upper) { TileGenerationSet defaultGenSet = new TileGenerationSet(); //Add all tiles to the board for (short x = x_lower; x <= x_upper; x++) { for (short y = y_lower; y <= y_upper; y++) { for (short z = z_lower; z <= z_upper; z++) { if (x + y + z == 0) { tiles.Add(new HexPosition(x, y, z), new Hex(defaultGenSet)); } } } } //Add all intersections foreach (KeyValuePair <HexPosition, Hex> tile in tiles) { //Check every intersection by inspecting the two mutual neighbors List <HexPosition> neighbors = tile.Key.GetNeighbors(); for (int i = 0; i < 6; i++) { int j = i + 1 < 6 ? i + 1 : 0; //Check that both neighbors are in the board if (tiles.ContainsKey(neighbors[i]) && tiles.ContainsKey(neighbors[j])) { intersections.TryAdd(new VertexPosition(tile.Key, neighbors[i], neighbors[j]), new Vertex()); } } } }
public Hex(TileGenerationSet tileset) { Random rand = new Random(); //Console.WriteLine("res count: " + tileset.resource_pool.Count); //Console.WriteLine("num count: " + tileset.number_pool.Count); type = tileset.resource_pool[rand.Next(tileset.resource_pool.Count)]; tileset.resource_pool.RemoveAt(tileset.resource_pool.FindIndex(res => res == type)); if (type == Resource.desert || type == Resource.sea || type == Resource.harbor_brick || type == Resource.harbor_ore || type == Resource.harbor_sheep || type == Resource.harbor_wheat || type == Resource.harbor_wood || type == Resource.harbor_any) { number = 0; } else { number = tileset.number_pool[rand.Next(tileset.number_pool.Count)]; tileset.number_pool.RemoveAt(tileset.number_pool.FindIndex(num => num == number)); } }