Пример #1
0
        private void HandlePlayerInput()
        {
            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
            ConsoleKey     key     = keyInfo.Key;

            switch (key)
            {
            case ConsoleKey.UpArrow:
                if (MyWorld.IsPositionWalkable(CurrentPlayer.X, CurrentPlayer.Y - 1))
                {
                    CurrentPlayer.Y -= 1;
                }
                break;

            case ConsoleKey.DownArrow:
                if (MyWorld.IsPositionWalkable(CurrentPlayer.X, CurrentPlayer.Y + 1))
                {
                    CurrentPlayer.Y += 1;
                }
                break;

            case ConsoleKey.LeftArrow:
                if (MyWorld.IsPositionWalkable(CurrentPlayer.X - 1, CurrentPlayer.Y))
                {
                    CurrentPlayer.X -= 1;
                }
                break;

            case ConsoleKey.RightArrow:
                if (MyWorld.IsPositionWalkable(CurrentPlayer.X + 1, CurrentPlayer.Y))
                {
                    CurrentPlayer.X += 1;
                }
                break;

            default:
                break;
            }
        }