protected override void UpdateInternal(SceneRelatedUpdateState updateState)
            {
                foreach (InputFrame actInputFrame in updateState.InputFrames)
                {
                    GamepadState gamepadState = actInputFrame.DefaultGamepad;
                    if (gamepadState == GamepadState.Dummy)
                    {
                        continue;
                    }

                    Vector3 moveVector = Vector3.Zero;

                    // Handle left/right movement
                    Vector3 moveX = new Vector3(0.1f, 0f, 0f);
                    if (gamepadState.IsButtonDown(GamepadButton.DPadLeft))
                    {
                        moveVector += -moveX;
                    }
                    else if (gamepadState.IsButtonDown(GamepadButton.DPadRight))
                    {
                        moveVector += moveX;
                    }
                    else if (Math.Abs(gamepadState.LeftThumbX) > 0.5f)
                    {
                        moveVector += gamepadState.LeftThumbX * moveX;
                    }
                    else if (Math.Abs(gamepadState.RightThumbX) > 0.5f)
                    {
                        moveVector += gamepadState.RightThumbX * moveX;
                    }

                    // Handle up/down movement
                    Vector3 moveZ = new Vector3(0f, 0f, 0.1f);
                    if (gamepadState.IsButtonDown(GamepadButton.DPadDown))
                    {
                        moveVector += -moveZ;
                    }
                    else if (gamepadState.IsButtonDown(GamepadButton.DPadUp))
                    {
                        moveVector += moveZ;
                    }
                    else if (Math.Abs(gamepadState.LeftThumbY) > 0.5f)
                    {
                        moveVector += gamepadState.LeftThumbY * moveZ;
                    }
                    else if (Math.Abs(gamepadState.RightThumbY) > 0.5f)
                    {
                        moveVector += gamepadState.RightThumbY * moveZ;
                    }

                    this.Position = this.Position + moveVector;
                }

                base.UpdateInternal(updateState);
            }
Beispiel #2
0
 /// <summary>
 /// gets the value of this input item
 /// </summary>
 /// <returns>the value of this input item</returns>
 public bool Get()
 {
     return(GamepadState?.IsButtonDown(Button) ?? false);
 }