Ejemplo n.º 1
0
        // process input
        public override void ProcessInput(float elapsedTime, InputManager input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            int i, j = (int)gameManager.GameMode;

            for (i = 0; i < j; i++)
            {
                // Any key/button to go back
                if (input.IsButtonPressedA(i) ||
                    input.IsButtonPressedB(i) ||
                    input.IsButtonPressedX(i) ||
                    input.IsButtonPressedY(i) ||
                    input.IsButtonPressedLeftShoulder(i) ||
                    input.IsButtonPressedRightShoulder(i) ||
                    input.IsButtonPressedLeftStick(i) ||
                    input.IsButtonPressedRightStick(i) ||
                    input.IsButtonPressedBack(i) ||
                    input.IsButtonPressedStart(i) ||
                    input.IsKeyPressed(i, Keys.Enter) ||
                    input.IsKeyPressed(i, Keys.Escape) ||
                    input.IsKeyPressed(i, Keys.Space))
                {
                    screenManager.SetNextScreen(ScreenType.ScreenIntro);
                    gameManager.PlaySound("menu_cancel");
                }
            }
        }
Ejemplo n.º 2
0
        // process input
        public override void ProcessInput(float elapsedTime, InputManager input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            int i, j = (int)gameManager.GameMode;
            for (i = 0; i < j; i++)
            {
                // Any key/button to go back
                if (input.IsButtonPressedA(i) ||
                    input.IsButtonPressedB(i) ||
                    input.IsButtonPressedX(i) ||
                    input.IsButtonPressedY(i) ||
                    input.IsButtonPressedLeftShoulder(i) ||
                    input.IsButtonPressedRightShoulder(i) ||
                    input.IsButtonPressedLeftStick(i) ||
                    input.IsButtonPressedRightStick(i) ||
                    input.IsButtonPressedBack(i) ||
                    input.IsButtonPressedStart(i) ||
                    input.IsKeyPressed(i, Keys.Enter) ||
                    input.IsKeyPressed(i, Keys.Escape) ||
                    input.IsKeyPressed(i, Keys.Space))
                {
                    screenManager.SetNextScreen(ScreenType.ScreenIntro);
                    gameManager.PlaySound("menu_cancel");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Process input for player ship (movement and weapons)
        /// </summary>
        public void ProcessInput(float elapsedTime, InputManager input, int player)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // if dead, don't process input for player
            if (IsAlive == false)
            {
                return;
            }

            // process movement related inputs
            movement.ProcessInput(elapsedTime, input.CurrentState, player);

            // if player invert Y is enabled, invert X rotation force
            if (gameManager.GetInvertY(player))
            {
                movement.rotationForce.X = -movement.rotationForce.X;
            }

            // if blaster ready and input activated
            if (blaster == 1)
            {
                if (input.IsKeyPressed(player, Keys.Space) ||
                    input.CurrentState.padState[player].Triggers.Right > 0)
                {
                    // fire blaster
                    FireProjectile(ProjectileType.Blaster, GameOptions.BlasterVelocity);
                    // reset charge time
                    blaster = 0;
                }
            }

            // if missile is ready and input activated
            if (missile == 1 && missileCount > 0)
            {
                if (input.IsKeyPressed(player, Keys.Enter) ||
                    input.IsTriggerPressedLeft(player))
                {
                    // fire missile
                    FireProjectile(ProjectileType.Missile, GameOptions.MissileVelocity);
                    // subtract missile count
                    AddMissile(-1);
                    // reset charge time
                    missile = 0;
                }
            }

            // if shield is ready and input
            if (shield == 1)
            {
                if (input.IsKeyPressed(player, Keys.R) || input.IsButtonPressedA(player))
                {
                    // activate shield
                    shieldUse = true;
                    // create animated sprite
                    animatedSpriteShield =
                        gameManager.AddAnimSprite(AnimSpriteType.Shield,
                                                  transform.Translation + transform.Forward * 10,
                                                  160, 80, 15, DrawMode.Additive, player);
                    // play shield sound
                    gameManager.PlaySound("shield_activate");
                }
            }

            // if boost ready and input activated
            if (boost == 1)
            {
                if (input.IsKeyPressed(player, Keys.LeftShift) ||
                    input.IsKeyPressed(player, Keys.RightShift) ||
                    input.IsButtonPressedY(player) ||
                    input.IsButtonPressedLeftStick(player))
                {
                    // activate boost
                    boostUse = true;
                    // play boost sound
                    gameManager.PlaySound("ship_boost");
                }
            }

            // if camara switch input activated
            if (input.IsKeyPressed(player, Keys.Back) || input.IsButtonPressedB(player))
            {
                // switch 3rd person mode
                camera3rdPerson = !camera3rdPerson;
                // reset camera
                chaseCamera.Reset();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Process input for player ship (movement and weapons)
        /// </summary>
        public void ProcessInput(float elapsedTime, InputManager input, int player)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // if dead, don't process input for player
            if (IsAlive == false)
            {
                return;
            }

            // process movement related inputs
            movement.ProcessInput(elapsedTime, input.CurrentState, player);

            // if player invert Y is enabled, invert X rotation force
            if (gameManager.GetInvertY(player))
                movement.rotationForce.X = -movement.rotationForce.X;

            // if blaster ready and input activated
            if (blaster == 1)
                if (input.IsKeyPressed(player, Keys.Space) ||
                    input.CurrentState.padState[player].Triggers.Right > 0)
                {
                    // fire blaster
                    FireProjectile(ProjectileType.Blaster, GameOptions.BlasterVelocity);
                    // reset charge time
                    blaster = 0;
                }

            // if missile is ready and input activated
            if (missile == 1 && missileCount > 0)
                if (input.IsKeyPressed(player, Keys.Enter) ||
                    input.IsTriggerPressedLeft(player))
                {
                    // fire missile
                    FireProjectile(ProjectileType.Missile, GameOptions.MissileVelocity);
                    // subtract missile count
                    AddMissile(-1);
                    // reset charge time
                    missile = 0;
                }

            // if shield is ready and input
            if (shield == 1)
                if (input.IsKeyPressed(player,Keys.R) || input.IsButtonPressedA(player))
                {
                    // activate shield
                    shieldUse = true;
                    // create animated sprite
                    animatedSpriteShield =
                        gameManager.AddAnimSprite(AnimSpriteType.Shield,
                        transform.Translation + transform.Forward * 10,
                        160, 80, 15, DrawMode.Additive, player);
                    // play shield sound
                    gameManager.PlaySound("shield_activate");
                }

            // if boost ready and input activated
            if (boost == 1)
                if (input.IsKeyPressed(player, Keys.LeftShift) ||
                    input.IsKeyPressed(player, Keys.RightShift) ||
                    input.IsButtonPressedY(player) ||
                    input.IsButtonPressedLeftStick(player))
                {
                    // activate boost
                    boostUse = true;
                    // play boost sound
                    gameManager.PlaySound("ship_boost");
                }

            // if camara switch input activated
            if (input.IsKeyPressed(player, Keys.Back) || input.IsButtonPressedB(player))
            {
                // switch 3rd person mode
                camera3rdPerson = !camera3rdPerson;
                // reset camera
                chaseCamera.Reset();
            }
        }