public void RenewTiles() { GridTile[,] temp = new GridTile[gridSize + 2, gridSize + 2]; for (int x = 0; x < temp.GetLength(0); x++) { for (int y = 0; y < temp.GetLength(1); y++) { temp[x, y] = new GridTile(GridTile.TileTypes.Empty); } } for (int x = 0; x < tiles.GetLength(0); x++) { for (int y = 0; y < tiles.GetLength(1); y++) { temp[x + 1, y + 1] = tiles[x, y]; } } for (int x = 1; x < temp.GetLength(0) - 1; x++) { for (int y = 1; y < temp.GetLength(1) - 1; y++) { if (temp[x, y].type == GridTile.TileTypes.Wall) { temp[x, y].adjTiles[0] = temp[x, y + 1].type; temp[x, y].adjTiles[1] = temp[x - 1, y].type; temp[x, y].adjTiles[2] = temp[x + 1, y].type; temp[x, y].adjTiles[3] = temp[x, y - 1].type; temp[x, y].diagTiles[0] = temp[x - 1, y + 1].type; temp[x, y].diagTiles[1] = temp[x + 1, y + 1].type; temp[x, y].diagTiles[2] = temp[x - 1, y - 1].type; temp[x, y].diagTiles[3] = temp[x + 1, y - 1].type; } tiles[x - 1, y - 1] = temp[x, y]; } } }