protected void RenderMap(ref PlayerEntity player) { //Todo: need a better way to do this later Point currentPosition = new Point(0, 0); Point playerPosition = new Point(player.Position.X, player.Position.Y); int[] currentMapDim = MasterWorldManager.GetCurrentMap().GetMapDimensions(); int currentMapRows = currentMapDim[0]; int currentMapCols = currentMapDim[1]; if (currentMapRows < 0 || currentMapRows < 0) { Console.WriteLine("The rows or cols was not set when map was loaded. Exiting!"); return; } for (int y = 0; y < currentMapRows; y++) { for (int x = 0; x < currentMapCols; x++) { currentPosition.X = x; currentPosition.Y = y; if (currentPosition == playerPosition) { Console.Write(" X "); continue; } BaseTile tile = MasterWorldManager.TileAt(currentPosition); if (tile != null) { if (tile.Type == TileType.Grass) { Console.Write(" G "); } else if (tile.Type == TileType.Lava) { Console.Write(" L "); } else if (tile.Type == TileType.Water) { Console.Write(" W "); } else if (tile.Type == TileType.Void) { Console.Write(" % "); } else if (tile.Type == TileType.Transition) { Console.Write(" Tr "); } else { Console.Write(" ERROR "); } } } Console.WriteLine(""); } Console.WriteLine(""); }
public void ProcessGame() { InputCommand command = MasterInputManager.PopCommand(); PlayerEntity player = MasterEntityManager.GetPlayer() as PlayerEntity; if (player == null) { Console.WriteLine("Player is NULL"); Environment.Exit(0); } if (command == InputCommand.Unknown) { //If there are no commands to process don't do anything return; } if (command == InputCommand.RestartGameSameMap) { if (MasterWorldManager.GetCurrentMap() == null) { MasterWorldManager.Initialize(); } else { ResetGame(ref player); } MasterGameState = GameState.Running; } if (command == InputCommand.RestartGameDifferentMap) { MasterWorldManager.Initialize(); player.Reset(); MasterGameState = GameState.Running; } if (command == InputCommand.ExitGame) { MasterGameState = GameState.Ended; Console.Clear(); Console.WriteLine("Thank you for playing!"); Thread.Sleep(2000); Environment.Exit(0); } if (!player.isAlive()) { MasterGameState = GameState.Ended; return; } if (MasterGameState == GameState.Running) { Point currentPosition = player.Position; MoveEntities(player, command); UpdateTiles(currentPosition, player.Position); UpdateDamage(player); if (ReadyForPlayerTransition(currentPosition)) { TransitionMap(player); } } }