void GenerateBlank() { tileTypeMap = new int[width * height]; for (int i = 0; i < tileTypeMap.Length; i++) { if (tiles.Count == i) { tiles.Add(NewTile()); } else { tiles[i].gameObject.SetActive(true); } var typeOfTile = RoomMath.IndexOnPerimeter(i, width, height) ? TileType.Wall : TileType.None; tiles[i].transform.localPosition = GetTileLocalPosition(i); tiles[i].position = Coordinate.FromPosition(i, width); SetTileType(i, typeOfTile); } for (int i = tileTypeMap.Length, l = tiles.Count; i < l; i++) { tiles[i].gameObject.SetActive(false); } }
List <int> GetNonPerimeterNeighbourIndices(List <int> indices, TileType neighbourType, int[] selector, int selectionValue) { var neighbours = new HashSet <int>(); for (int i = 0, j = indices.Count; i < j; i++) { var tileNeighbours = RoomSearch.GetNeighbourIndices(tileTypeMap, width, indices[i], neighbourType); for (int k = 0, l = tileNeighbours.Count; k < l; k++) { if (selector[tileNeighbours[k]] == selectionValue && !RoomMath.IndexOnPerimeter(tileNeighbours[k], width, height)) { neighbours.Add(tileNeighbours[k]); } } } return(new List <int>(neighbours)); }
public static List <int> GetNonPerimeterTilesThatBorderToType(int[] tileTypeMap, List <int> candidates, TileType borderType, int width) { var borderingTiles = new List <int>(); int height = tileTypeMap.Length / width; for (int i = 0, l = candidates.Count; i < l; i++) { if (GetNeighbourIndices(tileTypeMap, width, candidates[i], borderType).Count > 0 && !RoomMath.IndexOnPerimeter(candidates[i], width, height)) { borderingTiles.Add(candidates[i]); } } return(borderingTiles); }