private void checkNeighbors(Tile currentTile, int widthCounter) { widthCounter++; for (int i = 0; i < 6; ++i) { int a = 0; a++; Debug.Assert(LandTileHeap.Count != 0); if (!currentTile.hasNeighbor((NeighborLocation)i)) { currentTile.addNeighbor(LandTileHeap.TakeAway(rand.Next() % LandTileHeap.Count), (NeighborLocation)i); currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value.addNeighbor(currentTile, (NeighborLocation)((i + 3) % 6)); Tile tempTile = currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value; for (int j = 0; j < i; ++j) { tempTile.addNeighbor(currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)j).Value, (NeighborLocation)(((j + 3) % 6) - 1)); } if (widthCounter < 3) { checkNeighbors(tempTile, widthCounter); } } } }
private void checkNeighbors(Tile currentTile, int widthCounter) { widthCounter++; for (int i = 0; i < 6; ++i) { int a = 0; a++; Debug.Assert(LandTileHeap.Count != 0); if (!currentTile.hasNeighbor((NeighborLocation)i)) { currentTile.addNeighbor(LandTileHeap.TakeAway(rand.Next() % LandTileHeap.Count), (NeighborLocation)i); currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value.addNeighbor(currentTile, (NeighborLocation)((i + 3) % 6)); Tile tempTile = currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)i).Value; for (int j = 0; j < i; ++j) tempTile.addNeighbor(currentTile.Neighbors.Single(n => n.Key == (NeighborLocation)j).Value, (NeighborLocation)(((j + 3) % 6) - 1)); if (widthCounter < 3) checkNeighbors(tempTile, widthCounter); } } }