コード例 #1
0
        /// <summary>
        /// This function will take the user input and proceed to the relevent function.
        /// </summary>
        public void MenuSelection()
        {
            while (true)            // Will wait for keypress signal via the keyboard.
            {
                var keyPress = Console.ReadKey(false).Key;
                switch (keyPress)
                {
                case ConsoleKey.A:                                  // "a" will display the new game menu.
                    NewGameSelection();
                    break;

                case ConsoleKey.B:                                  // "b" will call LoadGameSelection() within the Game class.
                    Game loadGame = new Game();
                    LoadGameSelection();
                    break;

                case ConsoleKey.C:                                  // "c" will call startPVPGame.NewPVPGame() within the Game class.
                    Game startPVPGame = new Game();
                    startPVPGame.NewPVPGame();
                    break;

                case ConsoleKey.D:                                  // "d" will call startPVCGame.NewPVCGame() within the Game class.
                    Game startPVCGame = new Game();
                    startPVCGame.NewPVCGame();
                    break;

                case ConsoleKey.E:                                  // "e" will call startCVCGame.NewCVCGame() within the Game class.
                    Game startCVCGame = new Game();
                    startCVCGame.NewCVCGame();
                    break;

                case ConsoleKey.F:                                  // "f" will clear the console re-draw the main title.
                    Console.Clear();
                    DrawTitle();
                    break;

                case ConsoleKey.G:                                  // "g" will call loadPVPGame.LoadPVPGame() within the Game class.
                    Console.Clear();
                    Game loadPVPGame = new Game();
                    loadPVPGame.LoadPVPGame();
                    break;

                case ConsoleKey.H:                                  // "h" will call loadPVCGame.LoadPVCGame() within the Game class.
                    Console.Clear();
                    Game loadPVCGame = new Game();
                    loadPVCGame.LoadPVCGame();
                    break;

                case ConsoleKey.Q:                                  // "q" Will shut down the application.
                    Environment.Exit(0);
                    break;
                }
            }
        }