protected virtual void OnInputUpdate(InputActionEventData data) { if (data.playerId == m_PlayerId) { switch (data.actionId) { case RewiredConsts.Action.Move_Horizontal: m_Horizontal = data.GetAxis(); break; case RewiredConsts.Action.Move_Vertical: m_Vertical = data.GetAxis(); break; case RewiredConsts.Action.Interact: if (data.GetButtonDown()) { if (m_CurrentInteractable != null) { m_CurrentInteractable.Interact(m_Callout, m_SaveSlot); m_CurrentInteractable = null; } } break; } m_Movement = m_CamTransform.forward * m_Vertical + m_CamTransform.right * m_Horizontal; m_Movement.y = 0f; } }
protected virtual void OnInputUpdate(InputActionEventData data) { float value = 0f; Vector2 axis = Vector2.zero; Button b = Button.Guide; // not used switch (data.actionId) { case RewiredConsts.Action.Nav_Horizontal: value = data.GetAxis(); if (Mathf.Abs(value) > _deadzone) { axis.x = data.GetAxis(); } break; case RewiredConsts.Action.Nav_Vertical: value = data.GetAxis(); if (Mathf.Abs(value) > _deadzone) { axis.y = data.GetAxis(); } break; case RewiredConsts.Action.Select: if (data.GetButtonDown()) { b = Button.A; } break; case RewiredConsts.Action.Cancel: if (data.GetButtonDown()) { b = Button.B; } break; case RewiredConsts.Action.Confirm: if (data.GetButtonDown()) { b = Button.Start; } break; } if (axis != Vector2.zero) { if (_currentScreen != null && Time.time > _currentTime + _inputDelayTime) { _currentScreen.ProcessAxisInput(data.playerId, axis); _currentTime = Time.time; } } if (b != Button.Guide && _currentScreen != null) { _currentScreen.ProcessButtonInput(data.playerId, b); } }
protected override void OnInputUpdate(InputActionEventData data) { if (ScreenInputLocked()) { return; } bool handled = false; switch (data.actionId) { case RewiredConsts.Action.Confirm: // change this to START, once you set that up you lazy fool if (data.GetButtonDown()) { Advance(); handled = true; } break; default: if (m_PlayerControlEnabled) { handled = m_Reticle.OnInputUpdate(data); } break; } // pass to base if (!handled) { base.OnInputUpdate(data); } }
private void Pickup(InputActionEventData data) { if (m_canPickup && m_status.CanAct && m_objectStack.Count < m_status.MaxCarry) { Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, m_status.PickupRange, m_status.ItemMask); if (hits.Length > 0) { float lastDist = 1000; ObjectController obj = null; foreach (Collider2D hit in hits) { float dist = Vector2.Distance(transform.position, hit.transform.position); if (dist < lastDist) { obj = hit.gameObject.GetComponent <ObjectController>(); lastDist = dist; } } if (obj != null && !obj.CurrentState.Thrown && !obj.CurrentState.Held) { if (m_pickup != null) { StopCoroutine(m_pickup); } m_lastPickupTime = Time.time; m_canPickup = false; m_anim.SetTrigger(AnimationConst.Pickup); m_pickup = StartCoroutine(PickupObject(obj)); GameController.Instance.CurrentState.ItemsTouched++; } } } }
protected override void OnInputUpdate(InputActionEventData data) { if (ScreenInputLocked()) { return; // can be controlled by any player } bool handled = false; switch (data.actionId) { case RewiredConsts.Action.Navigate_Horizontal: m_Horizontal = data.GetAxis(); handled = true; break; case RewiredConsts.Action.Navigate_Vertical: m_Vertical = data.GetAxis(); handled = true; break; } Vector3 moveDirection = (Vector3.up * m_Vertical + Vector3.right * m_Horizontal); if (moveDirection != Vector3.zero) { m_ReticleTransform.Translate(moveDirection * m_MoveSpeed * Time.deltaTime, UnityEngine.Space.World); } // pass to base if (!handled) { base.OnInputUpdate(data); } }
private void OnInputUpdate(InputActionEventData data) { if (m_PlayerId == data.playerId) { if (m_CameraMode == eCameraMode.Free) { float horizontal = 0f; float vertical = 0f; switch (data.actionId) { case RewiredConsts.Action.Camera_Horizontal: horizontal = data.GetAxis(); break; case RewiredConsts.Action.Camera_Vertical: vertical = data.GetAxis(); break; } m_CurrentYaw += horizontal * m_YawSpeed * Time.deltaTime; m_Offset.y += vertical * -1f * Time.deltaTime; m_Offset.y = Mathf.Clamp(m_Offset.y, -3f, -0.75f); } else { m_CurrentYaw = 0f; } } }
void OnFireUpdate(InputActionEventData data) { if (data.GetButtonDown()) { Debug.Log("Fire!"); } }
// Player action event delegate private void OnPlayerButtonEvent(InputActionEventData actionEvent) { //Debug.Log("INPUT: " + actionEvent.actionName + "\nPLAYER: " + actionEvent.playerId + "\nEVENT: " + actionEvent.eventType.ToString()); List <int> playerIndices = GetPlayerIndicesByInput(actionEvent.playerId); if (playerIndices.Count > 0) { // Get action id string actionID = actionEvent.actionName; if (string.Equals(actionID, HORIZONTAL_INPUT_KEY)) { actionID = actionEvent.eventType == InputActionEventType.NegativeButtonJustReleased ? HORIZONTAL_NEG_INPUT_KEY : HORIZONTAL_POS_INPUT_KEY; } else if (string.Equals(actionID, VERTICAL_INPUT_KEY)) { actionID = actionEvent.eventType == InputActionEventType.NegativeButtonJustReleased ? VERTICAL_NEG_INPUT_KEY : VERTICAL_POS_INPUT_KEY; } // Call delegate if (onPlayerButtonClick != null) { foreach (int playerIndex in playerIndices) { onPlayerButtonClick(playerIndex, actionID); } } } }
void OnAxisUpdate(InputActionEventData data) { InputButtonType buttonInput = (InputButtonType)System.Enum.Parse(typeof(InputButtonType), data.actionName); float x = (buttonInput == InputButtonType.Left_Move_Horizontal || buttonInput == InputButtonType.Right_Move_Horizontal) ? data.GetAxis() : 0; float y = (buttonInput == InputButtonType.Left_Move_Vertical || buttonInput == InputButtonType.Right_Move_Vertical) ? data.GetAxis() : 0; Joystic = new Vector2(x, y); if (LeftJoystickUsedEvent != null && (x > 0.2f || x < -0.2f || y > 0.2f || y < -0.2f)) { if (Mathf.Abs(Joystic.x) > Mathf.Abs(Joystic.y)) { if (Joystic.x > 0) { LeftJoystickUsedEvent(data.playerId, InputDirection.Right); } else { LeftJoystickUsedEvent(data.playerId, InputDirection.Left); } } else { if (Joystic.y > 0) { LeftJoystickUsedEvent(data.playerId, InputDirection.Up); } else { LeftJoystickUsedEvent(data.playerId, InputDirection.Down); } } } }
private void OnInputUpdate(InputActionEventData data) { switch (data.actionId) { case RewiredConsts.Action.Confirm: if (data.GetButtonDown()) { if (m_CloseCallback != null) { m_CloseCallback(true); } } break; case RewiredConsts.Action.Cancel: if (data.GetButtonDown() && m_CurrentPopupType == ePopupType.YesNo) { if (m_CloseCallback != null) { m_CloseCallback(false); } } break; } }
void OnLaneUpButtonPushed(InputActionEventData data) { if (OnLaneUpButtonDown != null) { OnLaneUpButtonDown.Invoke(); } }
protected override void OnInputUpdate(InputActionEventData data) { if (ScreenInputLocked() || (m_ControlledBySinglePlayer && data.playerId != 0)) { return; } bool handled = false; switch (data.actionId) { #if UNITY_EDITOR case RewiredConsts.Action.Confirm: if (data.GetButtonDown()) { CancelInvoke("ContinueFlow"); ContinueFlow(); handled = true; } break; #endif } // pass to base if (!handled) { base.OnInputUpdate(data); } }
/// <summary> /// Try to interact with the currently selected target after receiving Rewired input event /// </summary> /// <param name="_eventData">The Rewired input event data</param> private void TryInteract(InputActionEventData _eventData) { // Only interact if not in Measure Mode if (MeasureModeManager.GetInstance().GetMeasureMode()) { selected?.OnInteract(); } }
void ChangeTeam(InputActionEventData data) { ++myTeam; if (myTeam >= Teams.neutral) { myTeam = 0; } ReleaseControlledActor(); }
void OnFire(InputActionEventData data) { bool attacking = data.GetButton(); if (myAttackTimer > minAttackTime && data.GetButtonDown()) { myAttackTimer = 0; // If we just started doing the attack AND the timer should have lapsed, set the minimum timer over again } firing = attacking; }
void SkipPreRaceCutscene(InputActionEventData data) { if (data.GetButtonDown()) { if (preRacePlayableDirector != null) { preRacePlayableDirector.time = preRacePlayableDirector.duration; } } }
/// <summary> /// Toggle whether Measure Mode is enabled /// </summary> /// <param name="_eventData">Rewired input event data</param> private void ToggleMeasureMode(InputActionEventData _eventData) { // Do nothing if game is paused if (PauseManager.GetInstance().GetIsPaused()) { return; } MeasureModeManager.GetInstance().ToggleMeasureMode(); }
protected override void OnInputUpdate(InputActionEventData data) { if (ScreenInputLocked() || (m_ControlledBySinglePlayer && data.playerId != 0)) { return; } bool handled = false; if (m_State == eScreenState.Title) { switch (data.actionId) { case RewiredConsts.Action.Confirm: if (data.GetButtonDown()) { m_ScreenContentAnimator.SetTrigger("OpenMenu"); m_MainMenu.RefocusMenu(); UIManager.Instance.RefreshPrompts(m_ContentPromptInfo); // audio //VSEventManager.Instance.TriggerEvent(new AudioEvents.RequestGameplayAudioEvent(true, (AudioManager.eGamePlayClip)random)); handled = true; } break; } } else { handled = m_MainMenu.HandleInput(data); switch (data.actionId) { case RewiredConsts.Action.Cancel: if (data.GetButtonDown()) { m_ScreenContentAnimator.SetTrigger("CloseMenu"); UIManager.Instance.RefreshPrompts(); // audio //VSEventManager.Instance.TriggerEvent(new AudioEvents.RequestGameplayAudioEvent(true, (AudioManager.eGamePlayClip)random)); handled = true; } break; } } // pass to base if (!handled) { base.OnInputUpdate(data); } }
private void Menu(InputActionEventData data) { if (GameController.Instance.CurrentGameState == GameController.GameState.Paused) { Resume(); } else if (GameController.Instance.CurrentGameState == GameController.GameState.Playing) { Pause(); } }
void OnInputUpdate(InputActionEventData data) { try { this.NextScene(false); } catch (Exception ex) { Debug.LogError("Error in ChangeScenePressAnyButton's OnInputUpdate: " + ex.Message.ToString()); } }
protected override void OnInputUpdate(InputActionEventData data) { if (!m_InputBlocked && data.actionId == RewiredConsts.Action.UISelect) { if (data.GetButtonUp()) { Game.Instance.LoadGameState(eGameState.GamePlay); UIManager.Instance.TransitionToScreen(ScreenId.HUD); } } base.OnInputUpdate(data); }
void SimulateEventPress2(InputActionEventData data) { Debug.Log("VIBRATE TIME!"); foreach (var j in player.controllers.Joysticks) { if (j.supportsVibration && !(j.GetVibration(0) > 0)) { StartCoroutine(Vibrate(j)); break; } } }
private void UpdateAxis(InputActionEventData data) { switch (data.actionId) { case Actions.HorizontalMove: m_currentInput.x = data.GetAxisRaw(); break; case Actions.VerticalMove: m_currentInput.y = data.GetAxisRaw(); break; } }
private void OnBack(InputActionEventData data) { if (GameManager.Instance.HasStarted) { OnCloseMenu(data); } if (currentCanvasGroup == startingCanvasGroup) { return; } TransitionMenu(lastCanvasGroup); }
private void OnOpenMenu(InputActionEventData data) { ShowSettings(); Time.timeScale = 0; player.controllers.maps.SetMapsEnabled(true, "Menu"); player.controllers.maps.SetMapsEnabled(false, "InGame"); if (musicController) { musicController.SetMuffle(true); } }
void TryToChangePlayer(InputActionEventData data) { XDebug.Log("Trying to change"); if (controlledActor == null) { return; } var firstEligible = ControllableActorManager.Instance.GetAlliedUncontrolledActors(myTeam, controlledActor) .First(actor => actor.GetComponent <Status>().isHero); if (firstEligible && firstEligible != controlledActor) { ChangeControlledActor(firstEligible); } }
private void InputResetCameraRotation(InputActionEventData data) { if (this._blockingEventsManager.IsAnyBlockingEventHappening) { return; } if (!data.GetButtonDown()) { return; } if (this._playerCamera == null) { return; } this._playerCamera.ResetRotation(); }
private void InputRun(InputActionEventData data) { if (this._blockingEventsManager.IsAnyBlockingEventHappening) { return; } var character = this.GetControllingCharacter(); if (character == null) { return; } var inputRun = data.GetButton(); character.InputRun = inputRun; }