Beispiel #1
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();
    }
Beispiel #2
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();
    }
    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();
    }
Beispiel #4
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)
    {
        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();
    }
Beispiel #6
0
    public override void PlaceAttributeVariation(EditorMazeTile tile)
    {
        ITileAttribute tileObstacle = (TileObstacle)tile.GetAttributes().FirstOrDefault(attribute => attribute is TileObstacle);

        if (tileObstacle == null)
        {
            return;                       // only place variation if there is already an obstacle
        }
        EditorMazeTileAttributePlacer tileAttributePlacer = new EditorMazeTileAttributePlacer(tile);

        tileAttributePlacer.PlaceTileObstacleVariation((TileObstacle)tileObstacle);
    }
Beispiel #7
0
    public void Remove(ITileAttribute attribute)
    {
        switch (attribute.GetType())
        {
        case Type t when t == typeof(TileObstacle):
            RemoveTileObstacle(attribute as TileObstacle);
            break;

        case Type t when t == typeof(PlayerSpawnpoint):
            RemovePlayerSpawnpoint(attribute as PlayerSpawnpoint);
            break;

        case Type t when t == typeof(MazeLevelEntry):
            RemoveMazeLevelEntry(attribute as MazeLevelEntry);
            break;

        default:
            Logger.Error($"Does not know how to remove attribute with type {attribute.GetType()}");
            break;
        }
    }
    public void Remove(ITileAttribute attribute)
    {
        switch (attribute.GetType())
        {
        case Type t when t == typeof(PlayerExit):
            RemovePlayerExit(attribute as PlayerExit);
            break;

        case Type t when t == typeof(TileObstacle):
            RemoveTileObstacle(attribute as TileObstacle);
            break;

        case Type t when t == typeof(PlayerSpawnpoint):
            RemovePlayerSpawnpoint(attribute as PlayerSpawnpoint);
            break;

        case Type t when t == typeof(EnemySpawnpoint):
            RemoveEnemySpawnpoint(attribute as EnemySpawnpoint);
            break;

        case Type t when t == typeof(PlayerOnly):
            RemovePlayerOnlyAttribute(attribute as PlayerOnly);
            break;

        case Type t when t == typeof(BridgePiece):
            RemoveBridgePiece(attribute as BridgePiece);
            break;

        case Type t when t == typeof(MusicInstrumentCase):
            RemoveMusicInstrumentCase(attribute as MusicInstrumentCase);
            break;

        default:
            Logger.Error($"Does not know how to remove attribute with type {attribute.GetType()}");
            break;
        }
    }
    public override void PlaceAttribute(EditorOverworldTile tile)
    {
        if (tile.TileMainMaterial.GetType() != typeof(GroundMainMaterial))
        {
            return;
        }

        EditorOverworldTileAttributePlacer tileAttributePlacer  = new EditorOverworldTileAttributePlacer(tile);
        OverworldTileAttributeRemover      tileAttributeRemover = new OverworldTileAttributeRemover(tile);

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

        if (MazeLevelEntry == null)
        {
            tileAttributeRemover.RemovePlayerSpawnpoint();
            tileAttributeRemover.RemoveTileObstacle();

            Logger.Log(Logger.Editor, $"Now place maze entry at {tile.GridLocation.X}, {tile.GridLocation.Y}");
            tileAttributePlacer.PlaceMazeLevelEntry();
            return;
        }

        tileAttributeRemover.RemoveMazeLevelEntry();
    }
Beispiel #10
0
    private ISerialisableTileAttribute CreateSerialisableTileAttribute(Tile tile, ITileAttribute tileAttribute)
    {
        if (tileAttribute.GetType() == typeof(TileObstacle))
        {
            TileObstacle tileObstacle = tileAttribute as TileObstacle;
            SerialisableTileObstacleAttribute serialisableTileObstacleAttribute =
                new SerialisableTileObstacleAttribute(
                    new TileConnectionScoreInfo(tileObstacle.ConnectionScore, tileObstacle.SpriteNumber));
            return(serialisableTileObstacleAttribute);
        }
        else if (tileAttribute.GetType() == typeof(PlayerExit))
        {
            PlayerExit playerExit = tileAttribute as PlayerExit;

            SerialisablePlayerExitAttribute serialisablePlayerExitAttribute = new SerialisablePlayerExitAttribute(
                new TileConnectionScoreInfo(playerExit.ConnectionScore, playerExit.SpriteNumber));
            return(serialisablePlayerExitAttribute);
        }
        else if (tileAttribute.GetType() == typeof(PlayerOnly))
        {
            SerialisablePlayerOnlyAttribute serialisablePlayerOnlyAttribute = new SerialisablePlayerOnlyAttribute();
            return(serialisablePlayerOnlyAttribute);
        }
        else if (tileAttribute.GetType() == typeof(PlayerSpawnpoint))
        {
            SerialisablePlayerSpawnpointAttribute serialisablePlayerSpawnpointAttribute = new SerialisablePlayerSpawnpointAttribute();
            return(serialisablePlayerSpawnpointAttribute);
        }
        else if (tileAttribute.GetType() == typeof(EnemySpawnpoint))
        {
            EnemySpawnpoint enemySpawnpoint = tileAttribute as EnemySpawnpoint;
            SerialisableEnemySpawnpointAttribute serialisableEnemySpawnpointAttribute = new SerialisableEnemySpawnpointAttribute(enemySpawnpoint.TileAreas);
            return(serialisableEnemySpawnpointAttribute);
        }
        else if (tileAttribute.GetType() == typeof(MazeLevelEntry))
        {
            MazeLevelEntry mazeLevelEntry = tileAttribute as MazeLevelEntry;
            SerialisableMazeLevelEntryAttribute serialisableMazeLevelEntryAttribute = new SerialisableMazeLevelEntryAttribute(mazeLevelEntry.MazeLevelName);
            return(serialisableMazeLevelEntryAttribute);
        }
        else if (tileAttribute.GetType() == typeof(BridgePiece))
        {
            BridgePiece          bridgePiece          = tileAttribute as BridgePiece;
            BridgePieceDirection bridgePieceDirection = bridgePiece.BridgePieceDirection;

            SerialisableBridgePieceAttribute serialisableBridgePieceAttribute = new SerialisableBridgePieceAttribute(bridgePieceDirection);
            return(serialisableBridgePieceAttribute);
        }
        else if (tileAttribute.GetType() == typeof(BridgeEdge))
        {
            BridgeEdge bridgeEdge = tileAttribute as BridgeEdge;

            SerialisableBridgeEdgeAttribute serialisableBridgeEdgeAttribute = new SerialisableBridgeEdgeAttribute(bridgeEdge.EdgeSide);
            return(serialisableBridgeEdgeAttribute);
        }
        else if (tileAttribute.GetType() == typeof(MusicInstrumentCase))
        {
            SerialisableMusicInstrumentCaseAttribute serialisableMusicInstrumentCaseAttribute = new SerialisableMusicInstrumentCaseAttribute();
            return(serialisableMusicInstrumentCaseAttribute);
        }
        else
        {
            Logger.Error($"Could not serialise the tile attribute {tileAttribute.GetType()}");
            return(null);
        }
    }