Example #1
0
        public void GameMenuController()
        {
            var pressedKey = Console.ReadKey(true);

            switch (pressedKey.Key)
            {
            case ConsoleKey.DownArrow:
                if (PositionCounter < 6)
                {
                    OnMenuDownButton?.Invoke(this, new EventArgs());
                    ++PositionCounter;
                }
                break;

            case ConsoleKey.UpArrow:
                if (PositionCounter > 1)
                {
                    OnMenuUpButton?.Invoke(this, new EventArgs());
                    --PositionCounter;
                }
                break;

            case ConsoleKey.Enter:
                OnGameMenuEnterButton?.Invoke(this, new EventArgs());
                break;
            }
        }
Example #2
0
        public void MenuController()
        {
            var pressedKey = Console.ReadKey(true);

            switch (pressedKey.Key)
            {
            case ConsoleKey.DownArrow:
                if (PositionCounter < 2)
                {
                    OnMenuDownButton?.Invoke(this, new EventArgs());
                    ++PositionCounter;
                }
                break;

            case ConsoleKey.UpArrow:
                if (PositionCounter > 1)
                {
                    OnMenuUpButton?.Invoke(this, new EventArgs());
                    --PositionCounter;
                }
                break;

            case ConsoleKey.Enter:
                if (PositionCounter == 1)
                {
                    OnMenuEnterButton?.Invoke(this, new EventArgs());
                }
                else
                {
                    Environment.Exit(0);
                }
                break;

            case ConsoleKey.Escape:
                Environment.Exit(0);
                break;
            }
        }