private void SetMazeLevelEntryName() { GridLocation selectedLocation = EditorTileSelector.Instance.CurrentlySelectedTile.GridLocation; MazeLevelEntry MazeLevelEntry = null; for (int i = 0; i < OverworldGameplayManager.Instance.EditorOverworld.MazeEntries.Count; i++) { MazeLevelEntry m = OverworldGameplayManager.Instance.EditorOverworld.MazeEntries[i]; if (m.Tile.GridLocation.X == selectedLocation.X && m.Tile.GridLocation.Y == selectedLocation.Y) { MazeLevelEntry = m; break; } } if (MazeLevelEntry == null) { Logger.Warning($"Could not find a maze entry tile at location {selectedLocation.X},{selectedLocation.Y}"); return; } MazeLevelEntry.MazeLevelName = GetCurrentDropdownSelection(); ScreenSpaceOverworldEditorElements.Instance.UpdateMazeLevelEntryName(MazeLevelEntry); Logger.Log($"This tile now connects to the maze '{MazeLevelEntry.MazeLevelName}'"); }
public virtual MazeLevelEntry PlaceMazeLevelEntry(string mazeLevelName = "") { MazeLevelEntry mazeLevelEntry = (MazeLevelEntry)InstantiateTileAttributeGO <MazeLevelEntry>(); mazeLevelEntry.Tile = Tile; mazeLevelEntry.MazeLevelName = mazeLevelName; Tile.SetWalkable(true); Tile.AddAttribute(mazeLevelEntry); return(mazeLevelEntry); }
public void UpdateMazeLevelEntryName(MazeLevelEntry mazeLevelEntry) { for (int i = 0; i < _mazeEntryNames.Count; i++) { EditorMazeLevelEntryName editorMazeLevelEntryName = _mazeEntryNames[i]; if (mazeLevelEntry.Tile.GridLocation.X == editorMazeLevelEntryName.MazeLevelEntry.Tile.GridLocation.X && mazeLevelEntry.Tile.GridLocation.Y == editorMazeLevelEntryName.MazeLevelEntry.Tile.GridLocation.Y) { editorMazeLevelEntryName.SetText(mazeLevelEntry.MazeLevelName); break; } } }
public void RemoveMazeLevelEntryName(MazeLevelEntry mazeLevelEntry) { for (int i = 0; i < _mazeEntryNames.Count; i++) { EditorMazeLevelEntryName editorMazeLevelEntryName = _mazeEntryNames[i]; if (mazeLevelEntry.Tile.GridLocation.X == editorMazeLevelEntryName.MazeLevelEntry.Tile.GridLocation.X && mazeLevelEntry.Tile.GridLocation.Y == editorMazeLevelEntryName.MazeLevelEntry.Tile.GridLocation.Y) { _mazeEntryNames.Remove(editorMazeLevelEntryName); editorMazeLevelEntryName.Destroy(); break; } } }
public void InstantiateMazeLevelEntryName(MazeLevelEntry mazeLevelEntry) { GameObject mazeLevelEntryGO = Instantiate(_editorMazeLevelEntryNamePrefab, _mazeEntryNameContainer.transform); mazeLevelEntryGO.transform.position = new Vector2(mazeLevelEntry.Tile.transform.position.x + 1.2f, mazeLevelEntry.Tile.transform.position.y + 0.5f); EditorMazeLevelEntryName editorMazeLevelEntryName = mazeLevelEntryGO.GetComponent <EditorMazeLevelEntryName>(); if (editorMazeLevelEntryName == null) { Logger.Error("Could not find EditorMazeLevelEntryName script on game object"); } _mazeEntryNames.Add(editorMazeLevelEntryName); editorMazeLevelEntryName.SetMazeLevelEntry(mazeLevelEntry); }
public void RemoveMazeLevelEntry(MazeLevelEntry mazeLevelEntry = null) { if (mazeLevelEntry == null) { mazeLevelEntry = (MazeLevelEntry)_tile.GetAttributes().FirstOrDefault(attribute => attribute is MazeLevelEntry); } if (mazeLevelEntry == null) { return; } _tile.RemoveAttribute(mazeLevelEntry); mazeLevelEntry.Remove(); if (OverworldGameplayManager.Instance != null && OverworldGameplayManager.Instance.EditorOverworld != null) { OverworldGameplayManager.Instance.EditorOverworld.MazeEntries.Remove(mazeLevelEntry); ScreenSpaceOverworldEditorElements.Instance.RemoveMazeLevelEntryName(mazeLevelEntry); } }
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}"); } } }
public void Destroy() { MazeLevelEntry = null; Destroy(gameObject); }
public void SetMazeLevelEntry(MazeLevelEntry mazeLevelEntry) { Logger.Log($"Set name to {mazeLevelEntry.MazeLevelName}"); MazeLevelEntry = mazeLevelEntry; SetText(mazeLevelEntry.MazeLevelName); }
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); } }