示例#1
0
        private void HandleInput(GameTime gameTime)
        {
            List <PlayerAction> playerActions = _playerController.GetActions();

            foreach (PlayerAction playerAction in playerActions)
            {
                switch (playerAction)
                {
                case PlayerAction.None:
                    // do nothing
                    break;

                case PlayerAction.MoveUp:
                    Body.Velocity = new Vector2(Body.Velocity.X, -MOVE_SPEED);
                    break;

                case PlayerAction.MoveDown:
                    Body.Velocity = new Vector2(Body.Velocity.X, MOVE_SPEED);
                    break;

                case PlayerAction.MoveLeft:
                    Body.Velocity = new Vector2(-MOVE_SPEED, Body.Velocity.Y);
                    break;

                case PlayerAction.MoveRight:
                    Body.Velocity = new Vector2(MOVE_SPEED, Body.Velocity.Y);
                    break;

                case PlayerAction.FireLaser:
                    if (!PlayerLaserOnCooldown(gameTime))
                    {
                        ShootLaser();
                        StartPlayerLaserCooldown();
                    }
                    break;
                }
            }
        }