public static void TryPlaceCornerFillersForNeighbours(Tile tile)
 {
     foreach (KeyValuePair <ObjectDirection, Tile> neighbour in tile.Neighbours)
     {
         TileCornerFillerRegister.TryPlaceCornerFillers(neighbour.Value);
     }
 }
示例#2
0
    public override void PlaceBackground(EditorOverworldTile tile)
    {
        EditorOverworldTileBackgroundPlacer tileBackgroundPlacer  = new EditorOverworldTileBackgroundPlacer(tile);
        OverworldTileBackgroundRemover      tileBackgroundRemover = new OverworldTileBackgroundRemover(tile);
        OverworldTileAttributeRemover       tileAttributeRemover  = new OverworldTileAttributeRemover(tile);

        Type            oldMainMaterial         = tile.TileMainMaterial?.GetType(); // old material before updating it
        ITileBackground overworldTileBaseGround = (OverworldTileBaseGround)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTileBaseGround);


        OverworldTileBaseGround oldOverworldTileBaseGround = (OverworldTileBaseGround)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTileBaseGround);

        if (oldMainMaterial != typeof(GroundMainMaterial))
        {
            List <ITileAttribute> attributes = tile.GetAttributes();
            for (int i = 0; i < attributes.Count; i++)
            {
                tileAttributeRemover.Remove(attributes[i]);
            }

            //if (oldMainMaterial == typeof(WaterMainMaterial) || tile.TileMainMaterial == null)
            //{
            //    tileBackgroundRemover.RemoveBackground<OverworldTileBaseWater>();
            //}

            //if(overworldTileBaseGround == null)
            //{
            //    tileBackgroundPlacer.PlaceBackground<OverworldTileBaseGround>();
            //}
            //else
            //{
            //    tileBackgroundPlacer.UpdateGroundConnectionsOnNeighbours(new OverworldDefaultGroundType());
            //}

            if (oldOverworldTileBaseGround != null && oldOverworldTileBaseGround.ConnectionScore != 16)
            {
                tileBackgroundRemover.RemoveBackground <OverworldTileBaseGround>();
            }

            OverworldTileBaseGround newMazeTileBaseGround = tileBackgroundPlacer.PlaceBackground <OverworldTileBaseGround>();
            // Remove water from the tile that is fully covered by land
            if (newMazeTileBaseGround.ConnectionScore == 16)
            {
                tileBackgroundRemover.RemoveBackground <OverworldTileBaseWater>();
            }
        }

        // Place corner fillers
        TileCornerFillerRegister.TryPlaceCornerFillers(tile);
        TileCornerFillerRegister.TryPlaceCornerFillersForNeighbours(tile);
    }
    public override void PlaceBackground(EditorMazeTile tile)
    {
        EditorMazeTileBackgroundPlacer tileBackgroundPlacer  = new EditorMazeTileBackgroundPlacer(tile);
        MazeTileBackgroundRemover      tileBackgroundRemover = new MazeTileBackgroundRemover(tile);
        MazeTileAttributeRemover       tileAttributeRemover  = new MazeTileAttributeRemover(tile);

        Type oldMainMaterial = tile.TileMainMaterial?.GetType(); // old material before updating it

        MazeTileBaseGround oldMazeTileBaseGround = (MazeTileBaseGround)tile.GetBackgrounds().FirstOrDefault(background => background is MazeTileBaseGround);

        if ((oldMainMaterial != typeof(GroundMainMaterial)))
        {
            List <ITileAttribute> attributes = tile.GetAttributes();
            for (int i = 0; i < attributes.Count; i++)
            {
                tileAttributeRemover.Remove(attributes[i]);
            }

            // Remove the old land background, because we are going to fully cover it with a new land background
            if (oldMazeTileBaseGround != null && oldMazeTileBaseGround.ConnectionScore != 16)
            {
                tileBackgroundRemover.RemoveBackground <MazeTileBaseGround>();
            }

            MazeTileBaseGround newMazeTileBaseGround = tileBackgroundPlacer.PlaceBackground <MazeTileBaseGround>();
            // Remove water from the tile that is fully covered by land
            if (newMazeTileBaseGround.ConnectionScore == 16)
            {
                tileBackgroundRemover.RemoveBackground <MazeTileBaseWater>();
            }
        }

        // Place corner fillers
        TileCornerFillerRegister.TryPlaceCornerFillers(tile);
        TileCornerFillerRegister.TryPlaceCornerFillersForNeighbours(tile);
    }