Esempio n. 1
0
    public override void PlaceAttribute(EditorMazeTile tile)
    {
        if (tile.TileMainMaterial.GetType() == typeof(WaterMainMaterial))
        {
            if (tile.TryGetBridgePiece() == null)
            {
                return;
            }
        }

        EditorMazeTileAttributePlacer tileAttributePlacer  = new EditorMazeTileAttributePlacer(tile);
        MazeTileAttributeRemover      tileAttributeRemover = new MazeTileAttributeRemover(tile);

        ITileAttribute musicInstrumentCase = (MusicInstrumentCase)tile.GetAttributes().FirstOrDefault(attribute => attribute is MusicInstrumentCase);

        if (musicInstrumentCase == null)
        {
            tileAttributeRemover.RemoveEnemySpawnpoint();
            tileAttributeRemover.RemovePlayerExit();
            tileAttributeRemover.RemovePlayerOnlyAttribute();
            tileAttributeRemover.RemovePlayerSpawnpoint();
            tileAttributeRemover.RemoveTileObstacle();

            Logger.Warning(Logger.Editor, $"Now place music instrument case at {tile.GridLocation.X}, {tile.GridLocation.Y}");
            tileAttributePlacer.PlaceMusicInstrumentCase();
            return;
        }

        tileAttributeRemover.RemoveMusicInstrumentCase();
    }
Esempio n. 2
0
    public override void PlaceAttribute(EditorMazeTile tile)
    {
        if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial))
        {
            return;
        }

        EditorMazeTileAttributePlacer tileAttributePlacer  = new EditorMazeTileAttributePlacer(tile);
        MazeTileAttributeRemover      tileAttributeRemover = new MazeTileAttributeRemover(tile);

        ITileAttribute tileObstacle = (TileObstacle)tile.GetAttributes().FirstOrDefault(attribute => (attribute is TileObstacle && !(attribute is PlayerExit)));

        if (tileObstacle == null)
        {
            tileAttributeRemover.RemoveEnemySpawnpoint();
            tileAttributeRemover.RemovePlayerExit();
            tileAttributeRemover.RemovePlayerOnlyAttribute();
            tileAttributeRemover.RemovePlayerSpawnpoint();
            tileAttributeRemover.RemoveMusicInstrumentCase();

            MazeTileBackgroundRemover tileBackgroundRemover = new MazeTileBackgroundRemover(tile);
            tileBackgroundRemover.RemovePath();

            tileAttributePlacer.PlaceTileObstacle(ObstacleType.Bush);
            return;
        }

        // Tile is already blocked
        tileAttributeRemover.RemoveTileObstacle();
    }
Esempio n. 3
0
    public override void PlaceAttribute(EditorMazeTile tile)
    {
        if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial))
        {
            return;
        }

        EditorMazeTileAttributePlacer tileAttributePlacer  = new EditorMazeTileAttributePlacer(tile);
        MazeTileAttributeRemover      tileAttributeRemover = new MazeTileAttributeRemover(tile);

        ITileAttribute playerOnlyAttribute = (PlayerOnly)tile.GetAttributes().FirstOrDefault(attribute => attribute is PlayerOnly);

        if (playerOnlyAttribute == null)
        {
            tileAttributeRemover.RemoveTileObstacle();
            tileAttributeRemover.RemovePlayerExit();
            tileAttributeRemover.RemoveEnemySpawnpoint();
            tileAttributeRemover.RemoveMusicInstrumentCase();
            tileAttributeRemover.RemovePlayerSpawnpoint();

            Logger.Warning($"Now place player only attribute at {tile.GridLocation.X}, {tile.GridLocation.Y}");
            tileAttributePlacer.PlacePlayerOnlyAttribute(PlayerOnlyType.Bush);
            return;
        }

        tileAttributeRemover.RemovePlayerOnlyAttribute();
    }
    public override void PlaceAttribute(EditorMazeTile tile)
    {
        if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial))
        {
            return;
        }

        EditorMazeTileAttributePlacer tileAttributePlacer  = new EditorMazeTileAttributePlacer(tile);
        MazeTileAttributeRemover      tileAttributeRemover = new MazeTileAttributeRemover(tile);

        ITileAttribute playerSpawnpoint = (PlayerSpawnpoint)tile.GetAttributes().FirstOrDefault(attribute => attribute is PlayerSpawnpoint);

        if (playerSpawnpoint == null)
        {
            tileAttributeRemover.RemoveEnemySpawnpoint();
            tileAttributeRemover.RemovePlayerExit();
            tileAttributeRemover.RemovePlayerOnlyAttribute();
            tileAttributeRemover.RemoveTileObstacle();

            tileAttributePlacer.PlacePlayerSpawnpoint();
            return;
        }

        tileAttributeRemover.RemovePlayerSpawnpoint();
    }
Esempio n. 5
0
    public override void PlaceAttribute(EditorMazeTile tile)
    {
        if (tile.TileMainMaterial.GetType() != typeof(WaterMainMaterial))
        {
            Logger.Log("TODO: Check if this works. Bridge can also be placed on any tile with a coastline");
            return;
        }

        EditorMazeTileAttributePlacer tileAttributePlacer  = new EditorMazeTileAttributePlacer(tile);
        MazeTileAttributeRemover      tileAttributeRemover = new MazeTileAttributeRemover(tile);

        BridgePiece bridgePiece = (BridgePiece)tile.GetAttributes().FirstOrDefault(attribute => (attribute is BridgePiece));

        if (bridgePiece == null)
        {
            tileAttributePlacer.PlaceBridgePiece(BridgePieceDirection.Horizontal);
        }
        else if (bridgePiece.BridgePieceDirection == BridgePieceDirection.Horizontal)
        {
            tileAttributeRemover.RemoveBridgePiece();
            tileAttributePlacer.PlaceBridgePiece(BridgePieceDirection.Vertical);
        }
        else
        {
            tileAttributeRemover.RemoveBridgePiece();
        }
    }
    public override void PlaceAttribute(EditorMazeTile tile)
    {
        Logger.Log("Try place Enemy Spawnpoint");
        if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial))
        {
            return;
        }

        EditorMazeTileAttributePlacer tileAttributePlacer  = new EditorMazeTileAttributePlacer(tile);
        MazeTileAttributeRemover      tileAttributeRemover = new MazeTileAttributeRemover(tile);

        ITileAttribute enemySpawnpoint = (EnemySpawnpoint)tile.GetAttributes().FirstOrDefault(attribute => attribute is EnemySpawnpoint);

        if (enemySpawnpoint == null)
        {
            tileAttributeRemover.RemovePlayerExit();
            tileAttributeRemover.RemovePlayerOnlyAttribute();
            tileAttributeRemover.RemovePlayerSpawnpoint();
            tileAttributeRemover.RemoveTileObstacle();
            tileAttributeRemover.RemoveMusicInstrumentCase();

            tileAttributePlacer.PlaceEnemySpawnpoint();

            TileAreaToEnemySpawnpointAssigner.Instance?.CheckForEnemySpawnpointOnTile();
            return;
        }

        tileAttributeRemover.RemoveEnemySpawnpoint();
        TileAreaToEnemySpawnpointAssigner.Instance?.CheckForEnemySpawnpointOnTile();
    }
Esempio n. 7
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();
    }
    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);
    }