Ejemplo n.º 1
0
        public void RenderMap(GamePlayManager gamePlayManager)
        {
            Point currentPlayerPosition = gamePlayManager.Player.CurrentPlayerPosition;

            ExploreTilesAroundPlayer(gamePlayManager, currentPlayerPosition);
            ConsoleHandler.WriteCharAt(gamePlayManager.Player.Symbol, currentPlayerPosition, ConsoleColor.Gray);
            ConsoleHandler.WriteStringAt(gamePlayManager.Player.numberOfMoves.ToString(), new Point(18, 17));
            PrintInventory(gamePlayManager);
        }
Ejemplo n.º 2
0
        private void PrintInventory(GamePlayManager gamePlayManager)
        {
            var point = new Point(20, 0);

            ConsoleHandler.WriteStringAt("Inventory: ", point);
            foreach (var key in gamePlayManager.Player.playerInventory)
            {
                point.row++;
                ConsoleHandler.WriteStringAt(new string(' ', Console.WindowWidth), point);
                ConsoleHandler.WriteStringAt(key.Name, point, key.Color);
            }
            point.row++;
            ConsoleHandler.WriteStringAt(new string(' ', Console.WindowWidth), point);
        }
Ejemplo n.º 3
0
        public void PrintOutMap(GamePlayManager gamePlayManager)
        {
            foreach (var Tile in gamePlayManager.GameObjects)
            {
                if (Tile.IsExplored == true)
                {
                    ConsoleHandler.WriteCharAt(Tile.Symbol, Tile.Position, Tile.Color);
                }
            }

            ConsoleHandler.WriteCharAt(gamePlayManager.Player.Symbol, gamePlayManager.Player.CurrentPlayerPosition, ConsoleColor.Gray);
            ConsoleHandler.WriteStringAt($"Number of steps: {gamePlayManager.Player.numberOfMoves.ToString()}", new Point(18, 0));
            PrintInventory(gamePlayManager);
        }
Ejemplo n.º 4
0
        public void Interact(GamePlayManager gamePlayerManager)
        {
            var tempTile = gamePlayerManager.GetTileAtPoint(new Point(6, 31));

            if (!tempTile.IsExplored)
            {
                gamePlayerManager.GameObjects.Remove(tempTile);
                gamePlayerManager.GameObjects.Add(new FloorTile(tempTile.Position, false));
            }
            else if (tempTile.IsExplored)
            {
                gamePlayerManager.GameObjects.Remove(tempTile);
                gamePlayerManager.GameObjects.Add(new FloorTile(tempTile.Position, true));
                ConsoleHandler.WriteCharAt(tempTile.Symbol, tempTile.Position, tempTile.Color);
            }
        }
Ejemplo n.º 5
0
        private void ExploreTilesAroundPlayer(GamePlayManager gamePlayManager, Point currentPlayerPosition)
        {
            Point      point;
            GameObject tempTile;

            for (int row = currentPlayerPosition.row - 1; row < currentPlayerPosition.row + 2; row++)
            {
                for (int column = currentPlayerPosition.column - 1; column < currentPlayerPosition.column + 2; column++)
                {
                    point    = new Point(row, column);
                    tempTile = gamePlayManager.GetTileAtPoint(point);

                    ConsoleHandler.WriteCharAt(tempTile.Symbol, point, tempTile.Color);
                    tempTile.IsExplored = true;
                }
            }
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            Console.CursorVisible = false;
            var gamePlayManager = new GamePlayManager();
            var gameEngine      = new GameEngine(gamePlayManager);

            while (true)
            {
                switch (currentState)
                {
                case States.StartState:
                    var player     = new Player();
                    var mapCreator = new MapCreator();
                    var renderer   = new Renderer();
                    gamePlayManager.Renderer    = renderer;
                    gamePlayManager.Player      = player;
                    gamePlayManager.GameObjects = mapCreator.CreateMap();
                    renderer.PrintOutMap(gamePlayManager);
                    renderer.PrintInstructions();
                    currentState = States.GamePlayState;
                    break;

                case States.GamePlayState:
                    gameEngine.Update();
                    break;

                case States.EndState:
                    Console.Clear();
                    ConsoleHandler.WriteStringAt("***** Game Over! *****", new Point(3, 22));
                    ConsoleHandler.WriteStringAt($"You finnished the game with {gamePlayManager.Player.numberOfMoves} moves!", new Point(6, 14));
                    var input = Console.ReadKey(true);
                    if (input.Key == ConsoleKey.Escape)
                    {
                        Environment.Exit(0);
                    }
                    break;
                }
            }
        }