void Update() { if (InputMng.GetButtonDown("Back", playerId)) { EventManager.Fire(new Event_Paused()); } GameState state = FindObjectOfType <GameState> (); if (state && state.PauseEnabled) { if (_pauseMenuActionLockedFrameNumber == 0) { var offst = GetPauseMenuDirection(); EventManager.Fire(new Event_ChangeSelectedPauseMenuItem() { offset = offst }); _pauseMenuActionLockedFrameNumber = PAUSE_MENU_FRAME_LOCK; } else { _pauseMenuActionLockedFrameNumber -= 1; } if (InputMng.GetButtonDown("Button A", playerId)) { EventManager.Fire(new Event_SelectPauseMenuItem()); } } }
private Vector2 GetRawMoveVector() { Vector2 move = Vector2.zero; move.x = InputManager.GetAxisRaw(m_HorizontalAxis); move.y = InputManager.GetAxisRaw(m_VerticalAxis); if (InputManager.GetButtonDown(m_HorizontalAxis)) { if (move.x < 0) { move.x = -1f; } if (move.x > 0) { move.x = 1f; } } if (InputManager.GetButtonDown(m_VerticalAxis)) { if (move.y < 0) { move.y = -1f; } if (move.y > 0) { move.y = 1f; } } return(move); }
public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } var shouldActivate = m_ForceModuleActive; InputManager.GetButtonDown(m_SubmitButton); shouldActivate |= InputManager.GetButtonDown(m_CancelButton); shouldActivate |= !Mathf.Approximately(InputManager.GetAxisRaw(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(InputManager.GetAxisRaw(m_VerticalAxis), 0.0f); shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= InputManager.GetMouseButtonDown(0); for (int i = 0; i < InputManager.touchCount; ++i) { Touch input = InputManager.GetTouch(i); shouldActivate |= input.phase == TouchPhase.Began || input.phase == TouchPhase.Moved || input.phase == TouchPhase.Stationary; } return(shouldActivate); }
private bool AllowMoveEventProcessing(float time) { bool allow = InputManager.GetButtonDown(m_HorizontalAxis); allow |= InputManager.GetButtonDown(m_VerticalAxis); allow |= (time > m_NextAction); return(allow); }
/// <summary> /// Process keyboard events. /// </summary> protected bool SendMoveEventToSelectedObject() { float time = Time.unscaledTime; Vector2 movement = GetRawMoveVector(); if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f)) { m_ConsecutiveMoveCount = 0; return(false); } // If user pressed key again, always allow event bool allow = InputManager.GetButtonDown(m_HorizontalAxis) || InputManager.GetButtonDown(m_VerticalAxis); bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0); if (!allow) { // Otherwise, user held down key or axis. // If direction didn't change at least 90 degrees, wait for delay before allowing consequtive event. if (similarDir && m_ConsecutiveMoveCount == 1) { allow = (time > m_PrevActionTime + m_RepeatDelay); } // If direction changed at least 90 degree, or we already had the delay, repeat at repeat rate. else { allow = (time > m_PrevActionTime + 1f / m_InputActionsPerSecond); } } if (!allow) { return(false); } // Debug.Log(m_ProcessingEvent.rawType + " axis:" + m_AllowAxisEvents + " value:" + "(" + x + "," + y + ")"); var axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f); if (axisEventData.moveDir != MoveDirection.None) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler); if (!similarDir) { m_ConsecutiveMoveCount = 0; } m_ConsecutiveMoveCount++; m_PrevActionTime = time; m_LastMoveVector = movement; } else { m_ConsecutiveMoveCount = 0; } return(axisEventData.used); }
public override bool ShouldActivateModule() { if (!base.ShouldActivateModule()) { return(false); } var shouldActivate = InputManager.GetButtonDown(m_SubmitButton); shouldActivate |= InputManager.GetButtonDown(m_CancelButton); shouldActivate |= !Mathf.Approximately(InputManager.GetAxisRaw(m_HorizontalAxis), 0.0f); shouldActivate |= !Mathf.Approximately(InputManager.GetAxisRaw(m_VerticalAxis), 0.0f); shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f; shouldActivate |= InputManager.GetMouseButtonDown(0); return(shouldActivate); }
public bool GetLaunchTrigger(int typeOfLaunchedMine) { switch (typeOfLaunchedMine) { case (int)Mine.MineTypes.Simple: return(InputMng.GetButtonDown("Button A", playerId)); case (int)Mine.MineTypes.Dash: return(InputMng.GetButtonDown("Button B", playerId)); case (int)Mine.MineTypes.Speed: return(InputMng.GetButtonDown("Button X", playerId)); default: throw new System.Exception("Unknown type of launched mine: " + typeOfLaunchedMine); } }
/// <summary> /// Process submit keys. /// </summary> private bool SendSubmitEventToSelectedObject() { if (eventSystem.currentSelectedGameObject == null) { return(false); } var data = GetBaseEventData(); if (InputManager.GetButtonDown(m_SubmitButton)) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler); } if (InputManager.GetButtonDown(m_CancelButton)) { ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler); } return(data.used); }
public static bool GetButtonDown(string buttonName) { return(InputManager.GetButtonDown(buttonName)); }
void Update() { if (_lockFlag) { return; } if (Input.GetKeyDown(KeyCode.Return) && JoinObjects.Count > 0) { GoToGame(); } int i = 0; while (i < playersConnected) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(i); if (InputMng.GetButtonDown("Button A", playerId)) { PlayerInfo info = _holder.playersInfos.Find(infs => infs.playerNumber == i); if (info != null) { _holder.RemovePlayerInfo(info); GameObject hideGO = JoinObjects.Find(objs => objs.name == joinKeysPrefixes[i]); if (hideGO) { hideGO.SetActive(false); } } else { //Color col = UnityEngine.Random.ColorHSV(0, 1, 1, 1, 1, 1); Color col = PlayerColors[i]; _holder.AddPlayerInfo(new PlayerInfo(col, i)); GameObject showGO = JoinObjects.Find(objs => objs.activeSelf == false); if (showGO) { showGO.SetActive(true); showGO.name = joinKeysPrefixes[i]; ColorSetter.UpdateModelColor(showGO, col); } } PlayMenuClick(); } i++; } foreach (var player in _holder.playersInfos) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)) .GetValue(player.playerNumber); if (InputMng.GetButtonDown("Start", playerId)) { player.ready = !player.ready; GameObject readyGOParent = JoinObjects.Find(objs => objs.name == joinKeysPrefixes[player.playerNumber]); readyGOParent.transform.Find("ReadyFlag").gameObject.SetActive(player.ready); PlayMenuClick(); } } bool _allReady = true; if (_holder.playersInfos.Count > 1) { foreach (var player in _holder.playersInfos) { if (!player.ready) { _allReady = false; } } } else { _allReady = false; } if (_allReady) { _lockFlag = true; Invoke("GoToGame", 0.5f); } }