public static void check_for_neighbors(c_tile a, c_tile b) { // If two tiles have matching edge ID numbers, mark them as neighbors. for (int i = 0; i < k_edge_traverals.Length; i++) { for (int j = 0; j < k_edge_traverals.Length; j++) { if (a.edge_ids[i] == b.edge_ids[j]) { a.neighbors.Add(b); b.neighbors.Add(a); return; } } } }
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(); }
private bool try_align(c_tile neighbor) { if (this.compute_edge_id(k_edge_index_top) == neighbor.compute_edge_id(k_edge_index_bottom)) { this.top_neighbor = neighbor; neighbor.bottom_neighbor = this; return(true); } if (this.compute_edge_id(k_edge_index_bottom) == neighbor.compute_edge_id(k_edge_index_top)) { this.bottom_neighbor = neighbor; neighbor.top_neighbor = this; return(true); } if (this.compute_edge_id(k_edge_index_left) == neighbor.compute_edge_id(k_edge_index_right)) { this.left_neighbor = neighbor; neighbor.right_neighbor = this; return(true); } if (this.compute_edge_id(k_edge_index_right) == neighbor.compute_edge_id(k_edge_index_left)) { this.right_neighbor = neighbor; neighbor.left_neighbor = this; return(true); } return(false); }