public void HandleInput(InputState inputState)
        {
            Vector3 newTrans = Vector3.Zero;
            Vector3 newRot = Vector3.Zero;
            bool shift = false;
            bool primaryFire = false;
            bool secondaryFire = false;
            foreach (KeyValuePair<Keys, UserControlKeys> pair in KeyMappings)
            {
                Keys key = pair.Key;
                if (inputState.IsKeyDown(key, playerIndex))
                {
                    UserControlKeys flyKey = pair.Value;
                    switch (flyKey)
                    {
                        case UserControlKeys.MoveFoward:
                            newTrans += Vector3.Forward;
                            break;
                        case UserControlKeys.MoveBackward:
                            newTrans += Vector3.Backward;
                            break;
                        case UserControlKeys.MoveRight:
                            newTrans += Vector3.Right;
                            break;
                        case UserControlKeys.MoveLeft:
                            newTrans += Vector3.Left;
                            break;
                        case UserControlKeys.MoveUp:
                            newTrans += Vector3.Up;
                            break;
                        case UserControlKeys.MoveDown:
                            newTrans += Vector3.Down;
                            break;
                        case UserControlKeys.TurnLeft:
                            newRot += Vector3.Up;
                            break;
                        case UserControlKeys.TurnRight:
                            newRot += Vector3.Down;
                            break;
                        case UserControlKeys.LookUp:
                            newRot += Vector3.Right;
                            break;
                        case UserControlKeys.LookDown:
                            newRot += Vector3.Left;
                            break;
                        case UserControlKeys.RollRight:
                            newRot += Vector3.Forward;
                            break;
                        case UserControlKeys.RollLeft:
                            newRot += Vector3.Backward;
                            break;
                        case UserControlKeys.Shifter:
                            shift = true;
                            break;
                        case UserControlKeys.PrimaryFire:
                            primaryFire = true;
                            break;
                        case UserControlKeys.SecondaryFire:
                            secondaryFire = true;
                            break;
                    }
                }
            }
            force = newTrans;
            if (force.Length() > 0)
            {
                force.Normalize();
                force *= shift ? ForceShiftMag : ForceMag;
            }

            torque = newRot;
            if (torque.Length() > 0)
            {
                torque.Normalize();
                torque *= shift ? TorqueShiftMag : TorqueMag;
            }
            PrimaryFire = primaryFire;
            SecondaryFire = secondaryFire;
        }
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.MenuSelect)
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, EventArgs.Empty);

                ExitScreen();
            }
            else if (input.MenuCancel)
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, EventArgs.Empty);

                ExitScreen();
            }
        }
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.MenuUp)
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

            // Move to the next menu entry?
            if (input.MenuDown)
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            // Accept or cancel the menu?
            if (input.MenuSelect)
            {
                OnSelectEntry(selectedEntry);
            }
            else if (input.MenuCancel)
            {
                OnCancel();
            }
        }
Exemple #4
0
 public override void HandleInput(InputState input)
 {
     base.HandleInput(input);
     CamControls.HandleInput(input);
 }
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }