public c_combined_tile(c_tile source) { // go to the top left while (source.top_neighbor != null) { source = source.top_neighbor; } while (source.left_neighbor != null) { source = source.left_neighbor; } List <e_grid_value[]> grid_list = new List <e_grid_value[]>(); // Loop through each row of tiles for (c_tile row_start_tile = source; row_start_tile != null; row_start_tile = row_start_tile.bottom_neighbor) { // In each row of tiles, loop through each row of grid positions for (int row = 1; row < 9; row++) { List <e_grid_value> grid_row = new List <e_grid_value>(); // Loop through each tile in this row of tiles for (c_tile current = row_start_tile; current != null; current = current.right_neighbor) { // In each tile, loop through each column of grid positions for (int column = 1; column < 9; column++) { e_grid_value value = current.get_grid_position(row, column) ? e_grid_value.on : e_grid_value.off; grid_row.Add(value); } } grid_list.Add(grid_row.ToArray()); } } grid = grid_list.ToArray(); }
public static void display(this e_grid_value value) { switch (value) { case e_grid_value.on: Console.Write("#"); break; case e_grid_value.off: Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Write("."); Console.ResetColor(); break; case e_grid_value.monster: Console.ForegroundColor = ConsoleColor.Green; Console.Write("O"); Console.ResetColor(); break; } }