Exemple #1
0
        private void AskForMovement(Player player, ConsoleKeyInfo testKey)
        {
            switch (testKey.Key)
            {
            case ConsoleKey.RightArrow:
                MoveRight(player);
                break;

            case ConsoleKey.LeftArrow:
                MoveLeft(player);
                break;

            case ConsoleKey.UpArrow:
                MoveUp(player);
                break;

            case ConsoleKey.DownArrow:
                MoveDown(player);
                break;

            case ConsoleKey.U:
                player.EatItem();
                break;

            default:
                break;
            }
        }
Exemple #2
0
        private ConsoleKeyInfo AskForMovement(Player player)
        {
            ConsoleKeyInfo testKey = new ConsoleKeyInfo();

            if (Console.KeyAvailable)
            {
                testKey = Console.ReadKey(true);
                switch (testKey.Key)
                {
                case ConsoleKey.RightArrow:
                    MoveRight(player);
                    break;

                case ConsoleKey.LeftArrow:
                    MoveLeft(player);
                    break;

                case ConsoleKey.UpArrow:
                    MoveUp(player);
                    break;

                case ConsoleKey.DownArrow:
                    MoveDown(player);
                    break;

                case ConsoleKey.U:
                    player.EatItem();
                    break;

                default:
                    break;
                }
                return(testKey);
            }
            return(testKey);
        }