Пример #1
0
    public void MainMenuLoop()
    {
        ConsoleKeyInfo inputKey;

        do
        {
            Clear();
            WriteLine("Rock-Paper-Scissors Menu:\n\t[1] Play a game\n\t[2] Show rules\n\t[3] Display last games' record\n\t[ESC] Exit");
            inputKey = ReadKey(true);

            if (inputKey.Key == ConsoleKey.D1)
            {
                Play();
            }
            else if (inputKey.Key == ConsoleKey.D2)
            {
                DisplayRules(false);
            }
            else if (inputKey.Key == ConsoleKey.D3)
            {
                gamesRecord.DisplayGamesHistory();
            }
            else
            {
                continue;
            }

            WriteLine("(click any key to continue)");
            ReadKey(true);
        } while (inputKey.Key != ConsoleKey.Escape);
    }
Пример #2
0
    public void MainMenuLoop()
    {
        ConsoleKeyInfo inputKey;

        do
        {
            Clear();
            WriteLine("Papier Kamień Nożyce Menu:\n\t[1] Zagraj w grę\n\t[2] Pokaż zasady\n\t[3] Wyświetl poprzednie rozgrywki' zapis\n\t[ESC] Exit");
            inputKey = ReadKey(true);
            if (inputKey.Key == ConsoleKey.D1)
            {
                Play();
            }
            else if (inputKey.Key == ConsoleKey.D2)
            {
                DisplayRules(false);
            }
            else if (inputKey.Key == ConsoleKey.D3)
            {
                gamesRecord.DisplayGamesHistory();
            }
            else
            {
                continue;
            }
            WriteLine("Wciśnij dowolny przycisk");
            ReadKey(true);
        } while(inputKey.Key != ConsoleKey.Escape);
    }
Пример #3
0
    public void MainMenuLoop()
    {
        // Declare the variable used for input
        ConsoleKeyInfo inputKey;

        // Control the effect of input to call a proper function
        do
        {
            // Clear the console
            Clear();
            // Write the menu message
            WriteLine("Game Menu - Current game [{0}]:\n[1] Player vs Player\n[2] Player vs AI\n[3] Show rules\n[4] Display last games' record\n[5] Change game\n[ESC] Exit", gameType[currentGameTypeIndex]);
            inputKey = ReadKey(true);
            if (inputKey.Key == ConsoleKey.D1)
            {
                if (gameType[currentGameTypeIndex] == "RPS")
                {
                    game = new GameRPS();
                }
                else if (gameType[currentGameTypeIndex] == "MyNewGame")
                {
                    game = new GameMyGame();
                }

                else
                {
                    throw new ArgumentException("No such game");
                }
                game.Play();
                gamesRecord += game.gamesRecord;
            }
            else if (inputKey.Key == ConsoleKey.D2)
            {
                game = new GameRPS(true);
                game.Play();
                gamesRecord += game.gamesRecord;
            }
            else if (inputKey.Key == ConsoleKey.D3)
            {
                DisplayRules(game, false); // false to not display the "Welcome.." part
            }
            else if (inputKey.Key == ConsoleKey.D4)
            {
                gamesRecord.DisplayGamesHistory();
            }
            else if (inputKey.Key == ConsoleKey.D5)
            {
                currentGameTypeIndex = (currentGameTypeIndex + 1) % gameType.Length;
                continue;
            }
            else
            {
                continue;
            }
            WriteLine("(click any key to continue)");
            ReadKey(true);
        } while (inputKey.Key != ConsoleKey.Escape);
    }
Пример #4
0
        public void MainMenuLoop()//bool AI)
        {
            ConsoleKeyInfo inputKey;

            do
            {
                Console.Clear();
                Console.WriteLine("Rock-Paper-Scissors Menu:\n\t[1] Play vs human\n\t[2] Play vs robot\n\t[3] Show rules\n\t[4] Display last games' record\n\t[ESC] Exit");
                inputKey = Console.ReadKey(true);

                if (inputKey.Key == ConsoleKey.D1)
                {
                    game = new Game();
                    game.Play();// AI);
                    gamesRecord += game.gamesRecord;
                }
                else if (inputKey.Key == ConsoleKey.D2)
                {
                    game = new Game(true);
                    game.Play();// AI);
                    gamesRecord += game.gamesRecord;
                }
                else if (inputKey.Key == ConsoleKey.D3)
                {
                    game.DisplayRules(false);
                }
                else if (inputKey.Key == ConsoleKey.D4)
                {
                    gamesRecord.DisplayGamesHistory();
                }
                else
                {
                    continue;
                }

                Console.WriteLine("(click any key to continue)");
                Console.ReadKey(true);
            } while (inputKey.Key != ConsoleKey.Escape);
        }