public void SetObligatoryWallTiles(WallTilemapIdentifier identifierWithOblitaryWalls)
    {
        Debug.Log("SetObligatoryWallTiles has been reached");
        replacementWallTiles = identifierWithOblitaryWalls.obligatoryTilemap.placeholderWallTiles;
        int[] arrayIndexForObligatoryTiles = identifierWithOblitaryWalls.arrayIndexForObligatoryTilemap;

        for (int entryNumber = 0; entryNumber < arrayIndexForObligatoryTiles.Length; entryNumber++)
        //this loop has to take each entry in the obligatory tilemap and replace the appropriate tile in this tilemap using the array index
        {
            // Debug.Log("Loop number: " + entryNumber);
            //FloorTiles[entryNumber].sprite = replacementFloorTiles[entryNumber];
            int indexOfTileToReplace = arrayIndexForObligatoryTiles[entryNumber];
            Debug.Log("Index of tile to replace is: " + arrayIndexForObligatoryTiles[entryNumber]);
            GetComponent <Tilemap>().SwapTile(WallTiles[indexOfTileToReplace], identifierWithOblitaryWalls.obligatoryTilemap.placeholderWallTiles[entryNumber]);
            // replacementFloorTiles.CopyTo(FloorTiles, 0);
            Debug.Log("Time to refresh colors");
            RoomManager.MyInstance.GetComponent <TileReplacementManager>().GetRandomColorForObligatoryWall(gameObject);
        }

        foreach (var position in GetComponent <Tilemap>().cellBounds.allPositionsWithin)
        {
            if (GetComponent <Tilemap>().HasTile(position))
            {
                TileBase tile = GetComponent <Tilemap>().GetTile(position);
                if (WallTiles.Contains(tile))
                {
                    GetComponent <Tilemap>().SetTile(position, null);
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void CreateObligatoryWallTileMap(WallTilemapIdentifier identifierWithOblitaryWalls, GameObject originalWallTileMap)
    {
        GameObject obligatoryTilemap = Instantiate(originalWallTileMap.gameObject, originalWallTileMap.gameObject.transform.position, transform.rotation);

        obligatoryTilemap.transform.parent = originalWallTileMap.transform.parent;
        obligatoryTilemap.GetComponent <TilemapRenderer>().sortingOrder = originalWallTileMap.GetComponent <TilemapRenderer>().sortingOrder - 1;
        obligatoryTilemap.GetComponent <TileChanger>().SetObligatoryWallTiles(identifierWithOblitaryWalls);
    }