/// <summary> /// Initializes a new InputAction. /// </summary> /// <param name="buttons">An array of buttons that can trigger the action.</param> /// <param name="keys">An array of keys that can trigger the action.</param> /// <param name="newPressOnly">Whether the action only occurs on the first press of one of the buttons/keys, /// false if it occurs each frame one of the buttons/keys is down.</param> /// <param name="gestures">An array of gestures that can trigger the action</param> public InputAction(Buttons[] buttons, Keys[] keys, InputGesture[] gestures, bool newPressOnly) { // Store the buttons and keys. If the arrays are null, we create a 0 length array so we don't // have to do null checks in the Evaluate method this.buttons = buttons != null ? buttons.Clone() as Buttons[] : new Buttons[0]; this.keys = keys != null ? keys.Clone() as Keys[] : new Keys[0]; this.gestures = gestures != null ? gestures.Clone() as InputGesture[] : new InputGesture[0]; this.newPressOnly = newPressOnly; }
private void EnqueueGesture(Vector2 position, int skel, bool clicked) { InputGesture gesture; if (clicked) { gesture = new InputGesture(InputGestureType.Click, Direction.NONE, position, skel); } else { gesture = new InputGesture(InputGestureType.Move, Direction.NONE, position, skel); } this.pendingGestures.Enqueue(gesture); }
/// <summary> /// Returns true if a particular gesture was seen /// </summary> /// <param name="gesture">The gesture to test</param> /// <param name="controllingPlayer">If not null, only gestures by this player will be detected</param> /// <param name="playerIndex">The player that initiated the gesture</param> /// <returns>True if the gesture was seen</returns> public bool WasGestureSeen(InputGesture gesture, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex) { double speed = 1.0; return WasGestureSeen(gesture, controllingPlayer, out playerIndex, out speed); //playerIndex = PlayerIndex.One; //// TODO: Support multiple players //foreach (InputGesture seen in this.OtherGestures) //{ // if (seen.Type == gesture.Type) // { // return gesture.Direction == Direction.NONE || gesture.Direction == seen.Direction; // } //} //return false; }
/// <summary> /// Returns true if a particular gesture was seen /// </summary> /// <param name="gesture">The gesture to test</param> /// <param name="controllingPlayer">If not null, only gestures by this player will be detected</param> /// <param name="playerIndex">The player that initiated the gesture</param> /// <param name="speed">The relative speed ratio of the gesture</param> /// <returns>True if the gesture was seen</returns> public bool WasGestureSeen(InputGesture gesture, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex, out double speed) { playerIndex = PlayerIndex.One; speed = 1.0; // TODO: Support multiple players foreach (InputGesture seen in this.OtherGestures) { if (seen.Type == gesture.Type) { speed = seen.ExecutionSpeed; return gesture.Direction == Direction.NONE || gesture.Direction == seen.Direction; } } return false; }