public override void HandleInput(InputState input)
 {
     base.HandleInput(input);
     if (input.IsYPressed(ControllingPlayer, out playerIndex))
     {
         LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new GameplayScreen(LevelDataManager.world, LevelDataManager.level));
     }
 }
        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);

            if (input.IsAnyFourPressed(ControllingPlayer, out playerIndex))
            {
                ExitScreen();
            }
        }
 public override void HandleInput(InputState input)
 {
     if (player.State != MediaState.Stopped)
     {
         if (input.IsBPressed(ControllingPlayer, out playerIndex))
         {
             player.Stop();
         }
     }
 }
 public override void HandleInput(InputState input)
 {
     if (input.IsXPressed(ControllingPlayer, out playerIndex))
     {
         SoundManager.StopMusic();
     }
     base.HandleInput(input);
 }
        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);

            if (!isGamePause) return;  //only check input (past this point) if we are on pause screen and not main menu

            if (input.IsAPressed(ControllingPlayer, out playerIndex) || input.IsBPressed(ControllingPlayer, out playerIndex) || input.IsPauseGame(ControllingPlayer, out playerIndex) )
            {
                saveOptions();
                ExitScreen();
            }

            if (input.IsYPressed(ControllingPlayer, out playerIndex))
            {
                saveOptions();
                LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new GameplayScreen(LevelDataManager.world, LevelDataManager.level));
                ExitScreen();
            }

            if (input.IsXPressed(ControllingPlayer, out playerIndex))
            {
                saveOptions();
                LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new BackgroundScreen(), new MainMenuScreen(), new LevelSelectScreen());
                ExitScreen();
            }
            return;
        }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            #region GET STATE OF INPUTS
            if (input == null)
                throw new ArgumentNullException("input");

            // Look up inputs for the active player profile.
            controllingPlayer = ControllingPlayer.Value;
            #if WINDOWS
            keyboardState = input.CurrentKeyboardStates[(int)controllingPlayer];
            #endif
            gamePadState = input.CurrentGamePadStates[(int)controllingPlayer];
            #endregion

            #region PAUSE GAME
            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            bool gamePadDisconnected = !gamePadState.IsConnected &&
                                       input.GamePadWasConnected[(int)controllingPlayer];
            if (input.IsPauseGame(ControllingPlayer, out responsePlayer) || gamePadDisconnected)
            {
                //ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
                ScreenManager.AddScreen(new MainOptionScreen(true), ControllingPlayer);
            }
            #endregion

            #region RESTART LEVEL ON Y
            if (input.IsYPressed(ControllingPlayer, out responsePlayer))
            {
                LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new GameplayScreen(LevelDataManager.world, LevelDataManager.level));
                ExitScreen();
            }
            #endregion

            #region CAMERA ZOOM
            if (gamePadState.IsButtonDown(Buttons.LeftShoulder))
            {
                if (Camera.zoom > 0.6f)
                {
                    Camera.zoom = (Math.Max(Camera.zoom - 0.008f, 0.6f));
                    Camera.ZoomTo(Camera.zoom);
                    Camera.IsScrolling = false;
                    Camera.AutoScroll = false;
                }
            }
            //if (input.IsLShoulderPressed(controllingPlayer, out responsePlayer))
            //{
            //    if (Camera.zoom - 0.1f < 0.6f) Camera.ZoomTo(0.6f);
            //    else Camera.ZoomTo(Camera.zoom - 0.1f);
            //    Camera.IsScrolling = false;
            //    Camera.AutoScroll = false;
            //}

            if (gamePadState.IsButtonDown(Buttons.RightShoulder))
            {
                if (Camera.zoom < 1f)
                {
                    Camera.zoom = (Math.Min(Camera.zoom + 0.008f,1f));
                    Camera.ZoomTo(Camera.zoom);
                    Camera.IsScrolling = false;
                    Camera.AutoScroll = false;
                }
            }
            //if (input.IsRShoulderPressed(controllingPlayer, out responsePlayer))
            //{
            //    if (Camera.zoom + 0.1f > 1f) Camera.ZoomTo(1f);
            //    else Camera.ZoomTo(Camera.zoom + 0.1f);
            //     Camera.IsScrolling = false;
            //    Camera.AutoScroll = false;
            //}
            #endregion

            #region CAMERA MOVEMENT
            cameraMovement = Vector2.Zero;
            #if WINDOWS
            if (keyboardState.IsKeyDown(Keys.Left))
                cameraMovement.X--;

            if (keyboardState.IsKeyDown(Keys.Right))
                cameraMovement.X++;

            if (keyboardState.IsKeyDown(Keys.Up))
                cameraMovement.Y--;

            if (keyboardState.IsKeyDown(Keys.Down))
                cameraMovement.Y++;
            #endif
            cameraMovement += new Vector2(gamePadState.ThumbSticks.Right.X,-gamePadState.ThumbSticks.Right.Y);
            if(cameraMovement != Vector2.Zero)
            {
                Camera.IsScrolling = false;
                Camera.AutoScroll = false;
                Camera.Move(cameraMovement * 20f);
            }
            #endregion
            #region CLICK R STICK TO RESET CAMERA
            if(gamePadState.IsButtonDown(Buttons.RightStick))
            {
                Camera.ZoomTo(1f);
                Camera.ScrollTo(shotManager.shot.Location, 0);
                Camera.IsScrolling = true;
            }
            #endregion

            //if (keyboardState.IsKeyDown(Keys.U)) blurAlpha += 0.01f;  //TESTING
            //if (keyboardState.IsKeyDown(Keys.I)) blurAlpha -= 0.01f;  //TESTING
            //MathHelper.Clamp(blurAlpha, 0f, 1f);  //TESTINIG

            switch (levelState)
            {
                case LevelState.Intro:
                    {
                        if (input.IsAPressed(ControllingPlayer, out responsePlayer))
                        {
                            introManager.AisPressed();
                        }

                        if (input.IsBPressed(ControllingPlayer, out responsePlayer))
                        {
                            introManager.Finish();
                        }

                        break;
                    }
                case LevelState.Countdown:
                case LevelState.Aim:
                    {

                        #region CHANGE AMMO/POWERUP DPAD OR FTGH
                        //if (input.IsDpadLeftPressed(controllingPlayer, out responsePlayer)) shotManager.ChangeSelectedAmmo(-1);
                        if (input.IsXPressed(controllingPlayer, out responsePlayer)) shotManager.ChangeSelectedAmmo(1);
                        //if (input.IsYPressed(controllingPlayer, out responsePlayer)) shotManager.ChangePowerBarrel(1);
                        //if (input.IsYPressed(controllingPlayer, out responsePlayer)) isAimLocked = !isAimLocked;
                        //if (input.IsDpadDownPressed(controllingPlayer, out responsePlayer)) shotManager.ChangePowerBarrel(-1);
                        #endregion

                        #region FIRING POWER
            #if WINDOWS
                        if (keyboardState.IsKeyDown(Keys.D))
                        {
                            firingPower += (GameSettings.MaxFiringPower - GameSettings.MinFiringPower) *0.02f;
                            firingPower = MathHelper.Clamp(firingPower, GameSettings.MinFiringPower, GameSettings.MaxFiringPower);
                        }
                        if (keyboardState.IsKeyDown(Keys.A))
                        {
                            firingPower -= (GameSettings.MaxFiringPower - GameSettings.MinFiringPower) *0.02f;
                            firingPower = MathHelper.Clamp(firingPower, GameSettings.MinFiringPower, GameSettings.MaxFiringPower);
                        }
            #endif
                        if (gamePadState.IsButtonDown(Buttons.RightTrigger))
                        {
                            firingPower += (GameSettings.MaxFiringPower - GameSettings.MinFiringPower) * 0.02f;
                            firingPower = MathHelper.Clamp(firingPower, GameSettings.MinFiringPower, GameSettings.MaxFiringPower);
                        }
                        if (gamePadState.IsButtonDown(Buttons.LeftTrigger))
                        {
                            firingPower -= (GameSettings.MaxFiringPower - GameSettings.MinFiringPower) * 0.02f;
                            firingPower = MathHelper.Clamp(firingPower, GameSettings.MinFiringPower, GameSettings.MaxFiringPower);
                        }
                        if (gamePadState.IsButtonDown(Buttons.DPadUp))
                        {
                            firingPower++;
                            firingPower = MathHelper.Clamp(firingPower, GameSettings.MinFiringPower, GameSettings.MaxFiringPower);
                        }
                        if (gamePadState.IsButtonDown(Buttons.DPadDown))
                        {
                            firingPower--;
                            firingPower = MathHelper.Clamp(firingPower, GameSettings.MinFiringPower, GameSettings.MaxFiringPower);
                        }

                        #endregion

                        #region FIRING ANGLE/DIRECTION
            #if WINDOWS
                        if (keyboardState.IsKeyDown(Keys.S)) firingAngle--;
                        if (keyboardState.IsKeyDown(Keys.W)) firingAngle++;
            #endif
                        if (gamePadState.IsButtonDown(Buttons.DPadLeft)) firingAngle += 0.2f;
                        if (gamePadState.IsButtonDown(Buttons.DPadRight)) firingAngle -= 0.2f;
                        firingDirection = new Vector2((float)Math.Cos(MathHelper.ToRadians(firingAngle)), (float)-Math.Sin(MathHelper.ToRadians(firingAngle)));

                        thumbstickL = Vector2.Zero;
                        thumbstickL = gamePadState.ThumbSticks.Left;
                        if (thumbstickL != Vector2.Zero)
                        {
                            if (thumbstickL.Length() >= lastThumbstick.Length() - 0.1f)
                            {
                                lastThumbstick = thumbstickL;
                                thumbstickL.Normalize();
                                firingDirection = thumbstickL * invertYThumbstick;
                                if (firingDirection.Y <= 0) firingAngle = MathHelper.ToDegrees((float)Math.Acos(firingDirection.X));
                                if (firingDirection.Y > 0) firingAngle = -MathHelper.ToDegrees((float)Math.Acos(firingDirection.X));
                            }
                        }
                        #endregion

                        #region max power for powerup/relay
                        if (shotManager.ActivePowerUpBarrel.TextureIndex == 4 || shotManager.ActivePowerUpBarrel.TextureIndex == 6 ||
                            shotManager.ActivePowerUpBarrel.TextureIndex == 7 || shotManager.ActivePowerUpBarrel.TextureIndex == 8)
                        {
                            //normal
                        }
                        else
                        {
                            firingPower = GameSettings.MaxFiringPower;
                        }
                        #endregion

                        #region CALCULATE POSITIONS FOR POWER BAR AND SHOT AIM PATH
                        firingForce = firingDirection * firingPower;
                        barrelEndLocation = new Vector2(firingLocation.X + (firingDirection.X * 96f), firingLocation.Y + (firingDirection.Y * 96f));
                        powerTargetFill = (firingPower - powerMod)/powerSlope;
                        powerTargetLocation = new Vector2((int)(powerBarLocation.X - 24 + (powerTargetFill * powerBar.Width)), powerBarLocation.Y - 36);
                        #endregion

                        #region ADVANCE GAME STATE (AND INITIALIZE POWER FILL) ON "A"
                        if (input.IsAPressed(ControllingPlayer, out responsePlayer))
                        {
                            if (countdown < 5 || levelState == LevelState.Aim)
                            {
                                lastThumbstick = Vector2.Zero;
                                powerBarFillRate = firingPower / 1500f;
                                powerBarFill = 0f;

                                if (levelState == LevelState.Countdown)
                                {
                                    countdown = -0.5f;
                                    shotManager.shot.spriteBody.Enabled = true;
                                }

                                levelState = LevelState.Power;
                            }
                        }
                        #endregion
                        break;
                    }
                case LevelState.Power:
                    {
                        #region CALCULATE POSITIONS FOR POWER BAR AND SHOT AIM PATH
                        firingForce = firingDirection * firingPower;
                        barrelEndLocation = new Vector2(firingLocation.X + (firingDirection.X * 96f), firingLocation.Y + (firingDirection.Y * 96f));
                        powerTargetFill = (firingPower - powerMod) / powerSlope;
                        powerTargetLocation = new Vector2((int)(powerBarLocation.X - 24 + (powerTargetFill * powerBar.Width)), powerBarLocation.Y - 36);
                        #endregion

                        //these barrels use the power bar
                        if (shotManager.ActivePowerUpBarrel.TextureIndex == 4 || shotManager.ActivePowerUpBarrel.TextureIndex == 6 ||
                            shotManager.ActivePowerUpBarrel.TextureIndex == 7 || shotManager.ActivePowerUpBarrel.TextureIndex == 8)
                        {
                            if (input.IsAPressed(ControllingPlayer, out responsePlayer))
                            {
                                powerSetBarFill = powerBarFill;
                                powerSetLocation = new Vector2((int)(powerBarLocation.X - 24 + (powerSetBarFill * powerBar.Width)), powerBarLocation.Y - 36);

                                //test of angle change on inaccuracy
                                actualPower = firingPower;
                                float misfireDirection = LevelDataManager.rand.Next(0,2);
                                if (misfireDirection == 0) misfireDirection = -1;
                                //if (shotManager.selectedAmmo == 0) misfireDirection *= 0.5f; //apple is twice as accurate
                                if (GameSettings.CheatHardMode) misfireDirection *= 2.0f;  //cheat
                                float actualFiringAngle = firingAngle + (misfireDirection * misfireAngle * (Math.Max(Math.Abs(powerTargetFill - powerSetBarFill)-0.025f,0))); //5% tolerance on firing

                                //apply cheat
                                if (GameSettings.CheatSharpshooter) actualFiringAngle = firingAngle;

                                firingForce = new Vector2((float)Math.Cos(MathHelper.ToRadians(actualFiringAngle)), (float)-Math.Sin(MathHelper.ToRadians(actualFiringAngle))) * actualPower;
                                barrelEndLocation = new Vector2(firingLocation.X + (firingForce.X / actualPower) * 96, firingLocation.Y + (firingForce.Y / actualPower) * 96);
                                shotManager.ActivePowerUpBarrel.TotalRotation = MathHelper.ToRadians(90.0f - actualFiringAngle);

                                shotManager.CreateFruitShot(barrelEndLocation, physicsWorld);
                                if (shotManager.ActivePowerUpBarrel.TextureIndex != 6)
                                {
                                    shotManager.CreatePowerUpShot(shotManager.shot, barrelEndLocation, physicsWorld, ConvertUnits.ToSimUnits(firingForce));
                                }

                                //perfect shot effects
                                if (actualFiringAngle == firingAngle) contactListener.ShotWasPerfect(shotManager.shot, shotManager.ActivePowerUpBarrel);

                                //for fruit, tnt, cannonball generate rotation based on misfire level
                                if (shotManager.ActivePowerUpBarrel.TextureIndex == 6 || shotManager.ActivePowerUpBarrel.TextureIndex == 4 ||
                                    shotManager.ActivePowerUpBarrel.TextureIndex == 7 || shotManager.ActivePowerUpBarrel.TextureIndex == 8 || shotManager.ActivePowerUpBarrel.TextureIndex == 0)
                                {
                                    shotManager.shot.spriteBody.AngularVelocity = (powerTargetFill - powerSetBarFill) * -100f;
                                    shotManager.shot.spriteBody.AngularVelocity = Math.Max(-20, shotManager.shot.spriteBody.AngularVelocity);
                                    shotManager.shot.spriteBody.AngularVelocity = Math.Min(20, shotManager.shot.spriteBody.AngularVelocity);
                                }

                                if (GameSettings.CheatFaster) firingForce *= 2.0f; //cheat
                                shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(firingForce);

                                contactListener.FireShot(barrelEndLocation, shotManager.ActivePowerUpBarrel);
                                shotNumber += 1;
                                if (shotNumber > LevelDataManager.levelData[LevelDataManager.world, LevelDataManager.level].bronze) isFailed = true;
                                Camera.IsScrolling = true;
                                levelState = LevelState.Fire;
                                break;
                            }
                            if (input.IsBPressed(ControllingPlayer, out responsePlayer))
                            {
                                powerBarFill = 0f;
                                levelState = LevelState.Aim;
                                break;
                            }
                        }
                        else
                        {
                                actualPower = GameSettings.MaxFiringPower;

                                firingForce = new Vector2((float)Math.Cos(MathHelper.ToRadians(firingAngle)), (float)-Math.Sin(MathHelper.ToRadians(firingAngle))) * actualPower;
                                barrelEndLocation = new Vector2(firingLocation.X + (firingForce.X / actualPower) * 96, firingLocation.Y + (firingForce.Y / actualPower) * 96);
                                shotManager.ActivePowerUpBarrel.TotalRotation = MathHelper.ToRadians(90.0f - firingAngle);

                                shotManager.CreateFruitShot(barrelEndLocation,physicsWorld);
                                if (shotManager.ActivePowerUpBarrel.TextureIndex != 6) shotManager.CreatePowerUpShot(shotManager.shot, barrelEndLocation, physicsWorld, ConvertUnits.ToSimUnits(firingForce));

                                if (GameSettings.CheatFaster) firingForce *= 2.0f; //cheat
                                shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(firingForce);

                                contactListener.FireShot(barrelEndLocation, shotManager.ActivePowerUpBarrel);
                                shotNumber += 1;
                                if (shotNumber > LevelDataManager.levelData[LevelDataManager.world, LevelDataManager.level].bronze) isFailed = true;
                                Camera.IsScrolling = true;
                                levelState = LevelState.Fire;
                            break;
                        }
                        break;
                    }

                case LevelState.Fire:
                    {
                        // Press A to activate shot ability
                        if (input.IsAPressed(ControllingPlayer, out responsePlayer))
                        {
                            #region shot ability
                            //if not already activated
                            if (shotManager.shot.IsVisible && shotManager.shot.pathingTravelled == 0f && shotManager.shot.TextureID == 20 && shotManager.shot.spriteBody.LinearVelocity.Length() > 1f)
                            {
                                shotManager.shot.pathingTravelled = 0.001f;//ability now used and wont pass check again
                                int spriteRow = shotManager.shot.TextureIndex / LevelDataManager.SpritesInRow(shotManager.shot);
                                switch (spriteRow)
                                {
                                    case 0:
                                    case 1:
                                    case 2:
                                        {
                                            //apple
                                            if (GameSettings.isAppleJump)
                                            {
                                                shotManager.isAppleCopter = true;
                                                shotManager.shot.pathing = Sprite.Pathing.Linear;
                                                shotManager.shot.PathingSpeed = 0;
                                                shotManager.shot.spriteBody.ResetDynamics();
                                                shotManager.shot.spriteBody.ApplyLinearImpulse(new Vector2(0, -6));
                                                contactListener.DoPoof(shotManager.shot);
                                                shotManager.shot.spriteBody.AngularVelocity = 0;
                                                shotManager.shot.spriteBody.SetTransform(shotManager.shot.spriteBody.Position, 0f);
                                            }
                                            break;
                                        }
                                    case 3:
                                        {
                                            //orange
                                            shotManager.shot.pathing = Sprite.Pathing.Linear;
                                            shotManager.shot.spriteBody.LinearVelocity.Normalize();
                                            shotManager.shot.PathingRadiusY = (int)shotManager.shot.spriteBody.LinearVelocity.Y * 100000;
                                            shotManager.shot.PathingRadiusX = (int)shotManager.shot.spriteBody.LinearVelocity.X * 100000;
                                            shotManager.shot.PathingSpeed = 2000;
                                            shotManager.shot.spriteBody.ResetDynamics();
                                            shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(new Vector2(10f, 10f)); //so it isnt motionless in physics and shot ends
                                            shotManager.shot.spriteBody.IgnoreGravity = true;
                                            shotManager.shot.InitializePathing();
                                            break;
                                        }
                                    case 4:
                                        {
                                            //strawberry
                                            shotManager.shot.spriteBody.Rotation = 0;
                                            shotManager.shot.spriteBody.AngularVelocity = 0;
                                            shotManager.shot.pathing = Sprite.Pathing.Linear;
                                            shotManager.shot.PathingRadiusY = 100000;
                                            shotManager.shot.PathingRadiusX = 0;
                                            shotManager.shot.PathingSpeed = 2000;
                                            shotManager.shot.spriteBody.ResetDynamics();
                                            shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(new Vector2(10f, 10f)); //so it isnt motionless in physics and shot ends
                                            shotManager.shot.spriteBody.IgnoreGravity = true;
                                            shotManager.shot.InitializePathing();
                                            break;
                                        }
                                    case 5:
                                        {
                                            //cherry
                                            shotManager.CreateSplitShot(physicsWorld, PlayArea);
                                            break;
                                        }
                                    case 6:
                                        {
                                            contactListener.ActivateBanana(shotManager.shot);
                                            break;
                                        }
                                    case 7:
                                        {
                                            contactListener.ActivateLemon(shotManager.shot);
                                            break;
                                        }
                                    case 8:
                                        {
                                            //watermelon
                                            break;
                                        }
                                    default:
                                        break;
                                }
                            }//end if not already activated
                            #endregion
                        }//end if a pressed

                        if (input.IsBPressed(ControllingPlayer, out responsePlayer))
                        {
                            if (shotManager.shot.IsVisible) shotManager.shot.IsHit = true;
                            //if (shotManager.shot.TextureIndex == 35)
                            if(shotManager.isSplit)
                            {
                                if (shotManager.splitShot[0].spriteBody != null && shotManager.splitShot[0].IsVisible) shotManager.splitShot[0].IsHit = true;
                                if (shotManager.splitShot[1].spriteBody != null && shotManager.splitShot[1].IsVisible) shotManager.splitShot[1].IsHit = true;
                                if (shotManager.splitShot[2].spriteBody != null && shotManager.splitShot[2].IsVisible) shotManager.splitShot[2].IsHit = true;
                            }
                        }

                        #region if apple jump ability active
                        if (shotManager.isAppleCopter)
                        {
                            thumbstickL = Vector2.Zero;
                            thumbstickL = gamePadState.ThumbSticks.Left;
                            if (thumbstickL != Vector2.Zero)
                            {
                                thumbstickL.Normalize();
                                if (thumbstickL.Y > 0) thumbstickL = new Vector2(thumbstickL.X, 0);
                                thumbstickL *= invertYThumbstick;
                                if (shotManager.shot.Scale != 1f) thumbstickL *= 4f;
                            }
                            shotManager.shot.spriteBody.ApplyLinearImpulse(new Vector2(thumbstickL.X * 0.4f, 0f));
                            //terminal velocity
                            shotManager.shot.spriteBody.LinearVelocity = new Vector2(MathHelper.Clamp(shotManager.shot.spriteBody.LinearVelocity.X, -12f, 12f), MathHelper.Clamp(shotManager.shot.spriteBody.LinearVelocity.Y, -12f, 2.5f));
                        }
                        #endregion

                        break;
                    }
                case LevelState.PowerUpAim:
                    {
                        #region FIRING ANGLE/DIRECTION
            #if WINDOWS
                        if (keyboardState.IsKeyDown(Keys.S)) firingAngle--;
                        if (keyboardState.IsKeyDown(Keys.W)) firingAngle++;
            #endif
                        if (gamePadState.IsButtonDown(Buttons.DPadLeft)) firingAngle += 0.2f;
                        if (gamePadState.IsButtonDown(Buttons.DPadRight)) firingAngle -= 0.2f;
                        firingDirection = new Vector2((float)Math.Cos(MathHelper.ToRadians(firingAngle)), (float)-Math.Sin(MathHelper.ToRadians(firingAngle)));

                        thumbstickL = Vector2.Zero;
                        thumbstickL = gamePadState.ThumbSticks.Left;
                        if (thumbstickL != Vector2.Zero)
                        {
                            if (thumbstickL.Length() >= lastThumbstick.Length() - 0.1f)
                            {
                                lastThumbstick = thumbstickL;
                                thumbstickL.Normalize();
                                firingDirection = thumbstickL * invertYThumbstick;
                                if (firingDirection.Y <= 0) firingAngle = MathHelper.ToDegrees((float)Math.Acos(firingDirection.X));
                                if (firingDirection.Y > 0) firingAngle = -MathHelper.ToDegrees((float)Math.Acos(firingDirection.X));
                            }
                        }
                        #endregion

                        firingPower = GameSettings.MaxFiringPower;
                        firingForce = firingDirection * firingPower;
                        barrelEndLocation = new Vector2(shotManager.ActivePowerUpBarrel.SpriteCenterInWorld.X + (firingDirection.X * 96f), shotManager.ActivePowerUpBarrel.SpriteCenterInWorld.Y + (firingDirection.Y * 96f));

                        if (input.IsAPressed(ControllingPlayer, out responsePlayer))
                        {
                            actualPower = firingPower;
                            firingForce = new Vector2((float)Math.Cos(MathHelper.ToRadians(firingAngle)), (float)-Math.Sin(MathHelper.ToRadians(firingAngle))) * actualPower;
                            barrelEndLocation = new Vector2(shotManager.ActivePowerUpBarrel.SpriteCenterInWorld.X + (firingForce.X / actualPower) * 96, shotManager.ActivePowerUpBarrel.SpriteCenterInWorld.Y + (firingForce.Y / actualPower) * 96);
                            shotManager.ActivePowerUpBarrel.TotalRotation = MathHelper.ToRadians(90 - firingAngle);
                            shotManager.CreatePowerUpShot(shotManager.shot, barrelEndLocation, physicsWorld, ConvertUnits.ToSimUnits(firingForce));

                            //for fruit, tnt, cannonball rotation
                            if (shotManager.ActivePowerUpBarrel.TextureIndex == 6 || shotManager.ActivePowerUpBarrel.TextureIndex == 4 ||
                                shotManager.ActivePowerUpBarrel.TextureIndex == 7 || shotManager.ActivePowerUpBarrel.TextureIndex == 8 || shotManager.ActivePowerUpBarrel.TextureIndex == 0)
                            {
                                shotManager.shot.spriteBody.AngularVelocity = LevelDataManager.rand.Next(-100, 100) * 0.1f;
                            }

                            if (GameSettings.CheatFaster) firingForce *= 2.0f; //cheat
                            shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(firingForce);
                            contactListener.FireShot(barrelEndLocation,shotManager.ActivePowerUpBarrel);
                            Camera.IsScrolling = true;
                            lastThumbstick = Vector2.Zero;
                            levelState = LevelState.PowerUpFire;
                        }

                        break;
                    }
                case LevelState.PowerUpFire:
                    {
                        // Press A to activate shot ability
                        if (input.IsAPressed(ControllingPlayer, out responsePlayer))
                        {
                            #region shot ability
                            //if shot visible, not acivated, is a fruit and is minimum speed
                            if (shotManager.shot.IsVisible && shotManager.shot.pathingTravelled == 0f && shotManager.shot.TextureID == 20 && shotManager.shot.spriteBody.LinearVelocity.Length() > 1f)
                            {
                                shotManager.shot.pathingTravelled = 0.001f;//ability now used and wont pass check again
                                int spriteRow = shotManager.shot.TextureIndex / LevelDataManager.SpritesInRow(shotManager.shot);
                                switch (spriteRow)
                                {
                                    case 0:
                                    case 1:
                                    case 2:
                                        {
                                            //apple
                                            if (GameSettings.isAppleJump)
                                            {
                                                shotManager.isAppleCopter = true;
                                                shotManager.shot.pathing = Sprite.Pathing.Linear;
                                                shotManager.shot.PathingSpeed = 0;
                                                shotManager.shot.spriteBody.ResetDynamics();
                                                shotManager.shot.spriteBody.ApplyLinearImpulse(new Vector2(0, -6));
                                                contactListener.DoPoof(shotManager.shot);
                                                shotManager.shot.spriteBody.AngularVelocity = 0;
                                                shotManager.shot.spriteBody.SetTransform(shotManager.shot.spriteBody.Position, 0f);
                                            }
                                            break;
                                        }
                                    case 3:
                                        {
                                            //orange
                                            shotManager.shot.pathing = Sprite.Pathing.Linear;
                                            shotManager.shot.spriteBody.LinearVelocity.Normalize();
                                            shotManager.shot.PathingRadiusY = (int)shotManager.shot.spriteBody.LinearVelocity.Y * 100000;
                                            shotManager.shot.PathingRadiusX = (int)shotManager.shot.spriteBody.LinearVelocity.X * 100000;
                                            shotManager.shot.PathingSpeed = 2000;
                                            shotManager.shot.spriteBody.ResetDynamics();
                                            shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(new Vector2(10f, 10f)); //so it isnt motionless in physics and shot ends
                                            shotManager.shot.spriteBody.IgnoreGravity = true;
                                            shotManager.shot.InitializePathing();
                                            break;
                                        }
                                    case 4:
                                        {
                                            //strawberry
                                            shotManager.shot.spriteBody.Rotation = 0;
                                            shotManager.shot.spriteBody.AngularVelocity = 0;
                                            shotManager.shot.pathing = Sprite.Pathing.Linear;
                                            shotManager.shot.PathingRadiusY = 100000;
                                            shotManager.shot.PathingRadiusX = 0;
                                            shotManager.shot.PathingSpeed = 2000;
                                            shotManager.shot.spriteBody.ResetDynamics();
                                            shotManager.shot.spriteBody.LinearVelocity = ConvertUnits.ToSimUnits(new Vector2(10f, 10f)); //so it isnt motionless in physics and shot ends
                                            shotManager.shot.spriteBody.IgnoreGravity = true;
                                            shotManager.shot.InitializePathing();
                                            break;
                                        }
                                    case 5:
                                        {
                                            //cherry
                                            shotManager.CreateSplitShot(physicsWorld, PlayArea);
                                            break;
                                        }
                                    case 6:
                                        {
                                            contactListener.ActivateBanana(shotManager.shot);
                                            break;
                                        }
                                    case 7:
                                        {
                                            contactListener.ActivateLemon(shotManager.shot);
                                            break;
                                        }
                                    case 8:
                                        {
                                            //watermelon
                                            break;
                                        }
                                    default:
                                        break;
                                }
                            }//end if not already activated
                            #endregion
                        }//end if a pressed

                        if (input.IsBPressed(ControllingPlayer, out responsePlayer))
                        {
                            if (shotManager.shot.IsVisible) shotManager.shot.IsHit = true;
                            //if (shotManager.shot.TextureIndex == 35)
                            if(shotManager.isSplit)
                            {
                                if (shotManager.splitShot[0].spriteBody != null && shotManager.splitShot[0].IsVisible) shotManager.splitShot[0].IsHit = true;
                                if (shotManager.splitShot[1].spriteBody != null && shotManager.splitShot[1].IsVisible) shotManager.splitShot[1].IsHit = true;
                                if (shotManager.splitShot[2].spriteBody != null && shotManager.splitShot[2].IsVisible) shotManager.splitShot[2].IsHit = true;
                            }
                        }

                        #region if apple jump ability active
                        if (shotManager.isAppleCopter)
                        {
                            thumbstickL = Vector2.Zero;
                            thumbstickL = gamePadState.ThumbSticks.Left;
                            if (thumbstickL != Vector2.Zero)
                            {
                                thumbstickL.Normalize();
                                if (thumbstickL.Y > 0) thumbstickL = new Vector2(thumbstickL.X, 0);
                                thumbstickL *= invertYThumbstick;
                                if (shotManager.shot.Scale != 1f) thumbstickL *= 4f;
                            }
                            shotManager.shot.spriteBody.ApplyLinearImpulse(new Vector2(thumbstickL.X * 0.4f, 0f));
                            //terminal velocity
                            shotManager.shot.spriteBody.LinearVelocity = new Vector2(MathHelper.Clamp(shotManager.shot.spriteBody.LinearVelocity.X, -12f, 12f), MathHelper.Clamp(shotManager.shot.spriteBody.LinearVelocity.Y, -12f, 2.5f));
                        }
                        #endregion

                        break;
                    }
                case LevelState.Win:
                    {

                        break;
                    }
                default:
                    break;
            }

            //check end of shot
            if (shotManager.shot.IsExpired)
            {
                if (input.IsAPressed(ControllingPlayer, out responsePlayer)) EndOfShot();
            }
        }
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // We pass in our ControllingPlayer, which may either be null (to
            // accept input from any player) or a specific index. If we pass a null
            // controlling player, the InputState helper returns to us which player
            // actually provided the input. We pass that through to our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex) || input.IsNewMouseLeftClick() )
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }

            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
        }
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }
 public override void HandleInput(InputState input)
 {
     if (player.State != MediaState.Stopped)
     {
         if (input.IsAnyFourPressed(ControllingPlayer, out playerIndex) || input.IsMenuSelect(ControllingPlayer, out playerIndex))
         {
             ControllingPlayer = playerIndex;
             player.Stop();
         }
     }
     else
     {
         if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
         {
             ControllingPlayer = playerIndex;
             // prompt for a device on the first Update we can
             if (!isPrompt) sharedSaveDevice.PromptForDevice();
         }
     }
 }
        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);
            if (input.IsLTriggerPressed(ControllingPlayer, out playerIndex))
            {
                LevelDataManager.nextworld -= 1;
                if (LevelDataManager.nextworld < 0) LevelDataManager.nextworld = 6;
                ScreenManager.AddScreen(new LevelSelectScreen(), ControllingPlayer);
                ExitScreen();
            }
            if (input.IsRTriggerPressed(ControllingPlayer, out playerIndex))
            {
                LevelDataManager.nextworld += 1;
                if (LevelDataManager.nextworld > 6) LevelDataManager.nextworld = 0;
                ScreenManager.AddScreen(new LevelSelectScreen(), ControllingPlayer);
                ExitScreen();
            }

            // Move to the previous menu entry
            if (input.IsMenuUp(ControllingPlayer, out playerIndex))
            {
                if (menuType == MenuType.LevelGrid)
                {
                    selectedEntry -= 5;
                    if (selectedEntry < 0) selectedEntry += numberOfLevels;
                }
            }

            // Move to the next menu entry
            if (input.IsMenuDown(ControllingPlayer, out playerIndex))
            {
                if (menuType == MenuType.LevelGrid)
                {
                    selectedEntry += 5;
                    if (selectedEntry >= numberOfLevels) selectedEntry -= numberOfLevels;
                }
            }
        }
        public override void HandleInput(InputState input)
        {
            if (input.IsXPressed(ControllingPlayer, out playerIndex))
            {
                GameSettings.Cheating = false;
                SetMenuEntryText();
            }

            base.HandleInput(input);
        }