Ejemplo n.º 1
0
        public bool canAdvance()
        {
            KeyboardState kb = Keyboard.GetState();
            MouseState    ms = Mouse.GetState();
            GamePadState  gp = GamePad.GetState(PlayerIndex.One);

            KeyboardState okb = OldKeyboard.GetState();
            MouseState    oms = OldMouse.GetState();
            GamePadState  ogp = OldGamePad.GetState();

            return(
                ((kb.IsKeyDown(Keys.Escape) && !okb.IsKeyDown(Keys.Escape)) ||
                 (kb.IsKeyDown(Keys.Space) && !okb.IsKeyDown(Keys.Space)) ||
                 ((ms.LeftButton != ButtonState.Pressed &&
                   ms.X >= 0 && ms.Y >= 0 && ms.X < ScreenSize.X && ms.Y < ScreenSize.Y &&
                   oms.LeftButton == ButtonState.Pressed))

                 || (gp.Buttons.Start == ButtonState.Pressed && ogp.Buttons.Start != ButtonState.Pressed) ||
                 (gp.Buttons.A == ButtonState.Pressed && ogp.Buttons.A != ButtonState.Pressed) ||
                 (gp.Buttons.B == ButtonState.Pressed && ogp.Buttons.B != ButtonState.Pressed) ||
                 ((kb.IsKeyDown(Keys.Enter) && !kb.IsKeyDown(Keys.LeftAlt) && !kb.IsKeyDown(Keys.RightAlt)) &&
                  !(okb.IsKeyDown(Keys.Enter) && !okb.IsKeyDown(Keys.LeftAlt) && !okb.IsKeyDown(Keys.RightAlt))
                 )
                )
                );
        }
Ejemplo n.º 2
0
 private void up()
 {
     // Update controls.
     KeyboardState keyState    = Keyboard.GetState();
     KeyboardState oldkeyState = OldKeyboard.GetState();
     GamePadState  padState    = GamePad.GetState(PlayerIndex.One);
     GamePadState  oldpadState = OldGamePad.GetState();
 }
Ejemplo n.º 3
0
        public override void Update(float elapsedTime)
        {
            if (enabled)
            {
                KeyboardState keyState    = Keyboard.GetState();
                GamePadState  padState    = GamePad.GetState(PlayerIndex.One);
                GamePadState  oldpadState = OldGamePad.GetState();

                if (keyState.IsKeyDown(Keys.Up) ||
                    keyState.IsKeyDown(Keys.W) ||
                    padState.IsButtonDown(Input.Buttons.DPadUp) ||
                    padState.ThumbSticks.Left.Y > threshold ||
                    padState.ThumbSticks.Right.Y > threshold
                    )
                {
                    up.highlight();
                }
                else
                {
                    up.deHighlight();
                }

                if (keyState.IsKeyDown(Keys.Down) ||
                    keyState.IsKeyDown(Keys.S) ||
                    padState.IsButtonDown(Input.Buttons.DPadDown) ||
                    (padState.ThumbSticks.Left.Y < -threshold) ||
                    (padState.ThumbSticks.Right.Y < -threshold)
                    )
                {
                    down.highlight();
                }
                else
                {
                    down.deHighlight();
                }

                if (keyState.IsKeyDown(Keys.Left) ||
                    keyState.IsKeyDown(Keys.D) ||
                    padState.IsButtonDown(Input.Buttons.DPadLeft) ||
                    padState.ThumbSticks.Left.X < -threshold ||
                    padState.ThumbSticks.Right.X < -threshold
                    )
                {
                    left.highlight();
                }
                else
                {
                    left.deHighlight();
                }

                if (keyState.IsKeyDown(Keys.Right) ||
                    keyState.IsKeyDown(Keys.A) ||
                    padState.IsButtonDown(Input.Buttons.DPadRight) ||
                    padState.ThumbSticks.Left.X > threshold ||
                    padState.ThumbSticks.Right.X > threshold
                    )
                {
                    right.highlight();
                }
                else
                {
                    right.deHighlight();
                }
            }
            else
            {
                up.deHighlight();
                down.deHighlight();
                left.deHighlight();
                right.deHighlight();
            }

            base.Update(elapsedTime);
        }
Ejemplo n.º 4
0
        public override void Update(float elapsedTime)
        {
            if ((Keyboard.GetState().IsKeyDown(Keys.Down) && !OldKeyboard.GetState().IsKeyDown(Keys.Down)) ||
                (Keyboard.GetState().IsKeyDown(Keys.S) && !OldKeyboard.GetState().IsKeyDown(Keys.S)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.DPadDown) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.DPadDown)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.LeftThumbstickDown) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.LeftThumbstickDown)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.RightThumbstickDown) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.RightThumbstickDown))
                )
            {
                unSelectCurrentButton();
                selectButton(currentButton.nextButton);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Up) && !OldKeyboard.GetState().IsKeyDown(Keys.Up) ||
                (Keyboard.GetState().IsKeyDown(Keys.W) && !OldKeyboard.GetState().IsKeyDown(Keys.W)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.DPadUp) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.DPadUp)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.LeftThumbstickUp) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.LeftThumbstickUp)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.RightThumbstickUp) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.RightThumbstickUp))

                )
            {
                unSelectCurrentButton();
                selectButton(currentButton.prevButton);
            }

            if (!(Keyboard.GetState().IsKeyDown(Keys.RightAlt) || Keyboard.GetState().IsKeyDown(Keys.LeftAlt)))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !OldKeyboard.GetState().IsKeyDown(Keys.Enter) ||
                    GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.A) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.A))
                {
                    currentButton.isPressed = true;
                    buttonPressed           = true;
                }
                if (Keyboard.GetState().IsKeyUp(Keys.Enter) && !OldKeyboard.GetState().IsKeyUp(Keys.Enter) ||
                    GamePad.GetState(PlayerIndex.One).IsButtonUp(Input.Buttons.A) && !OldGamePad.GetState().IsButtonUp(Input.Buttons.A))
                {
                    if (currentButton.isPressed)
                    {
                        currentButton.DispatchOnMouseUp(true);
                    }
                }
            }

            base.Update(elapsedTime);
        }
Ejemplo n.º 5
0
        public override void Update(float elapsedTime)
        {
            //Scaling
            float scaleX = ScreenSize.X / menuBackground.Texture.Width;
            float scaleY = ScreenSize.Y / menuBackground.Texture.Height;

            if (scaleX < scaleY)
            {
                ScreenScale  = new Vector2(1.0f, scaleX / scaleY);
                ScreenOffset = new Vector2(0.0f, (ScreenSize.Y - ScreenScale.Y * ScreenSize.Y) / 2);
            }
            else
            {
                ScreenScale  = new Vector2(scaleY / scaleX, 1.0f);
                ScreenOffset = new Vector2((ScreenSize.X - ScreenScale.X * ScreenSize.X) / 2, 1.0f);
            }

            float scale = Math.Min(scaleX, scaleY);

            menuBackground.Scale    = scale;
            playButton.Scale        = scale;
            instructionButton.Scale = scale;
            creditsButton.Scale     = scale;
            quitButton.Scale        = scale;

            if ((Keyboard.GetState().IsKeyDown(Keys.Down) && !OldKeyboard.GetState().IsKeyDown(Keys.Down)) ||
                (Keyboard.GetState().IsKeyDown(Keys.S) && !OldKeyboard.GetState().IsKeyDown(Keys.S)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.DPadDown) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.DPadDown)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.LeftThumbstickDown) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.LeftThumbstickDown)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.RightThumbstickDown) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.RightThumbstickDown))
                )
            {
                unSelectCurrentButton();
                selectButton(currentButton.nextButton);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Up) && !OldKeyboard.GetState().IsKeyDown(Keys.Up) ||
                Keyboard.GetState().IsKeyDown(Keys.W) && !OldKeyboard.GetState().IsKeyDown(Keys.W) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.DPadUp) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.DPadUp)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.LeftThumbstickUp) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.LeftThumbstickUp)) ||
                (GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.RightThumbstickUp) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.RightThumbstickUp))
                )
            {
                unSelectCurrentButton();
                selectButton(currentButton.prevButton);
            }

            if (!(Keyboard.GetState().IsKeyDown(Keys.RightAlt) || Keyboard.GetState().IsKeyDown(Keys.LeftAlt)))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !OldKeyboard.GetState().IsKeyDown(Keys.Enter) ||
                    GamePad.GetState(PlayerIndex.One).IsButtonDown(Input.Buttons.A) && !OldGamePad.GetState().IsButtonDown(Input.Buttons.A))
                {
                    currentButton.isPressed = true;
                }
                if (Keyboard.GetState().IsKeyUp(Keys.Enter) && !OldKeyboard.GetState().IsKeyUp(Keys.Enter) ||
                    GamePad.GetState(PlayerIndex.One).IsButtonUp(Input.Buttons.A) && !OldGamePad.GetState().IsButtonUp(Input.Buttons.A))
                {
                    if (currentButton.isPressed)
                    {
                        currentButton.DispatchOnMouseUp(true);
                    }
                }
            }

            Fader.Update(elapsedTime);

            base.Update(elapsedTime);
        }
Ejemplo n.º 6
0
        private void ProcessControls(out int dirX, out int dirY)
        {
            KeyboardState keyState    = Keyboard.GetState();
            KeyboardState oldKeyState = OldKeyboard.GetState();
            GamePadState  padState    = GamePad.GetState(PlayerIndex.One);
            GamePadState  oldpadState = OldGamePad.GetState();

            dirX = 0;
            dirY = 0;

            if (enableUp && (keyState.IsKeyDown(Keys.Up) ||
                             keyState.IsKeyDown(Keys.W) ||
                             padState.IsButtonDown(Buttons.DPadUp) ||
                             padState.ThumbSticks.Left.Y > threshold ||
                             padState.ThumbSticks.Right.Y > threshold
                             ))
            {
                --dirY;
            }

            if ((enableDown && (keyState.IsKeyDown(Keys.Down) ||
                                keyState.IsKeyDown(Keys.S) ||
                                padState.IsButtonDown(Buttons.DPadDown) ||
                                padState.ThumbSticks.Left.Y < -threshold ||
                                padState.ThumbSticks.Right.Y < -threshold
                                )) || endingDescent)
            {
                ++dirY;
            }

            if (enableLeft && (keyState.IsKeyDown(Keys.Left) ||
                               keyState.IsKeyDown(Keys.A) ||
                               padState.IsButtonDown(Buttons.DPadLeft) ||
                               padState.ThumbSticks.Left.X < -threshold ||
                               padState.ThumbSticks.Right.X < -threshold
                               ))
            {
                Environment.Camera.EffectScale = 1.0f + 2 * zoomAmount;
                --dirX;
            }

            if ((enableRight && (keyState.IsKeyDown(Keys.Right) ||
                                 keyState.IsKeyDown(Keys.D) ||
                                 padState.IsButtonDown(Buttons.DPadRight) ||
                                 padState.ThumbSticks.Left.X > threshold ||
                                 padState.ThumbSticks.Right.X > threshold
                                 )) || endingDescent)
            {
                Environment.Camera.EffectScale = 1.0f;
                ++dirX;
            }
            if (!keyState.IsKeyDown(Keys.Right) && !keyState.IsKeyDown(Keys.Left))
            {
                Environment.Camera.EffectScale = 1.0f + zoomAmount;
            }
            if (dirY == -1 && dirY != lastDirY)
            {
                upSound = Sound.PlayCue("up");
            }
            if (dirY == 1 && dirY != lastDirY)
            {
                downSound = Sound.PlayCue("down");
            }

            // Events on key down.
            if (dirX == -1 && dirX != lastDirX)
            {
                leftSound = Sound.PlayCue("left");
                Environment.OnPressureChange(1.0f);
            }
            if (dirX == 1 && dirX != lastDirX)
            {
                rightSound = Sound.PlayCue("right");
                Environment.OnPressureChange(-1.0f);
            }

            if (downSound != null && dirY != 1)
            {
                downSound.Stop(AudioStopOptions.AsAuthored);
                downSound = null;
            }
            if (upSound != null && dirY != -1)
            {
                upSound.Stop(AudioStopOptions.AsAuthored);
                upSound = null;
            }
            if (leftSound != null && dirX != -1)
            {
                leftSound.Stop(AudioStopOptions.AsAuthored);
                leftSound = null;
                Environment.OnPressureChange(0.0f);
            }
            if (rightSound != null && dirX != 1)
            {
                rightSound.Stop(AudioStopOptions.AsAuthored);
                rightSound = null;
                Environment.OnPressureChange(0.0f);
            }
        }