private void ControlActions(InputManager input)
 {
     for (int s = 0; s < 6; ++s)
     {
         if (mSkillPalette.Skills[s] != null)
             mSkillPalette.Skills[s].UpdateInputState(input.CheckForBinaryInput(ActiveInputMap, mSkillActions[s], InputIndex), mBipedControl);
     }
 }
Exemple #2
0
        private void ControlBiped(InputManager input, float dTimeMs)
        {
            // If input is in line with avatar orientation, you get all movement, otherwise, some of the movement is dulled to get reorientation

            Vector3 moveInput = Vector3.Zero;

            if (ActiveInputMap.FullIntervalMap.ContainsKey(FullIntervalControlActions.MoveLeftRightRate))
            {
                moveInput.X += input.GetFullIntervalControlValue(ActiveInputMap.FullIntervalMap[FullIntervalControlActions.MoveLeftRightRate],
                                                                 InputIndex);
            }

            if (ActiveInputMap.FullIntervalMap.ContainsKey(FullIntervalControlActions.MoveDownUpRate))
            {
                moveInput.Z -= input.GetFullIntervalControlValue(ActiveInputMap.FullIntervalMap[FullIntervalControlActions.MoveDownUpRate],
                                                                 InputIndex);
            }

            float moveAmount = moveInput.Length();

            if (moveAmount > 0.0f)
            {
                // Transform (rotation only) the input from view space into world space
                Matrix cameraRotation = mReferenceCam.Transform;
                cameraRotation.Translation = Vector3.Zero;
                moveInput = Vector3.Transform(moveInput, cameraRotation);

                if (moveInput.X != 0.0f || moveInput.Z != 0.0f)
                {
                    moveInput.Y = 0.0f;
                    Quaternion directionDiff = SpaceUtils.GetSweptQuaternion(BepuConverter.Convert(mBipedControl.Controller.HorizontalViewDirection), moveInput);

                    mBipedControl.OrientationChange = directionDiff;
                }
            }

            mBipedControl.HorizontalMovement = Vector2.UnitY * moveAmount;

            // Crouching:
            if (input.CheckForBinaryInput(ActiveInputMap, BinaryControlActions.Crouch, InputIndex))
            {
                mBipedControl.DesiredMovementActions |= BipedControllerComponent.MovementActions.Crouching;
            }
            else
            {
                mBipedControl.DesiredMovementActions &= ~BipedControllerComponent.MovementActions.Crouching;
            }

            // Jumping:
            if (input.CheckForNewBinaryInput(ActiveInputMap, BinaryControlActions.Jump, InputIndex))
            {
                mBipedControl.DesiredMovementActions |= BipedControllerComponent.MovementActions.Jumping;
            }
            else
            {
                mBipedControl.DesiredMovementActions &= ~BipedControllerComponent.MovementActions.Jumping;
            }
        }
Exemple #3
0
 private void ControlActions(InputManager input)
 {
     for (int s = 0; s < 6; ++s)
     {
         if (mSkillPalette.Skills[s] != null)
         {
             mSkillPalette.Skills[s].UpdateInputState(input.CheckForBinaryInput(ActiveInputMap, mSkillActions[s], InputIndex), mBipedControl);
         }
     }
 }
        protected override void PrepareInputProcessors(InputManager input)
        {
            PlayerIndex inputIndex = GameResources.PlaySession.LocalPlayers[PlayerId];
            InputMode newMode = mInputMode;

            // TODO: P3: This needs a real state system to manage transitions:

            // Compute next mode:
            if (mInputMode == InputMode.Aiming &&
                !(input.CheckForBinaryInput(mPlayerInputMap, BinaryControlActions.Aim, inputIndex)))
            {
                newMode = InputMode.Aloof;
            }
            else if (mInputMode == InputMode.Aloof &&
                input.CheckForBinaryInput(mPlayerInputMap, BinaryControlActions.Aim, inputIndex))
            {
                newMode = InputMode.Aiming;
            }

            // Take some special actions if there is a mode change:
            if (newMode != mInputMode)
            {
                // Exiting mode tasks:
                switch (mInputMode)
                {
                    case InputMode.Aiming:
                        Actor avatar = GameResources.ActorManager.GetActorById(ActorId);
                        BipedControllerComponent bipedControl = avatar.GetComponent<BipedControllerComponent>(
                            ActorComponent.ComponentType.Control);
                        bipedControl.Controller.ViewDirection = bipedControl.Controller.HorizontalViewDirection;
                        mMmoCameraDesc.Pitch = -MathHelper.Pi / 12.0f;
                        mMmoCameraDesc.Yaw = (float)(Math.Atan2(-bipedControl.Controller.HorizontalViewDirection.X,
                            -bipedControl.Controller.HorizontalViewDirection.Z));

                        DrawSegment.MainWindow.UIElements.Remove(UIElementDepth.CROSSHAIRS);
                        break;
                    default:
                        break;
                }

                // Entering mode tasks:
                switch (newMode)
                {
                    case InputMode.Aiming:
                        DrawSegment.MainWindow.UIElements.Add(UIElementDepth.CROSSHAIRS, mCrosshairs);
                        break;
                    default:
                        break;
                }
            }

            mInputMode = newMode;

            // Handle some misc input functions:

            // Inventory window:
            if (input.CheckForNewBinaryInput(mPlayerInputMap, BinaryControlActions.OpenInventory, inputIndex))
            {
                DrawSegment.AddWindow(mInventoryPanel, inputIndex);
                mInventoryPanel.RefreshItems();
            }

            // TODO: P2: Remove nonessential/debug functionality:

            PlayerIndex dummyPlayerIndex;
            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.V, inputIndex, out dummyPlayerIndex))
            {
                mShadowViewMode = !mShadowViewMode;

                DrawSegment.MainWindow.UIElements.Clear();

                if (mShadowViewMode)
                {
                    DrawSegment.MainWindow.UIElements.Add(UIElementDepth.DEBUG_SHADOW_MAP, new ShadowMapVisual());
                }
                else
                {
                    DrawSegment.MainWindow.UIElements.Add(UIElementDepth.STANDARD_3D_PERSP, new Standard3dPerspective());
                }
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.P, inputIndex, out dummyPlayerIndex))
            {
                Debugger.Break();
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.U, inputIndex, out dummyPlayerIndex))
            {
                mBright += 0.01f;
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.J, inputIndex, out dummyPlayerIndex))
            {
                mBright -= 0.01f;
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.I, inputIndex, out dummyPlayerIndex))
            {
                mContrast += 0.1f;
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.K, inputIndex, out dummyPlayerIndex))
            {
                mContrast -= 0.1f;
            }

            //mBrightParam.SetValue(mBright);
            //mContrastParam.SetValue(mContrast);
        }
Exemple #5
0
        protected override void PrepareInputProcessors(InputManager input)
        {
            PlayerIndex inputIndex = GameResources.PlaySession.LocalPlayers[PlayerId];
            InputMode   newMode    = mInputMode;

            // TODO: P3: This needs a real state system to manage transitions:

            // Compute next mode:
            if (mInputMode == InputMode.Aiming &&
                !(input.CheckForBinaryInput(mPlayerInputMap, BinaryControlActions.Aim, inputIndex)))
            {
                newMode = InputMode.Aloof;
            }
            else if (mInputMode == InputMode.Aloof &&
                     input.CheckForBinaryInput(mPlayerInputMap, BinaryControlActions.Aim, inputIndex))
            {
                newMode = InputMode.Aiming;
            }

            // Take some special actions if there is a mode change:
            if (newMode != mInputMode)
            {
                // Exiting mode tasks:
                switch (mInputMode)
                {
                case InputMode.Aiming:
                    Actor avatar = GameResources.ActorManager.GetActorById(ActorId);
                    BipedControllerComponent bipedControl = avatar.GetComponent <BipedControllerComponent>(
                        ActorComponent.ComponentType.Control);
                    bipedControl.Controller.ViewDirection = bipedControl.Controller.HorizontalViewDirection;
                    mMmoCameraDesc.Pitch = -MathHelper.Pi / 12.0f;
                    mMmoCameraDesc.Yaw   = (float)(Math.Atan2(-bipedControl.Controller.HorizontalViewDirection.X,
                                                              -bipedControl.Controller.HorizontalViewDirection.Z));

                    DrawSegment.MainWindow.UIElements.Remove(UIElementDepth.CROSSHAIRS);
                    break;

                default:
                    break;
                }

                // Entering mode tasks:
                switch (newMode)
                {
                case InputMode.Aiming:
                    DrawSegment.MainWindow.UIElements.Add(UIElementDepth.CROSSHAIRS, mCrosshairs);
                    break;

                default:
                    break;
                }
            }

            mInputMode = newMode;

            // Handle some misc input functions:

            // Inventory window:
            if (input.CheckForNewBinaryInput(mPlayerInputMap, BinaryControlActions.OpenInventory, inputIndex))
            {
                DrawSegment.AddWindow(mInventoryPanel, inputIndex);
                mInventoryPanel.RefreshItems();
            }

            // TODO: P2: Remove nonessential/debug functionality:

            PlayerIndex dummyPlayerIndex;

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.V, inputIndex, out dummyPlayerIndex))
            {
                mShadowViewMode = !mShadowViewMode;

                DrawSegment.MainWindow.UIElements.Clear();

                if (mShadowViewMode)
                {
                    DrawSegment.MainWindow.UIElements.Add(UIElementDepth.DEBUG_SHADOW_MAP, new ShadowMapVisual());
                }
                else
                {
                    DrawSegment.MainWindow.UIElements.Add(UIElementDepth.STANDARD_3D_PERSP, new Standard3dPerspective());
                }
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.P, inputIndex, out dummyPlayerIndex))
            {
                Debugger.Break();
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.U, inputIndex, out dummyPlayerIndex))
            {
                mBright += 0.01f;
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.J, inputIndex, out dummyPlayerIndex))
            {
                mBright -= 0.01f;
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.I, inputIndex, out dummyPlayerIndex))
            {
                mContrast += 0.1f;
            }

            if (input.IsNewKeyPress(Microsoft.Xna.Framework.Input.Keys.K, inputIndex, out dummyPlayerIndex))
            {
                mContrast -= 0.1f;
            }

            //mBrightParam.SetValue(mBright);
            //mContrastParam.SetValue(mContrast);
        }
        private void ControlBiped(InputManager input, float dTimeMs)
        {
            // If input is in line with avatar orientation, you get all movement, otherwise, some of the movement is dulled to get reorientation

            Vector3 moveInput = Vector3.Zero;

            if (ActiveInputMap.FullIntervalMap.ContainsKey(FullIntervalControlActions.MoveLeftRightRate))
            {
                moveInput.X += input.GetFullIntervalControlValue(ActiveInputMap.FullIntervalMap[FullIntervalControlActions.MoveLeftRightRate],
                    InputIndex);
            }

            if (ActiveInputMap.FullIntervalMap.ContainsKey(FullIntervalControlActions.MoveDownUpRate))
            {
                moveInput.Z -= input.GetFullIntervalControlValue(ActiveInputMap.FullIntervalMap[FullIntervalControlActions.MoveDownUpRate],
                    InputIndex);
            }

            float moveAmount = moveInput.Length();

            if (moveAmount > 0.0f)
            {
                // Transform (rotation only) the input from view space into world space
                Matrix cameraRotation = mReferenceCam.Transform;
                cameraRotation.Translation = Vector3.Zero;
                moveInput = Vector3.Transform(moveInput, cameraRotation);

                if (moveInput.X != 0.0f || moveInput.Z != 0.0f)
                {
                    moveInput.Y = 0.0f;
                    Quaternion directionDiff = SpaceUtils.GetSweptQuaternion(BepuConverter.Convert(mBipedControl.Controller.HorizontalViewDirection), moveInput);

                    mBipedControl.OrientationChange = directionDiff;
                }
            }

            mBipedControl.HorizontalMovement = Vector2.UnitY * moveAmount;

            // Crouching:
            if (input.CheckForBinaryInput(ActiveInputMap, BinaryControlActions.Crouch, InputIndex))
            {
                mBipedControl.DesiredMovementActions |= BipedControllerComponent.MovementActions.Crouching;
            }
            else
            {
                mBipedControl.DesiredMovementActions &= ~BipedControllerComponent.MovementActions.Crouching;
            }

            // Jumping:
            if (input.CheckForNewBinaryInput(ActiveInputMap, BinaryControlActions.Jump, InputIndex))
            {
                mBipedControl.DesiredMovementActions |= BipedControllerComponent.MovementActions.Jumping;
            }
            else
            {
                mBipedControl.DesiredMovementActions &= ~BipedControllerComponent.MovementActions.Jumping;
            }
        }