Exemplo n.º 1
0
        public void Update(KeyboardState kbs)
        {
            #region Kbd->ls
            //if (kbs.IsKeyDown(keyboardlsUp))
            //{
            //    leftStick.Y += -0.07f;
            //    if (leftStick.Y <= -1)
            //    {
            //        leftStick.Y = -1;
            //    }
            //}
            //if (kbs.IsKeyDown(keyboardlsDown))
            //{
            //    leftStick.Y += 0.07f;
            //    if (leftStick.Y >= 1)
            //    {
            //        leftStick.Y = 1;
            //    }
            //}
            //if (kbs.IsKeyDown(keyboardlsRight))
            //{
            //    leftStick.X += 0.07f;
            //    if (leftStick.X >= 1)
            //    {
            //        leftStick.X = 1;
            //    }
            //}
            //if (kbs.IsKeyDown(keyboardlsLeft))
            //{
            //    leftStick.X += -0.07f;
            //    if (leftStick.X <= -1)
            //    {
            //        leftStick.X = -1;
            //    }
            //}

            //if (kbs.IsKeyUp(keyboardlsLeft) &&
            //    kbs.IsKeyUp(keyboardlsRight))
            //{
            //    leftStick.X *= 0.8f;
            //}
            //if (kbs.IsKeyUp(keyboardlsDown) &&
            //    kbs.IsKeyUp(keyboardlsUp))
            //{
            //    leftStick.Y *= 0.8f;
            //}
            #endregion

            mouseState = Mouse.GetState();

            //if (!Game1.gammgr.isPaused)
            //{
            //    int tX = mouseState.X;
            //    int tY = mouseState.Y;
            //    if (tX < 0)
            //        tX = 0;
            //    if (tY < -5)
            //        tY = -5;
            //    if (tX > Game1.scrmgr.screenSize.X)
            //        tX = (int)Game1.scrmgr.screenSize.X;
            //    if (tY > Game1.scrmgr.screenSize.Y)
            //        tY = (int)Game1.scrmgr.screenSize.Y;
            //    Mouse.SetPosition(tX, tY);
            //}

            #region mouse->ls

            leftStick.X = (float)mouseState.X / (float)Game1.scrmgr.screenSize.X;
            leftStick.Y = (float)mouseState.Y / (float)Game1.scrmgr.screenSize.Y;
            #endregion

            if (scrollPauser < 15)
            {
                scrollPauser++;
                mouseWheelState = 0;
            }
            else
            {
                if (mouseState.ScrollWheelValue > lastMouseWheelNumber)
                {
                    mouseWheelState = 1;
                    lastMouseWheelNumber = mouseState.ScrollWheelValue;
                    scrollPauser = 0;
                }
                else if (mouseState.ScrollWheelValue < lastMouseWheelNumber)
                {
                    mouseWheelState = -1;
                    lastMouseWheelNumber = mouseState.ScrollWheelValue;
                    scrollPauser = 0;
                }
                else
                {
                    mouseWheelState = 0;
                }
            }

            #region A button
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                if (A == expButtonState.notPressed)
                {
                    A = expButtonState.Pressed;
                }
                else if (A == expButtonState.Pressed)
                {
                    A = expButtonState.Held;
                }
            }
            else
            {
                A = expButtonState.notPressed;
            }
            #endregion
            #region B button
            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                if (B == expButtonState.notPressed)
                {
                   B = expButtonState.Pressed;
                }
                else if (B == expButtonState.Pressed)
                {
                    B = expButtonState.Held;
                }
            }
            else
            {
                B = expButtonState.notPressed;
            }
            #endregion

            #region Start button
            if (kbs.IsKeyDown(keyboardStart))
            {
                if (Start == expButtonState.notPressed)
                {
                    Start = expButtonState.Pressed;
                }
                else if (Start == expButtonState.Pressed)
                {
                    Start = expButtonState.Held;
                }
            }
            else
            {
                Start = expButtonState.notPressed;
            }
            #endregion
            #region Back button
            if (kbs.IsKeyDown(keyboardBack))
            {
                if (Back == expButtonState.notPressed)
                {
                    Back = expButtonState.Pressed;
                }
                else if (Back == expButtonState.Pressed)
                {
                    Back = expButtonState.Held;
                }
            }
            else
            {
                Back = expButtonState.notPressed;
            }
            #endregion
        }
Exemplo n.º 2
0
        public void Update(GamePadState gps)
        {
            leftStick = gps.ThumbSticks.Left;
            rightStick = gps.ThumbSticks.Right;

            leftStick.Y *= -1;
            rightStick.Y *= -1;

            leftTrigger = gps.Triggers.Left;
            rightTrigger = gps.Triggers.Right;

            if (leftRumble > 0.01f)
                leftRumble -= 0.025f;
            else
                leftRumble = 0;

            if (rightRumble > 0.01f)
                rightRumble -= 0.01f;
            else
                rightRumble = 0;

            GamePad.SetVibration(PlayerIndex.One, leftRumble, rightRumble);

            #region A button
            if (gps.Buttons.A == ButtonState.Pressed)
            {
                if (A == expButtonState.notPressed)
                {
                    A = expButtonState.Pressed;
                }
                else if (A == expButtonState.Pressed)
                {
                    A = expButtonState.Held;
                }
            }
            else
            {
                A = expButtonState.notPressed;
            }
            #endregion
            #region B button
            if (gps.Buttons.B == ButtonState.Pressed)
            {
                if (B == expButtonState.notPressed)
                {
                    B = expButtonState.Pressed;
                }
                else if (B == expButtonState.Pressed)
                {
                    B = expButtonState.Held;
                }
            }
            else
            {
                B = expButtonState.notPressed;
            }
            #endregion
            #region X button
            if (gps.Buttons.X == ButtonState.Pressed)
            {
                if (X == expButtonState.notPressed)
                {
                    X = expButtonState.Pressed;
                }
                else if (X == expButtonState.Pressed)
                {
                    X = expButtonState.Held;
                }
            }
            else
            {
                X = expButtonState.notPressed;
            }
            #endregion
            #region Y button
            if (gps.Buttons.Y == ButtonState.Pressed)
            {
                if (Y == expButtonState.notPressed)
                {
                    Y = expButtonState.Pressed;
                }
                else if (Y == expButtonState.Pressed)
                {
                    Y = expButtonState.Held;
                }
            }
            else
            {
                Y = expButtonState.notPressed;
            }
            #endregion

            #region Rb button
            if (gps.Buttons.RightShoulder == ButtonState.Pressed)
            {
                if (Rb == expButtonState.notPressed)
                {
                    Rb = expButtonState.Pressed;
                }
                else if (Rb == expButtonState.Pressed)
                {
                    Rb = expButtonState.Held;
                }
            }
            else
            {
                Rb = expButtonState.notPressed;
            }
            #endregion
            #region Lb button
            if (gps.Buttons.LeftShoulder == ButtonState.Pressed)
            {
                if (Lb == expButtonState.notPressed)
                {
                    Lb = expButtonState.Pressed;
                }
                else if (Lb == expButtonState.Pressed)
                {
                    Lb = expButtonState.Held;
                }
            }
            else
            {
                Lb = expButtonState.notPressed;
            }
            #endregion

            #region Start button
            if (gps.Buttons.Start == ButtonState.Pressed)
            {
                if (Start == expButtonState.notPressed)
                {
                    Start = expButtonState.Pressed;
                }
                else if (Start == expButtonState.Pressed)
                {
                    Start = expButtonState.Held;
                }
            }
            else
            {
                Start = expButtonState.notPressed;
            }
            #endregion
            #region Back button
            if (gps.Buttons.Back == ButtonState.Pressed)
            {
                if (Back == expButtonState.notPressed)
                {
                    Back = expButtonState.Pressed;
                }
                else if (Back == expButtonState.Pressed)
                {
                    Back = expButtonState.Held;
                }
            }
            else
            {
                Back = expButtonState.notPressed;
            }
            #endregion

            #region dU button
            if (gps.DPad.Up == ButtonState.Pressed)
            {
                if (dU == expButtonState.notPressed)
                {
                    dU = expButtonState.Pressed;
                }
                else if (dU == expButtonState.Pressed)
                {
                    dU = expButtonState.Held;
                }
            }
            else
            {
                dU = expButtonState.notPressed;
            }
            #endregion
            #region dD button
            if (gps.DPad.Down == ButtonState.Pressed)
            {
                if (dD == expButtonState.notPressed)
                {
                    dD = expButtonState.Pressed;
                }
                else if (dD == expButtonState.Pressed)
                {
                    dD = expButtonState.Held;
                }
            }
            else
            {
                dD = expButtonState.notPressed;
            }
            #endregion
            #region dL button
            if (gps.DPad.Left == ButtonState.Pressed)
            {
                if (dL == expButtonState.notPressed)
                {
                    dL = expButtonState.Pressed;
                }
                else if (dL == expButtonState.Pressed)
                {
                    dL = expButtonState.Held;
                }
            }
            else
            {
                dL = expButtonState.notPressed;
            }
            #endregion
            #region dR button
            if (gps.DPad.Right == ButtonState.Pressed)
            {
                if (dR == expButtonState.notPressed)
                {
                    dR = expButtonState.Pressed;
                }
                else if (dR == expButtonState.Pressed)
                {
                    dR = expButtonState.Held;
                }
            }
            else
            {
                dR = expButtonState.notPressed;
            }
            #endregion
        }