public void AddTileAttributes(SerialisableTile serialisableTile, EditorOverworldTile tile) { EditorOverworldTileAttributePlacer tileAttributePlacer = new EditorOverworldTileAttributePlacer(tile); foreach (SerialisableTileAttribute serialisableTileAttribute in serialisableTile.TileAttributes) { Type type = Type.GetType(serialisableTileAttribute.AttributeType); //if (tileAttributeId == SerialisableTileAttribute.ObstacleAttributeCode) //{ // tileAttributePlacer.PlaceTileObstacle(ObstacleType.Bush, new TileConnectionScoreInfo(serialisableTileAttribute.ObstacleConnectionScore, serialisableTileAttribute.SpriteNumber)); //TODO, find a way to use polymorphism so we can cast as SerialisableTileObstacleAttribute instead of a general //} //else if (tileAttributeId == SerialisableTileAttribute.PlayerExitCode) //{ // tileAttributePlacer.PlacePlayerExit(ObstacleType.Bush, new TileConnectionScoreInfo(serialisableTileAttribute.ObstacleConnectionScore, serialisableTileAttribute.SpriteNumber)); //} if (type.Equals(typeof(SerialisablePlayerSpawnpointAttribute))) { tileAttributePlacer.PlacePlayerSpawnpoint(); } else if (type.Equals(typeof(SerialisableMazeLevelEntryAttribute))) { SerialisableMazeLevelEntryAttribute serialisableMazeLevelEntryAttribute = (SerialisableMazeLevelEntryAttribute)JsonUtility.FromJson(serialisableTileAttribute.SerialisedData, type); MazeLevelEntry mazeLevelEntry = tileAttributePlacer.PlaceMazeLevelEntry(serialisableMazeLevelEntryAttribute.MazeLevelName); MazeEntries.Add(mazeLevelEntry); } //else if (tileAttributeId == SerialisableTileAttribute.PlayerOnlyAttributeCode) //{ // tileAttributePlacer.PlacePlayerOnlyAttribute(PlayerOnlyType.Bush); //} //else if (tileAttributeId == SerialisableTileAttribute.EnemySpawnpointCode) //{ // tileAttributePlacer.PlaceEnemySpawnpoint(); //} else { Logger.Error($"Unknown tile attribute of the type {type}"); } } }
private void AddTileAttributes(SerialisableTile serialisableTile, InGameOverworldTile tile) { InGameOverworldTileAttributePlacer tileAttributePlacer = new InGameOverworldTileAttributePlacer(tile); foreach (SerialisableTileAttribute serialisableTileAttribute in serialisableTile.TileAttributes) { Type type = Type.GetType(serialisableTileAttribute.AttributeType); if (type.Equals(typeof(SerialisableMazeLevelEntryAttribute))) { SerialisableMazeLevelEntryAttribute serialisableMazeLevelEntryAttribute = (SerialisableMazeLevelEntryAttribute)JsonUtility.FromJson(serialisableTileAttribute.SerialisedData, type); MazeLevelEntry mazeLevelEntry = tileAttributePlacer.PlaceMazeLevelEntry(serialisableMazeLevelEntryAttribute.MazeLevelName); MazeEntries.Add(mazeLevelEntry); } else if (type.Equals(typeof(SerialisablePlayerSpawnpointAttribute))) { tileAttributePlacer.PlacePlayerSpawnpoint(); } else { Logger.Error($"Unknown tile attribute of type {type}"); } } }