Ejemplo n.º 1
0
        /// <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)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if (startingTransition > 0f) return;

            // Look up inputs for the active player profile.
            int playerIndex = 0;

            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            PlayerIndex player;
            if (input.IsPauseGame(ControllingPlayer))
            {
                PauseBackgroundScreen pauseBG = new PauseBackgroundScreen();
                ScreenManager.AddScreen(pauseBG, ControllingPlayer);
                ScreenManager.AddScreen(new PauseMenuScreen(pauseBG), ControllingPlayer);
            }

            if(IsActive)
            {
                //Matrix mouseMatrix = Matrix.CreateTranslation(input.LastMouseState.X, input.LastMouseState.Y, 0) * -gameCamera.CameraMatrix;// Matrix.CreateTranslation(input.LastMouseState.X, input.LastMouseState.Y, 0);
                //mouseMatrix += Matrix.CreateTranslation(gameCamera.Position.X, gameCamera.Position.Y, 0);
                //mouseMatrix = mouseMatrix + Matrix.CreateRotationZ(-gameCamera.Rotation);
                //mouseMatrix -= Matrix.CreateTranslation(gameCamera.Width / 2, gameCamera.Height - 200, 0);

                //mousePos = Vector2.Transform(mousePos, gameCamera.CameraMatrix);

                //Quaternion camRot;
                //Vector3 dummy;
                //gameCamera.CameraMatrix.Decompose(out dummy, out camRot, out dummy);

                //mousePos += gameCamera.Position;
                //mousePos -= new Vector2(ScreenManager.GraphicsDevice.Viewport.Width / 2, ScreenManager.GraphicsDevice.Viewport.Height - 200);

                if (input.MouseDragging)
                {

                }

            #if WINRT || WINDOWS_PHONE
               // TouchCollection tc = TouchPanel.GetState();

                foreach(TouchLocation tl in TouchPanel.GetState())
                {
                    if (tl.State == TouchLocationState.Pressed || tl.State == TouchLocationState.Moved)
                    {
                        mousePos = Vector2.Transform(tl.Position, Matrix.Invert(gameCamera.CameraMatrix));
                        gameHero.Fire(mousePos);
                    }
                    else gameHero.NotFiring();
                }
            #else

                    mousePos = new Vector2(input.LastMouseState.X, input.LastMouseState.Y);
                    mousePos = Vector2.Transform(mousePos, Matrix.Invert(gameCamera.CameraMatrix));

            #endif

                if (input.CurrentMouseState.LeftButton == ButtonState.Pressed)
                    gameHero.Fire(mousePos);
                else
                    gameHero.NotFiring();

                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.A)) gameHero.MoveBackward();
                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.D)) gameHero.MoveForward();

                if (input.IsNewKeyPress(Keys.Space, null, out player)) gameHero.DoGravFlip();

                if (Math.Abs(input.AccelerometerVect.Y) > 0.15f)
                {
                    if (input.AccelerometerVect.Y>0) gameHero.MoveBackward();
                    if (input.AccelerometerVect.Y<0) gameHero.MoveForward();
                }

                if (input.CurrentMouseState.Y < 150)
                {
                    if(gameHUD.Alpha>0.2f) gameHUD.Alpha -= 0.02f;
                }
                else
                {
                    if(gameHUD.Alpha<1f) gameHUD.Alpha += 0.02f;
                }

            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor fills in the menu contents.
 /// </summary>
 public PauseMenuScreen(PauseBackgroundScreen pauseBG)
     : base("Pause", 0)
 {
     BGScreen = pauseBG;
     IsPopup = true;
 }