public void GetFloorTileMap(FloorTileMap randomisedFloorTileMap) { foreach (FloorTilemapIdentifier floorTileIdentifier in floorTileMapsArray) { if (floorTileIdentifier.floorTileMap == randomisedFloorTileMap) { Debug.Log("The appropriate tilemap for floor has been found!"); replacementFloorTileMapsArray = floorTileIdentifier.thisTilemap.placeholderFloorTiles; } } }
public void ReplaceFlooring(int tilemapIdentifier) { FloorTileMap findThisFloorTileMap = (FloorTileMap)tilemapIdentifier; roomManager.GetComponent <TileReplacementManager>().GetFloorTileMap(findThisFloorTileMap); //Now the instance should have the appropriate tiles replacementFloorTiles = roomManager.GetComponent <TileReplacementManager>().replacementFloorTileMapsArray; //Now this code should have the appropriate tiles for (int entryNumber = 0; entryNumber < replacementFloorTiles.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); //FloorTiles[entryNumber].sprite = replacementFloorTiles[entryNumber]; GetComponent <Tilemap>().SwapTile(FloorTiles[entryNumber], replacementFloorTiles[entryNumber]); // replacementFloorTiles.CopyTo(FloorTiles, 0); // GetComponent<Tilemap>().RefreshAllTiles(); } }