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); } } } }
protected override void OnRunEventInput(InputButtonType eButtonType, GetInputType eGetType) { if (!TryGetIActorData(out IActorData_Input hDataInput)) { return; } hDataInput.inputButtonCallback.Run((eButtonType, eGetType), this); }
/// <summary> /// Get KeyCode by the section and name of the hotkey. /// </summary> /// <param name="section">Secion name.</param> /// <param name="hotkeyName">Hotkey enum.</param> /// <returns></returns> public string GetButton(string section, InputButtonType hotkeyName) { if (!Hotkeys.ContainsKey(section) || !Hotkeys[section].ContainsKey(hotkeyName)) { Debug.unityLogger.LogFormat(LogType.Error, "No KeyCode for hotkey: {0} from the section: {1}!", hotkeyName, section); return(string.Empty); } return(Hotkeys[section][hotkeyName]); }
public bool GetButtonWasPressedLastFrame(InputButtonType buttonPressed) { foreach (InputButtonType button in buttonsPressedLastFrame) { if (buttonPressed == button) { return(true); } } return(false); }
public void UpdateButtonPressed(InputButtonType buttonPressed) { foreach (InputButtonType button in buttonsPressedLastFrame) { if (buttonPressed == button) { return; } } buttonsPressedLastFrame.Add(buttonPressed); StartCoroutine(RemoveButtonsPressedLastFrame(buttonPressed)); }
public bool GetButton(InputButtonType type) { switch (type) { case InputButtonType.Down: return(GetButtonDown()); case InputButtonType.Stay: return(GetButton()); case InputButtonType.Up: return(GetButtonUp()); default: return(false); } }
protected override void SetHoldingInputData(InputButtonType eButtonType, GetInputType eGetType) { var eHoldingInput = m_hInputData.m_eHoldingInput; if (eGetType == GetInputType.Down) { AddHoldFlag(eButtonType); } else if (eGetType == GetInputType.Up) { RemoveHoldFlag(eButtonType); } m_hInputData.m_eHoldingInput = eHoldingInput; }
public static bool GetButton(string buttonName, InputButtonType type) { switch (type) { case InputButtonType.Up: return(Input.GetButtonUp(buttonName)); case InputButtonType.Down: return(Input.GetButtonDown(buttonName)); case InputButtonType.Stay: return(Input.GetButton(buttonName)); default: throw new System.Exception("For input enum " + type); } }
//Handles input from the player. private void Input_OnInputEvent(InputButtonType button, InputEventType inputEvent, int joyID = 0) { if (!planet.saveData.isAlive) { return; } if (inputEvent == InputEventType.Pressed) { switch (button) { case InputButtonType.Cancel: controller.gui.TogglePauseMenu(); break; } } if (planet.saveData.isAlive && inputEvent == InputEventType.Continuous && !controller.isPaused) { switch (button) { case InputButtonType.MouseLeft: Shoot(); break; #region ManualControlls //In case we need to controll our planet manually. Comment out planet.MovePlanet() in Update method. /* * case InputButtonType.Left: * planet.MovePlanet(1); * break; * case InputButtonType.Right: * planet.MovePlanet(-1); * break; */ #endregion } } }
/// <summary> /// On press event process. /// </summary> /// <param name="eButtonType">Input event type.</param> /// <param name="bRawValue">Raw value of input.</param> /// <returns>Get input type of this input event.</returns> protected virtual GetInputType OnPressInput(InputButtonType eButtonType, bool bRawValue) { if (previousGetType == null) { previousGetType = new Dictionary <InputButtonType, GetInputType>(); } if (!previousGetType.ContainsKey(eButtonType)) { previousGetType.Add(eButtonType, GetInputType.None); } var eGetType = previousGetType[eButtonType]; eGetType = InputUtility.ConvertRawValueToGetType(eGetType, bRawValue); RunEventInput(eButtonType, eGetType); SetHoldingInputData(eButtonType, eGetType); previousGetType[eButtonType] = eGetType; return(eGetType); }
void OnButtonDown(InputActionEventData data) { InputButtonType buttonInput = (InputButtonType)System.Enum.Parse(typeof(InputButtonType), data.actionName); switch (buttonInput) { case InputButtonType.A: ButtonADownEvent?.Invoke(data.playerId); break; case InputButtonType.B: ButtonBDownEvent?.Invoke(data.playerId); break; case InputButtonType.X: ButtonXDownEvent?.Invoke(data.playerId); break; case InputButtonType.Y: ButtonYDownEvent?.Invoke(data.playerId); break; case InputButtonType.Left: ButtonLeftDownEvent?.Invoke(data.playerId); break; case InputButtonType.Right: ButtonRightDownEvent?.Invoke(data.playerId); break; case InputButtonType.Up: ButtonUpDownEvent?.Invoke(data.playerId); break; case InputButtonType.Down: ButtonDownDownEvent?.Invoke(data.playerId); break; case InputButtonType.ZL: ButtonZLDownEvent?.Invoke(data.playerId); break; case InputButtonType.L: ButtonLDownEvent?.Invoke(data.playerId); break; case InputButtonType.ZR: ButtonZRDownEvent?.Invoke(data.playerId); break; case InputButtonType.R: ButtonRDownEvent?.Invoke(data.playerId); break; case InputButtonType.Plus: ButtonPlusDownEvent?.Invoke(data.playerId); break; case InputButtonType.Minus: ButtonMinusDownEvent?.Invoke(data.playerId); break; case InputButtonType.Home: ButtonHomeDownEvent?.Invoke(data.playerId); break; case InputButtonType.Capture: ButtonCaptureDownEvent?.Invoke(data.playerId); break; case InputButtonType.Left_SL: ButtonLeftSLDownEvent?.Invoke(data.playerId); break; case InputButtonType.Right_SL: ButtonRightSLDownEvent?.Invoke(data.playerId); break; case InputButtonType.Left_SR: ButtonLeftSRDownEvent?.Invoke(data.playerId); break; case InputButtonType.Right_SR: ButtonRightSRDownEvent?.Invoke(data.playerId); break; case InputButtonType.Left_Stick: ButtonLeftStickDownEvent?.Invoke(data.playerId); break; case InputButtonType.Right_Stick: ButtonRightStickDownEvent?.Invoke(data.playerId); break; case InputButtonType.KeyboardDown: LeftJoystickUsedEvent?.Invoke(data.playerId, InputDirection.Down); break; case InputButtonType.KeyboardLeft: LeftJoystickUsedEvent?.Invoke(data.playerId, InputDirection.Left); break; case InputButtonType.KeyboardRight: LeftJoystickUsedEvent?.Invoke(data.playerId, InputDirection.Right); break; case InputButtonType.KeyboardUp: LeftJoystickUsedEvent?.Invoke(data.playerId, InputDirection.Up); break; } }
protected abstract void OnRunEventInput(InputButtonType eButtonType, GetInputType eGetType);
//Buttons event (Keyboard and mouse). public void ButtonEvent(InputButtonType button, InputEventType inputEvent, int joyID = 0) { device = button == InputButtonType.MouseLeft ? InputDevice.Mouse : InputDevice.Keyboard; OnInputEvent?.Invoke(button, inputEvent, joyID); }
IEnumerator RemoveButtonsPressedLastFrame(InputButtonType buttonPressed) { yield return(null); buttonsPressedLastFrame.Remove(buttonPressed); }
protected override void RunEventInput(InputButtonType eEventType, GetInputType eGetType) { m_hOnRunEventInput?.Invoke(eEventType, eGetType); }
protected virtual void RemoveHoldFlag(InputButtonType eButtonType) { m_hInputData.m_eHoldingInput &= ~eButtonType; }
protected abstract void SetHoldingInputData(InputButtonType eButtonType, GetInputType eGetType);
void OnButtonPress(InputActionEventData data) { InputButtonType buttonInput = (InputButtonType)System.Enum.Parse(typeof(InputButtonType), data.actionName); switch (buttonInput) { case InputButtonType.A: ButtonAPressedEvent?.Invoke(data.playerId); break; case InputButtonType.B: ButtonBPressedEvent?.Invoke(data.playerId); break; case InputButtonType.X: ButtonXPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Y: ButtonYPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Left: ButtonLeftPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Right: ButtonRightPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Up: ButtonUpPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Down: ButtonDownPressedEvent?.Invoke(data.playerId); break; case InputButtonType.ZL: ButtonZLPressedEvent?.Invoke(data.playerId); break; case InputButtonType.L: ButtonLPressedEvent?.Invoke(data.playerId); break; case InputButtonType.ZR: ButtonZRPressedEvent?.Invoke(data.playerId); break; case InputButtonType.R: ButtonRPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Plus: ButtonPlusPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Minus: ButtonMinusPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Home: ButtonHomePressedEvent?.Invoke(data.playerId); break; case InputButtonType.Capture: ButtonCapturePressedEvent?.Invoke(data.playerId); break; case InputButtonType.Left_SL: ButtonLeftSLPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Right_SL: ButtonRightSLPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Left_SR: ButtonLeftSRPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Right_SR: ButtonRightSRPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Left_Stick: ButtonLeftStickPressedEvent?.Invoke(data.playerId); break; case InputButtonType.Right_Stick: ButtonRightStickPressedEvent?.Invoke(data.playerId); break; } }
void OnButtonUp(InputActionEventData data) { InputButtonType buttonInput = (InputButtonType)System.Enum.Parse(typeof(InputButtonType), data.actionName); if (EventManager.Instance != null) { EventManager.Instance.UpdateButtonPressed(buttonInput); } switch (buttonInput) { case InputButtonType.A: ButtonAUpEvent?.Invoke(data.playerId); break; case InputButtonType.B: ButtonBUpEvent?.Invoke(data.playerId); break; case InputButtonType.X: ButtonXUpEvent?.Invoke(data.playerId); break; case InputButtonType.Y: ButtonYUpEvent?.Invoke(data.playerId); break; case InputButtonType.Left: ButtonLeftUpEvent?.Invoke(data.playerId); break; case InputButtonType.Right: ButtonRightUpEvent?.Invoke(data.playerId); break; case InputButtonType.Up: ButtonUpUpEvent?.Invoke(data.playerId); break; case InputButtonType.Down: ButtonDownUpEvent?.Invoke(data.playerId); break; case InputButtonType.ZL: ButtonZLUpEvent?.Invoke(data.playerId); break; case InputButtonType.L: ButtonLUpEvent?.Invoke(data.playerId); break; case InputButtonType.ZR: ButtonZRUpEvent?.Invoke(data.playerId); break; case InputButtonType.R: ButtonRUpEvent?.Invoke(data.playerId); break; case InputButtonType.Plus: ButtonPlusUpEvent?.Invoke(data.playerId); break; case InputButtonType.Minus: ButtonMinusUpEvent?.Invoke(data.playerId); break; case InputButtonType.Home: ButtonHomeUpEvent?.Invoke(data.playerId); break; case InputButtonType.Capture: ButtonCaptureUpEvent?.Invoke(data.playerId); break; case InputButtonType.Left_SL: ButtonLeftSLUpEvent?.Invoke(data.playerId); break; case InputButtonType.Right_SL: ButtonRightSLUpEvent?.Invoke(data.playerId); break; case InputButtonType.Left_SR: ButtonLeftSRUpEvent?.Invoke(data.playerId); break; case InputButtonType.Right_SR: ButtonRightSRUpEvent?.Invoke(data.playerId); break; case InputButtonType.Left_Stick: ButtonLeftStickUpEvent?.Invoke(data.playerId); break; case InputButtonType.Right_Stick: ButtonRightStickUpEvent?.Invoke(data.playerId); break; } }
protected virtual void AddHoldFlag(InputButtonType eButtonType) { m_hInputData.m_eHoldingInput |= eButtonType; }