void Awake() { Cursor.visible = false; Cursor.lockState = CursorLockMode.Confined; inputActions = new InputActions(); inputActions.Gameplay.Enable(); playerTransform = playerController.transform; cameraTransform = playerCamera.transform; playerCamera.depthTextureMode = DepthTextureMode.Depth; state.pulses = new List <Pulse>(); state.trapsDisabled = new List <GameObject>(); pulses = state.pulses; InitializePulseSpec(abilityPulseSpec); InitializePulseSpec(footstepPulseSpec); // Music { if (musicList.Length > 0) { musicAudioSource.clip = musicList[0]; } musicAudioSource.playOnAwake = true; musicAudioSource.loop = repeatSong; musicAudioSource.Play(); } state.chestsOpened = new HashSet <Chest>(); state.items = new List <ItemSpec>(); //SetMetaState(MetaState.Start); }
/// <inheritdoc /> public LocalizedStringTableWindow(Editor editor, AssetItem item) : base(editor, item) { // Undo _undo = new Undo(); _undo.UndoDone += OnUndoRedo; _undo.RedoDone += OnUndoRedo; _undo.ActionDone += OnUndoRedo; // Toolstrip _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save64, Save).LinkTooltip("Save"); _toolstrip.AddSeparator(); _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo (Ctrl+Z)"); _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo (Ctrl+Y)"); _toolstrip.AddSeparator(); _toolstrip.AddButton(Editor.Icons.Up64, OnExport).LinkTooltip("Export localization table entries for translation to .pot file"); // Panel var panel = new Panel(ScrollBars.Vertical) { AnchorPreset = AnchorPresets.StretchAll, Offsets = new Margin(0, 0, _toolstrip.Bottom, 0), Parent = this }; // Properties _presenter = new CustomEditorPresenter(_undo, "Loading..."); _presenter.Panel.Parent = panel; _presenter.Modified += MarkAsEdited; // Setup input actions InputActions.Add(options => options.Undo, _undo.PerformUndo); InputActions.Add(options => options.Redo, _undo.PerformRedo); }
void Awake() { this.inputActions = new InputActions(); this.inputActions.Enable(); this.inputActions.PlayerActionMap.Movement.performed += OnMovement; this.inputActions.PlayerActionMap.Drop.performed += OnDrop; }
void Awake() { rb = GetComponent <Rigidbody2D>(); pos = Vector2.zero; inputActions = new InputActions(); inputActions.Player.MovePlayer.performed += ctx => { inputMovePlayer = ctx.ReadValue <Vector2>(); }; inputActions.Player.MovePlayer.canceled += ctx => inputMovePlayer = Vector2.zero; inputActions.Player.MoveCursor.performed += ctx => inputMoveCursor = ctx.ReadValue <Vector2>(); inputActions.Player.MoveCursor.canceled += ctx => inputMoveCursor = Vector2.zero; inputActions.Player.ClickCursor.performed += ctx => { if (Physics2D.Raycast(Vector2.zero, inputMoveCursor)) { print("You Win"); } }; InputUser.onChange += (user, change, device) => { if (change == InputUserChange.ControlSchemeChanged) { switch (user.controlScheme.Value.name) { case "Gamepad": //buttonImage.sprite = gamepadImage; break; default: //buttonImage.sprite = keyboardImage; break; } } }; }
private void Awake() { _inputActions = new InputActions(); _inputActions.Player1.Move.performed += context => Player1Axis = context.ReadValue <float>(); _inputActions.Player2.Move.performed += context => Player2Axis = context.ReadValue <float>(); }
private void Awake() { inputActions = new InputActions(); playerRigidBody = GetComponent <Rigidbody2D>(); playerCollider = GetComponent <Collider2D>(); playerAnimator = GetComponent <Animator>(); }
void Start() { InputActions inputActions = GameController.Instance.inputActions; inputActions.Game.Move.performed += ctx => inputMovement = ctx.ReadValue <Vector2>(); inputActions.Game.Move.canceled += ctx => inputMovement = ctx.ReadValue <Vector2>(); inputActions.Game.Sprint.performed += ctx => this.isSprinting = true; inputActions.Game.Sprint.canceled += ctx => this.isSprinting = false; inputActions.Game.Look.performed += ctx => inputView = ctx.ReadValue <Vector2>(); inputActions.Game.Look.canceled += ctx => inputView = ctx.ReadValue <Vector2>(); inputActions.Game.Jump.performed += ctx => { this.isJumping = ctx.ReadValueAsButton(); if (ctx.ReadValueAsButton()) { OnJump(); } }; inputActions.Game.Crouch.performed += ctx => { this.isCrouching = ctx.ReadValueAsButton(); if (ctx.ReadValueAsButton()) { OnCrouch(); } }; //inputActions.Game.DoubleJump.performed += ctx => OnDoubleJump(); //inputActions.Game.LeftClick.performed += ctx => FireProjectile(); }
public PursuitBuilder(GameObject gameObject, InputActions input, GameObject target, float timeout) { this.gameObject = gameObject; this.input = input; this.target = target; this.timeout = timeout; }
private void TryOnInputDesktop(Action inputAction) { InputActions.Enqueue(() => { if (!Win32Interop.SwitchToInputDesktop()) { if (IsInputBlocked) { BlockInput(false); } Task.Run(() => { Win32Interop.SwitchToInputDesktop(); inputAction(); }).Wait(); if (IsInputBlocked) { BlockInput(true); } } else { inputAction(); } }); }
protected virtual void UpdateAnimation(InputActions actionsToAnimate) { if (animator != null) { if (actionsToAnimate.primaryDirection.x != 0) { float sign = Mathf.Sign(actionsToAnimate.primaryDirection.x); float abs = Mathf.Abs(actionsToAnimate.primaryDirection.x); int x = Mathf.RoundToInt(Mathf.Ceil(abs) * sign); animator.SetFloat("x", x); } if (actionsToAnimate.primaryDirection.y != 0) { float sign = Mathf.Sign(actionsToAnimate.primaryDirection.y); float abs = Mathf.Abs(actionsToAnimate.primaryDirection.y); int y = Mathf.RoundToInt(Mathf.Ceil(abs) * sign); animator.SetFloat("y", y); } animator.SetBool("p_action", actionsToAnimate.primaryAction); animator.SetBool("s_action", actionsToAnimate.secondaryAction); if (lastHealth != currentStats.health) { animator.SetTrigger("damaged"); lastHealth = currentStats.health; } } }
void AddAction(InputActions another) { if ((VirtualAction & another) != another) { VirtualAction = (InputActions)((int)VirtualAction + (int)another); } }
/// <inheritdoc /> public GameplayGlobalsWindow(Editor editor, AssetItem item) : base(editor, item) { _undo = new Undo(); _undo.ActionDone += OnUndo; _undo.UndoDone += OnUndo; _undo.RedoDone += OnUndo; var panel = new Panel(ScrollBars.Vertical) { AnchorPreset = AnchorPresets.StretchAll, Offsets = new Margin(0, 0, _toolstrip.Bottom, 0), Parent = this, }; _propertiesEditor = new CustomEditorPresenter(_undo); _propertiesEditor.Panel.Parent = panel; _propertiesEditor.Modified += OnPropertiesEditorModified; _proxy = new PropertiesProxy(); _propertiesEditor.Select(_proxy); _saveButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Save32, Save).LinkTooltip("Save asset"); _toolstrip.AddSeparator(); _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo32, _undo.PerformUndo).LinkTooltip("Undo (Ctrl+Z)"); _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo32, _undo.PerformRedo).LinkTooltip("Redo (Ctrl+Y)"); _toolstrip.AddSeparator(); _resetButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Rotate32, Reset).LinkTooltip("Resets the variables values to the default values"); InputActions.Add(options => options.Save, Save); InputActions.Add(options => options.Undo, _undo.PerformUndo); InputActions.Add(options => options.Redo, _undo.PerformRedo); }
void Awake() { CurrentScreenNumber = ScreensNavigator.ScreenNumberCounter; InputActions = new InputActions(); InputActions.Main.Escape.performed += _ => OnEscape(); InputActions.Main.AnyAction.performed += _ => AnyKeyPressed(); }
private void SendInput(InputActions inputActions) { if (OnInput != null) { OnInput(inputActions); } }
public PursuitBuilder(GameObject gameObject, InputActions input, string targetVariable, float timeout) { this.gameObject = gameObject; this.input = input; this.targetVariable = targetVariable; this.timeout = timeout; }
/// Get the player's limo control data. protected override void OnCreate() { inputActions = new InputActions(); var playerQuery = GetEntityQuery(typeof(PlayerTag)); input = playerQuery.GetSingleton <LimoControlInput>(); }
protected override void Execute(InputActions actions) { if (GetActionInvoke(moveToLocationAction, actions)) { if (manager.followingMinions.Count > 0) { Minion skel = manager.followingMinions[0]; skel.RecieveTarget(cursor.transform); manager.followingMinions.Remove(skel); } cursor.animator.SetTrigger("leftClick"); } if (GetActionInvoke(returnHomeAction, actions)) { for (int i = 0; i < manager.activeMinions.Count; i++) { manager.activeMinions[i].RecieveTarget(transform); } manager.followingMinions = new List <Minion>(); for (int i = 0; i < manager.activeMinions.Count; i++) { manager.followingMinions.Add(manager.activeMinions[i]); } cursor.animator.SetTrigger("rightClick"); } }
private void Awake() { _input = new InputActions(); _input.PlayerControls.MenuAccept.started += ctx => AcceptItem(); _input.PlayerControls.MenuNavigationUp.started += ctx => ItemUp(); _input.PlayerControls.MenuNavigationDown.started += ctx => ItemDown(); }
private void OnInputKeyEvent(InputActions action, InputActionStates state, float axis) { switch (action) { case InputActions.RunAxisAction: SetRun(axis); break; case InputActions.JumpButton: if (state == InputActionStates.KeyDown) { StartJump(); } break; case InputActions.CastSpellButton: if (state == InputActionStates.KeyDown) { StartCastSpell(); } else { EndCastSpell(); } break; } }
public ProcessorInput() { _inputActions = new InputActions(); _inputActions.Gameplay.SetCallbacks(this); _inputActions.UI.SetCallbacks(this); _inputActions.Enable(); }
void RemoveAction(InputActions another) { if ((VirtualAction & another) == another) { VirtualAction = (InputActions)((int)VirtualAction - (int)another); } }
public bool ChangeActionToKey(InputActions action, KeyCode newKey, bool changeOnError = true) { if (!CurrentActionToKey.ContainsKey(action)) { CurrentActionToKey.Add(action, newKey); OnActionToKeysChanged?.Invoke(); return(true); } foreach (KeyValuePair <InputActions, KeyCode> actionKey in CurrentActionToKey) { if (actionKey.Value == newKey) { if (changeOnError) { CurrentActionToKey[action] = newKey; CurrentActionToKey[actionKey.Key] = KeyCode.None; OnActionToKeysChanged?.Invoke(); } return(false); } } OnActionToKeysChanged?.Invoke(); return(true); }
private void Awake() { controls = new InputActions(); GM = GetComponent <GameManager>(); if (airCraft != null) { startHealth = airCraft.GetHealth(); } if (Time.timeScale != 1) { Time.timeScale = 1; } enemyDistance = Camera.main.scaledPixelHeight * enemyPositionScreenHeightRatio; if (levelText != null) { levelText.text = SceneManager.GetActiveScene().name; } bindInputActions(); displayQuitWhenAppropriate(); UpdateMissiles(); UpdateHealth(); initializeEnemyScore(); UpdateEnemyScore(); }
private void Awake() { inputActions = new InputActions(); inputActions.Player.ShopEnable.performed += ShopEnablePerformed; inputActions.Player.ShopFollower.performed += ShopFollowerPerformed; inputActions.Player.ShopHealth.performed += ShopHealthPerformed; }
protected override void UpdateAnimation(InputActions actionsToAnimate) { if (actionsToAnimate.target != null) { Vector3 dir = actionsToAnimate.target.position - transform.position; dir = dir.normalized; Debug.DrawRay(transform.position, dir, Color.red); if (dir.x != 0) { float sign = Mathf.Sign(dir.x); float abs = Mathf.Abs(dir.x); int x = Mathf.RoundToInt(Mathf.Ceil(abs) * sign); animator.SetFloat("x", x); } if (dir.z != 0) { float sign = Mathf.Sign(dir.z); float abs = Mathf.Abs(dir.z); int y = Mathf.RoundToInt(Mathf.Ceil(abs) * sign); animator.SetFloat("y", y); } } animator.SetBool("s_action", actionsToAnimate.secondaryAction); if (lastHealth != currentStats.health) { animator.SetTrigger("damaged"); lastHealth = currentStats.health; transform.DOShakePosition(.25f, .5f, 100, 90); } }
private void Awake() { rectTransform = GetComponent <RectTransform>(); toolToButton = new Dictionary <Tool, ToolButton>(); toolToIndex = new Dictionary <Tool, int>(); toolButtons = new List <ToolButton>(); foreach (Transform child in transform) { var toolButton = child.GetComponent <ToolButton>(); if (toolButton && toolButton.gameObject.activeSelf) { toolToButton[toolButton.Tool] = toolButton; toolToIndex[toolButton.Tool] = toolButtons.Count; toolButtons.Add(toolButton); } } inputs = new InputActions(); inputs.Gameplay.Select.performed += OnSelect; inputs.Gameplay.Select.canceled += OnRelease; tutorialManager = TutorialManager.Instance; tutorialManager.TutorialReady += OnTutorialReady; }
/// <summary> /// Removes the action. /// </summary> /// <param name="e">E.</param> public void RemoveAction(InputActions a, EventHandler e) { if (InputEvents.ContainsKey(a)) { InputEvents[a] -= e; } }
/// <inheritdoc /> protected VisjectFunctionSurfaceWindow(Editor editor, AssetItem item) : base(editor, item) { // Undo _undo = new Undo(); _undo.UndoDone += OnUndoRedo; _undo.RedoDone += OnUndoRedo; _undo.ActionDone += OnUndoRedo; // Toolstrip _saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); _toolstrip.AddSeparator(); _undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip("Undo (Ctrl+Z)"); _redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip("Redo (Ctrl+Y)"); _toolstrip.AddSeparator(); _toolstrip.AddButton(Editor.Icons.Search64, Editor.ContentFinding.ShowSearch).LinkTooltip("Open content search tool (Ctrl+F)"); _toolstrip.AddButton(editor.Icons.CenterView64, ShowWholeGraph).LinkTooltip("Show whole graph"); // Panel _panel = new Panel(ScrollBars.None) { AnchorPreset = AnchorPresets.StretchAll, Offsets = new Margin(0, 0, _toolstrip.Bottom, 0), Parent = this }; // Setup input actions InputActions.Add(options => options.Undo, _undo.PerformUndo); InputActions.Add(options => options.Redo, _undo.PerformRedo); InputActions.Add(options => options.Search, Editor.ContentFinding.ShowSearch); }
public CameraInput() { _actions = new InputActions(); _actions.Camera.Vertical.performed += MouseVerticalAction; _actions.Camera.Horizontal.performed += MouseHorizontalAction; }
/// <summary> /// Initializes a new instance of the <see cref="SceneEditorWindow"/> class. /// </summary> /// <param name="editor">The editor.</param> /// <param name="hideOnClose">True if hide window on closing, otherwise it will be destroyed.</param> /// <param name="scrollBars">The scroll bars.</param> protected SceneEditorWindow(Editor editor, bool hideOnClose, ScrollBars scrollBars) : base(editor, hideOnClose, scrollBars) { // Setup input actions InputActions.Add(options => options.Save, Editor.SaveAll); InputActions.Add(options => options.Undo, () => { Editor.PerformUndo(); Focus(); }); InputActions.Add(options => options.Redo, () => { Editor.PerformRedo(); Focus(); }); InputActions.Add(options => options.Cut, Editor.SceneEditing.Cut); InputActions.Add(options => options.Copy, Editor.SceneEditing.Copy); InputActions.Add(options => options.Paste, Editor.SceneEditing.Paste); InputActions.Add(options => options.Duplicate, Editor.SceneEditing.Duplicate); InputActions.Add(options => options.SelectAll, Editor.SceneEditing.SelectAllScenes); InputActions.Add(options => options.Delete, Editor.SceneEditing.Delete); InputActions.Add(options => options.Search, () => Editor.Windows.SceneWin.Search()); InputActions.Add(options => options.Play, Editor.Simulation.RequestStartPlay); InputActions.Add(options => options.Pause, Editor.Simulation.RequestResumeOrPause); InputActions.Add(options => options.StepFrame, Editor.Simulation.RequestPlayOneFrame); }
void DoAction(InputActions action, ref bool crouchPress) { if ((action & InputActions.Jump) == InputActions.Jump)//跳跃 { if (Landed && !Jumping && !Crouching) { //播放上跳动画 animator.Play("Jump"); Jumping = true; StartCoroutine(Jump()); } } if ((action & InputActions.Crouch) == InputActions.Crouch)//蹲下 { crouchPress = true; if (Landed) { if (!Crouching) { //播放下蹲动画 animator.Play("Crouch"); } Crouching = true; } } if ((action & InputActions.Hit) == InputActions.Hit) //攻击1 { if (!Landing) //空中攻击 { StartCoroutine(Jumphit()); } else if (Crouching)//下蹲攻击 { } else//普通攻击 { if (!Hitting) { Hitting = true; StartCoroutine(Hit()); } } } if ((action & InputActions.MoveLeft) == InputActions.MoveLeft)//左移 { StartCoroutine(Move(true)); } if ((action & InputActions.MoveRight) == InputActions.MoveRight)//右移 { StartCoroutine(Move(false)); } if (!crouchPress) { Crouching = false; } }
/// <summary> /// Initializes a new instance of the <see cref="MouseButtonTrigger"/> class. /// </summary> /// <param name="Button">The button.</param> /// <param name="Action">The action.</param> /// <param name="ShouldHandle">if set to <c>true</c> the trigger should handle the event.</param> public MouseButtonTrigger(MouseButtons Button, InputActions Action, bool ShouldHandle) : base(EventTypes.MouseButton, ShouldHandle) { button = Button; action = Action; Mouse.Hook.MouseDown += new MouseEventHandler(OnMouseDown); Mouse.Hook.MouseUp += new MouseEventHandler(OnMouseUp); }
public ChargedMeleeAttackBuilder(GameObject gameObject, InputActions input, string chargeVariable, float initialChargeMultiplier, float maxChargeMultiplier, float maxChargeSeconds) : base(gameObject, input) { this.chargeVariable = chargeVariable; this.initialChargeMultiplier = initialChargeMultiplier; this.maxChargeMultiplier = maxChargeMultiplier; this.maxChargeSeconds = maxChargeSeconds; }
private void Awake() { // We need to first set this to be a new object before we can do anything controls = new InputActions(); controls.Player.MouseSelection.performed += ctx => GrabMouseSelect(ctx); controls.Player.MouseSelection.canceled += ctx => GrabMouseSelect(ctx); }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardTrigger"/> class. /// </summary> /// <param name="KeyData">The key data.</param> /// <param name="Action">The action.</param> /// <param name="ShouldHandle">if set to <c>true</c> the trigger should handle the event.</param> public KeyboardTrigger(Keys KeyData, InputActions Action, bool ShouldHandle) : base(EventTypes.Keyboard, ShouldHandle) { action = Action; key = KeyData; //InputLib.KeyboardInput.Hook.KeyPress += new KeyPressEventHandler(OnKeyPress); Keyboard.Hook.KeyDown += new KeyEventHandler(OnKeyDown); Keyboard.Hook.KeyUp += new KeyEventHandler(OnKeyUp); }
public TeleportBuilder(GameObject gameObject, InputActions input, string targetVariable, float timeout, LayerMask obstacles, float distance) { this.gameObject = gameObject; this.input = input; this.targetVariable = targetVariable; this.timeout = timeout; this.obstacles = obstacles; this.distance = distance; }
/// <summary> /// Sends a keyboard event to the OS. /// </summary> /// <param name="Key">The key.</param> /// <param name="Action">The action.</param> public static void SendKey(Keys Key, InputActions Action) { switch (Action) { case InputActions.Press: KeyboardSimulator.KeyPress(Key); break; case InputActions.Down: KeyboardSimulator.KeyDown(Key); break; case InputActions.Up: KeyboardSimulator.KeyUp(Key); break; default: break; } }
/// <summary> /// Sends a mouse event to the OS. /// </summary> /// <param name="Button">The button.</param> /// <param name="Action">The action.</param> public static void SendButton(MouseButtons Button, InputActions Action) { switch (Action) { case InputActions.Press: MouseSimulator.Click(Button); break; case InputActions.Down: MouseSimulator.MouseDown(Button); break; case InputActions.Up: MouseSimulator.MouseUp(Button); break; default: break; } }
/// <summary> /// Registers the event for a given action. /// </summary> /// <param name="action">Action.</param> /// <param name="callback">Callback.</param> public void RegisterEvent(InputActions action, EventHandler callback) { if (!InputEvents.ContainsKey(action)) { InputEvents.Add(action,null); } InputEvents[action] += callback; }
/// <summary> /// Remove all events for a given action. /// </summary> /// <param name="action">Action.</param> public void RemoveAction(InputActions action) { InputEvents.Remove(action); }
/// <summary> /// Initializes a new instance of the <see cref="TriggerAttribute"/> class. /// </summary> /// <param name="Key">The key.</param> /// <param name="Action">The action.</param> public TriggerAttribute(Keys Key, InputActions Action) { eventdata = new KeyboardTrigger(Key, Action); }
/// <summary> /// Determines if an action was fired on during since last drop call. /// </summary> /// <returns><c>true</c>, if the event happend, <c>false</c> otherwise.</returns> /// <param name="action">Action.</param> public bool IsActionFired(InputActions action) { return ActionsFired.Contains(action); }
/// <summary> /// Gets the key for a given action. /// </summary> /// <returns>The key.</returns> /// <param name="action">Action.</param> public Keys GetKey(InputActions action) { if (!Info.ContainsKey(action)) { throw new Exception("The action is not present in the XML"); } return Info[action].KeyboardKey; }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardTrigger"/> class. /// </summary> /// <param name="KeyData">The key data.</param> /// <param name="Action">The action.</param> public KeyboardTrigger(Keys KeyData, InputActions Action) : this(KeyData, Action, true) { }
private void ChangeBinding(InputActions inputAction, Keys key) { }
private void ChangeBinding(InputActions inputAction, Buttons button) { }
// This is the main purpose of this class. It allows us to check // for an action rather than a specific device button. // /// <summary> /// This is the main purpose of this class. It allows us to check for an action rather /// than a specific device button. /// </summary> /// <param name="action">Which action to check, as defined in InputManager.InputActions.</param> /// <param name="buffer">True if input should only be registers once per press (prevent spamming).</param> /// <returns>True if that action happened this frame.</returns> public bool CheckAction(InputActions action, bool buffer) { #if WINDOWS // First let's check the keyboard. KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(mKeyboardActionMap[(int)action])) { // The button has been pressed this frame, but that might not be the end our checks // if the user has requested the input to be buffered. if(buffer) { // Was this key down last frame? if (mPreviousKeyboardState.IsKeyDown(mKeyboardActionMap[(int)action])) { // If it was then it needs to be ignored this frame. return false; } } // If we make it to here, the button press is valid. return true; } #endif // !WINDOWS // Now let's do the gamepad if (mIsControllerLocked == false) { // Need to detect which controller has pressed start for (int i = 0; i < MAX_CONTROLLER_COUNT; i++) { if (action == InputActions.START && GamePad.GetState((PlayerIndex)i).Buttons.Start == ButtonState.Pressed) { mIsControllerLocked = true; mActiveControllerIndex = (PlayerIndex)i; mPreviousGamePadState = mCurrentGamePadState = GamePad.GetState(mActiveControllerIndex); return true; } } return false; } // Dump brute force checks. Not as simple as keyboard because we // need to handle buttons, dpad, and thumbstick. // switch (action) { case InputActions.A: { return CheckButtonState(mCurrentGamePadState.Buttons.A, mPreviousGamePadState.Buttons.A, ButtonState.Pressed, buffer); } case InputActions.B: { return CheckButtonState(mCurrentGamePadState.Buttons.B, mPreviousGamePadState.Buttons.B, ButtonState.Pressed, buffer); } case InputActions.X: { return CheckButtonState(mCurrentGamePadState.Buttons.X, mPreviousGamePadState.Buttons.X, ButtonState.Pressed, buffer); } case InputActions.Y: { return CheckButtonState(mCurrentGamePadState.Buttons.Y, mPreviousGamePadState.Buttons.Y, ButtonState.Pressed, buffer); } case InputActions.START: { return CheckButtonState(mCurrentGamePadState.Buttons.Start, mPreviousGamePadState.Buttons.Start, ButtonState.Pressed, buffer); } case InputActions.BACK: { return CheckButtonState(mCurrentGamePadState.Buttons.Back, mPreviousGamePadState.Buttons.Back, ButtonState.Pressed, buffer); } case InputActions.R1: { return CheckButtonState(mCurrentGamePadState.Buttons.RightShoulder, mPreviousGamePadState.Buttons.RightShoulder, ButtonState.Pressed, buffer); } case InputActions.L1: { return CheckButtonState(mCurrentGamePadState.Buttons.LeftShoulder, mPreviousGamePadState.Buttons.LeftShoulder, ButtonState.Pressed, buffer); } case InputActions.R2: { if (mCurrentGamePadState.Triggers.Right >= 0.1f) { if (!buffer || mPreviousGamePadState.Triggers.Right < 0.1f) { return true; } } return false; } case InputActions.L2: { if (mCurrentGamePadState.Triggers.Left >= 0.1f) { if (!buffer || mPreviousGamePadState.Triggers.Left < 0.1f) { return true; } } return false; } case InputActions.L3: { return CheckButtonState(mCurrentGamePadState.Buttons.LeftStick, mPreviousGamePadState.Buttons.LeftStick, ButtonState.Pressed, buffer); } case InputActions.DP_LEFT: { return CheckButtonState(mCurrentGamePadState.DPad.Left, mPreviousGamePadState.DPad.Left, ButtonState.Pressed, buffer); } case InputActions.DP_RIGHT: { return CheckButtonState(mCurrentGamePadState.DPad.Right, mPreviousGamePadState.DPad.Right, ButtonState.Pressed, buffer); } case InputActions.DP_UP: { return CheckButtonState(mCurrentGamePadState.DPad.Up, mPreviousGamePadState.DPad.Up, ButtonState.Pressed, buffer); } case InputActions.DP_DOWN: { return CheckButtonState(mCurrentGamePadState.DPad.Down, mPreviousGamePadState.DPad.Down, ButtonState.Pressed, buffer); } case InputActions.LA_LEFT: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Left.X, mPreviousGamePadState.ThumbSticks.Left.X, -0.1f, buffer) || CheckButtonState(mCurrentGamePadState.DPad.Left, mPreviousGamePadState.DPad.Left, ButtonState.Pressed, buffer); } case InputActions.LA_RIGHT: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Left.X, mPreviousGamePadState.ThumbSticks.Left.X, 0.1f, buffer) || CheckButtonState(mCurrentGamePadState.DPad.Right, mPreviousGamePadState.DPad.Right, ButtonState.Pressed, buffer); } case InputActions.LA_UP: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Left.Y, mPreviousGamePadState.ThumbSticks.Left.Y, 0.1f, buffer) || CheckButtonState(mCurrentGamePadState.DPad.Up, mPreviousGamePadState.DPad.Up, ButtonState.Pressed, buffer); } case InputActions.LA_DOWN: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Left.Y, mPreviousGamePadState.ThumbSticks.Left.Y, -0.1f, buffer) || CheckButtonState(mCurrentGamePadState.DPad.Down, mPreviousGamePadState.DPad.Down, ButtonState.Pressed, buffer); } case InputActions.RA_LEFT: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Right.X, mPreviousGamePadState.ThumbSticks.Right.X, -0.1f, buffer); } case InputActions.RA_RIGHT: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Right.X, mPreviousGamePadState.ThumbSticks.Right.X, 0.1f, buffer); } case InputActions.RA_UP: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Right.Y, mPreviousGamePadState.ThumbSticks.Right.Y, 0.1f, buffer); } case InputActions.RA_DOWN: { return CheckAnalogState(mCurrentGamePadState.ThumbSticks.Right.Y, mPreviousGamePadState.ThumbSticks.Right.Y, -0.1f, buffer); } }; return false; }
/// <summary> /// Initializes a new instance of the <see cref="MouseButtonTrigger"/> class. /// </summary> /// <param name="Button">The button.</param> /// <param name="Action">The action.</param> public MouseButtonTrigger(MouseButtons Button, InputActions Action) : this(Button, Action, true) { }
public static CharVar FromInputMode(InputActions input) { switch (input) { case InputActions.Horizontal: return HORIZONTAL_MODE; case InputActions.Vertical: return VERTICAL_MODE; case InputActions.Jump: return JUMP_MODE; case InputActions.Fire1: return FIRE1_MODE; case InputActions.Fire2: return FIRE2_MODE; default: return null; } }
public static CharVar FromInputValue(InputActions input) { switch (input) { case InputActions.Horizontal: return HORIZONTAL_VALUE; case InputActions.Vertical: return VERTICAL_VALUE; default: return null; } }
/// <summary> /// Gets the info for a given action. /// </summary> /// <returns>The info.</returns> /// <param name="action">Action.</param> public KeyboardInputInfo GetInfo(InputActions action) { if (!Info.ContainsKey(action)) { throw new Exception("The action is not present in the XML"); } return new KeyboardInputInfo() { Action = action, Key = Info[action].KeyboardKey, State = Info[action].State, DeadKey = Info[action].DeadKey }; }
public BasicMeleeAttackBuilder(GameObject gameObject, InputActions input) : base(gameObject, input) { }
public IMeleeAttackBuilder(GameObject gameObject, InputActions input) { this.gameObject = gameObject; this.input = input; }
/// <summary> /// Initializes a new instance of the <see cref="TriggerAttribute"/> class. /// </summary> /// <param name="Button">The button.</param> /// <param name="Action">The action.</param> public TriggerAttribute(MouseButtons Button, InputActions Action) { eventdata = new MouseButtonTrigger(Button, Action); }
// Same as the regular CheckAction but assumes that input will not be // buffered. /// <summary> /// Same as the regular CheckAction but assumes that input will not bebuffered. /// </summary> /// <param name="action">Which action to check, as defined in InputManager.InputActions.</param> /// <returns>True if that action happened this frame.</returns> public bool CheckAction(InputActions action) { return CheckAction(action, false); }