public void GetWallTileMap(WallTileMap randomisedWallTileMap, GameObject originalWallTileMap) { foreach (WallTilemapIdentifier wallTileIdentifier in wallTileMapsArray) { if (wallTileIdentifier.wallTileMap == randomisedWallTileMap) { Debug.Log("The appropriate tilemap for walls has been found! It is: " + wallTileIdentifier); replacementWallTileMapsArray = wallTileIdentifier.thisTilemap.placeholderWallTiles; if (wallTileIdentifier.obligatoryTilemap != null) { CreateObligatoryWallTileMap(wallTileIdentifier, originalWallTileMap); } } } }
public void ReplaceWalls(int tilemapIdentifier) { // Debug.Log("ReplaceWalls has been reached"); // Debug.Log("The random number for walls is " + num); WallTileMap findThisWallTileMap = (WallTileMap)tilemapIdentifier; roomManager.GetComponent <TileReplacementManager>().GetWallTileMap(findThisWallTileMap, gameObject); //Now the instance should have the appropriate tiles replacementWallTiles = roomManager.GetComponent <TileReplacementManager>().replacementWallTileMapsArray; //Now this code should have the appropriate tiles for (int entryNumber = 0; entryNumber < replacementWallTiles.Length; entryNumber++) //I made a foreach loop here before to try to do the same thing and got an "array out of range" error { // Debug.Log("Loop number: " + entryNumber); GetComponent <Tilemap>().SwapTile(WallTiles[entryNumber], replacementWallTiles[entryNumber]); GetComponent <Tilemap>().RefreshAllTiles(); } }