Ejemplo n.º 1
0
 public HumanView(PlayerInfo playerInfo, CharacterInfo selectedCharacter, ContentManager contentLoader)
     : base(playerInfo, selectedCharacter)
 {
     mContentLoader  = contentLoader;
     mPlayerInputMap = null;
     DrawSegment     = null;
 }
Ejemplo n.º 2
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);
        }