コード例 #1
0
        public void PrintInstructions()
        {
            var point = new Point(2, 60);

            ConsoleHandler.WriteStringAt(" __________________________", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|    *** FIND EXIT ***     |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|                          |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|Move @ with a,s,d and w,  |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|collect keys(k),          |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|move through doors(D),    |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|watch out for monsters(M),|", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|they give you extra steps,|", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|find exit(E) with as few  |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|steps as possible.        |", point);
            point.row++;
            ConsoleHandler.WriteStringAt("|__________________________|", point);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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;
                }
            }
        }