コード例 #1
0
        private static void ReadPlayersInputKey(bool areTwoPlayersSelected)
        {
            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo movementDirectionKey = Console.ReadKey(true);

                Console.CursorVisible = false;

                if (GameKeyAuthenticator.IsArrowKey(movementDirectionKey))
                {
                    var newDirection = DirectionManager.GetNextDirection(movementDirectionKey);

                    var elementToDelete = new Point(0, 0);

                    if (areTwoPlayersSelected)
                    {
                        if (movementDirectionKey.Key == ConsoleKey.W || movementDirectionKey.Key == ConsoleKey.S)
                        {
                            elementToDelete = UpdateLeftRocket(true, newDirection);
                        }
                        else
                        {
                            elementToDelete = UpdateLeftRocket(false, newDirection);
                        }
                    }
                    else if (!areTwoPlayersSelected)
                    {
                        elementToDelete = UpdateLeftRocket(true, newDirection);
                    }
                }
            }
        }