public override void PlaceBackground(EditorOverworldTile tile)
    {
        EditorOverworldTileBackgroundPlacer tileBackgroundPlacer  = new EditorOverworldTileBackgroundPlacer(tile);
        OverworldTileBackgroundRemover      tileBackgroundRemover = new OverworldTileBackgroundRemover(tile);
        OverworldTileAttributeRemover       tileAttributeRemover  = new OverworldTileAttributeRemover(tile);

        List <ITileBackground> backgrounds            = tile.GetBackgrounds();
        ITileBackground        overworldTileBaseWater = (OverworldTileBaseWater)tile.GetBackgrounds().FirstOrDefault(background => background is OverworldTileBaseWater);

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

            if (oldMainMaterial == null || oldMainMaterial == typeof(GroundMainMaterial))
            {
                tileBackgroundRemover.RemoveBackground <OverworldTilePath>();
            }
            OverworldTileBaseWater water = tileBackgroundPlacer.PlaceBackground <OverworldTileBaseWater>();

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

            if (oldMainMaterial == null || oldMainMaterial == typeof(GroundMainMaterial))
            {
                if (water.ConnectionScore == 16) // remove background if we completely covered the tile with water
                {
                    tileBackgroundRemover.RemoveBackground <OverworldTileBaseGround>();
                }
            }
        }
    }
Example #2
0
    private ISerialisableTileBackground CreateSerialisableTileBackground(ITileBackground tileBackground)
    {
        if (tileBackground.GetType() == typeof(MazeTilePath) || tileBackground.GetType() == typeof(OverworldTilePath))
        {
            TilePath tilePath = tileBackground as TilePath;

            SerialisableTilePathBackground serialisableTilePathBackground = new SerialisableTilePathBackground(tilePath.ConnectionScore);
            return(serialisableTilePathBackground);
        }
        else if (tileBackground.GetType() == typeof(MazeTileBaseWater) || tileBackground.GetType() == typeof(OverworldTileBaseWater))
        {
            SerialisableTileBaseWater serialisableTileBaseWater = new SerialisableTileBaseWater();
            return(serialisableTileBaseWater);
        }
        else if (tileBackground.GetType() == typeof(MazeTileBaseGround) || (tileBackground.GetType() == typeof(OverworldTileBaseGround)))
        {
            TileBaseGround tileGround = tileBackground as TileBaseGround;

            SerialisableTileBaseGround serialisableTileBaseGround = new SerialisableTileBaseGround(tileGround.ConnectionScore);

            return(serialisableTileBaseGround);
        }
        else
        {
            Logger.Error($"Could not serialise the tile background {tileBackground.GetType()}");
            return(null);
        }
    }
    public override void PlaceBackgroundVariation(EditorMazeTile tile)
    {
        ITileBackground mazeTilePath = (MazeTilePath)tile.GetBackgrounds().FirstOrDefault(background => background is MazeTilePath);

        if (mazeTilePath == null)
        {
            return;                       // only place variation if there is already a path
        }
        EditorMazeTileBackgroundPlacer tileBackgroundPlacer = new EditorMazeTileBackgroundPlacer(tile);

        tileBackgroundPlacer.PlacePathVariation((MazeTilePath)mazeTilePath);
    }
Example #4
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 PlaceBackgroundVariation(EditorMazeTile tile)
    {
        Logger.Log("Try place background variation");
        ITileBackground mazeTileGround = (MazeTileBaseGround)tile.GetBackgrounds().FirstOrDefault(background => background is MazeTileBaseGround);

        if (mazeTileGround == null)
        {
            return;
        }

        EditorMazeTileBackgroundPlacer tileBackgroundPlacer = new EditorMazeTileBackgroundPlacer(tile);

        tileBackgroundPlacer.PlaceGroundVariation((MazeTileBaseGround)mazeTileGround);
    }
Example #6
0
    public override void PlaceBackground(EditorMazeTile tile)
    {
        EditorMazeTileBackgroundPlacer tileBackgroundPlacer  = new EditorMazeTileBackgroundPlacer(tile);
        MazeTileBackgroundRemover      tileBackgroundRemover = new MazeTileBackgroundRemover(tile);
        MazeTileAttributeRemover       tileAttributeRemover  = new MazeTileAttributeRemover(tile);

        List <ITileBackground> backgrounds       = tile.GetBackgrounds();
        ITileBackground        mazeTileBaseWater = backgrounds.FirstOrDefault(background => background is MazeTileBaseWater);

        // Only act if there is no water
        if (mazeTileBaseWater == null)
        {
            Type oldMainMaterial = tile.TileMainMaterial?.GetType(); // old material before updating it

            // Remove any background overlays for Ground tiles, such as paths.
            if (oldMainMaterial == null || oldMainMaterial == typeof(GroundMainMaterial))
            {
                tileBackgroundRemover.RemoveBackground <MazeTilePath>();
            }

            MazeTileBaseWater water = tileBackgroundPlacer.PlaceBackground <MazeTileBaseWater>();

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

            if (oldMainMaterial == null || oldMainMaterial == typeof(GroundMainMaterial))
            {
                if (water.ConnectionScore == 16) // remove background if we completely covered the tile with water
                {
                    tileBackgroundRemover.RemoveBackground <MazeTileBaseGround>();
                }
            }
        }
    }
    public override void PlaceBackground(EditorMazeTile tile)
    {
        if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial))
        {
            return;
        }

        EditorMazeTileBackgroundPlacer tileBackgroundPlacer  = new EditorMazeTileBackgroundPlacer(tile);
        MazeTileBackgroundRemover      tileBackgroundRemover = new MazeTileBackgroundRemover(tile);

        ITileBackground mazeTilePath = (MazeTilePath)tile.GetBackgrounds().FirstOrDefault(background => background is MazeTilePath);

        if (mazeTilePath == null)
        {
            MazeTileAttributeRemover tileAttributeRemover = new MazeTileAttributeRemover(tile);
            tileAttributeRemover.RemoveTileObstacle();

            tileBackgroundPlacer.PlacePath(new MazeLevelDefaultPathType());
            return;
        }

        // This path already exists on this tile, so remove it
        tileBackgroundRemover.RemovePath();
    }