Exemple #1
0
        public void ShowMenu()
        {
            gameWindow.Render();
            bool needToRender = true;

            do
            {
                while (Console.KeyAvailable)
                {
                    ConsoleKeyInfo pressedChar = Console.ReadKey(true);
                    int            hashCode    = pressedChar.Key.GetHashCode();

                    switch (hashCode)
                    {
                    case 27:     //ConsoleKey.Escape:
                        needToRender = false;
                        Console.Clear();
                        break;

                    case 39:     // ConsoleKey.RightArrow:
                        gameWindow.SwitchActiveButtonsToRight();
                        gameWindow.Render();
                        break;

                    case 37:     // ConsoleKey.LeftArrow:
                        gameWindow.SwitchActiveButtonsToLeft();
                        gameWindow.Render();
                        break;

                    case 13:
                        switch (gameWindow.ActiveButtonIndex())
                        {
                        case 0:
                            gameController.StartGame(this, new Game.GameScreen(50, 30));
                            break;

                        case 1:
                            ShowCredits();
                            needToRender = false;
                            break;

                        case 2:
                            Console.Clear();
                            Environment.Exit(0);
                            break;

                        default:
                            break;
                        }
                        break;
                    }
                }

                System.Threading.Thread.Sleep(250);
            } while (needToRender);
        }
Exemple #2
0
        public void ShowMenu()
        {
            gameWindow.Render();

            bool needToRender = true;
            int  i            = 0;

            do
            {
                ConsoleKeyInfo pressedChar = Console.ReadKey(true);
                int            hashCode    = pressedChar.Key.GetHashCode();

                switch (hashCode)
                {
                case 39:         // ConsoleKey.RightArrow:
                    if (i < 2 && i >= 0)
                    {
                        i++;
                        gameWindow.MenuButtons[i].SetActive();
                        gameWindow.MenuButtons[i - 1].SetInActive();
                    }
                    break;

                case 37:         // ConsoleKey.LeftArrow:
                    if (i < 3 && i > 0)
                    {
                        gameWindow.MenuButtons[i - 1].SetActive();
                        gameWindow.MenuButtons[i].SetInActive();
                        i--;
                    }
                    break;

                case 13:         //ConsoleKey.Enter
                    if (i == 1)
                    {
                        ShowCredits();
                    }
                    else if (i == 0)
                    {
                        StartGame();
                    }
                    else if (i == 2)
                    {
                        Environment.Exit(0);
                    }
                    break;
                }
                gameWindow.Render();
            } while (needToRender);
        }