private void ButtonClick(EInputState obj) { if (obj == EInputState.Down) { _thow.Play(); } }
public void MoveLeft() { if (!_isMoveLeft) { MirrorPlayer(); _isMoveLeft = true; } _direction = EInputState.Left; }
void Awake() { if (null != instance) { Debug.LogError("There are more than one InputManager on the scene"); } instance = this; inputState = EInputState.Normal; }
public void MoveRight() { if (_isMoveLeft) { MirrorPlayer(); _isMoveLeft = false; } _direction = EInputState.Right; }
public void OnGameEvent(PlayerInputGameEvent inputEvent) { if (m_IsInDialogue && m_IsWaitingForInput) { string input = inputEvent.GetInput(); EInputState state = inputEvent.GetInputState(); if (input == "Enter" && state == EInputState.Down) { m_IsWaitingForInput = false; } } }
void Update() { if (Input.GetMouseButtonDown(0) && inputState != EInputState.MouseDown) { inputState = EInputState.MouseDown; if (null != OnClick) OnClick(Input.mousePosition); } else if (Input.GetMouseButtonUp(0)) { inputState = EInputState.Normal; } }
// Use this for initialization void Awake() { m_State = EInputState.MouseKeyBoard; if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); } else { if (this != instance) { Destroy(this.gameObject); } } }
private void ButtonClick(EInputState clickState) { switch (clickState) { case EInputState.Left: RunAnimation(); break; case EInputState.Right: RunAnimation(); break; case EInputState.Down: _animator.SetInteger("Stay", 2); break; } }
private void ButtonOnClick(EInputState inputValue) { switch (inputValue) { case EInputState.Left: _playerMoves.MoveLeft(); break; case EInputState.Right: _playerMoves.MoveRight(); break; case EInputState.Down: _playerMoves.ThrowBox(); break; } }
public void OnGameEvent(PlayerInputGameEvent inputEvent) { if (UpdaterProxy.Get().IsPaused() || !m_ProcessInput) { return; } string input = inputEvent.GetInput(); EInputState state = inputEvent.GetInputState(); switch (input) { case "Jump": if (state == EInputState.Down) { Jump(); } break; case "Right": Move(state == EInputState.Held ? 1 : 0); ChangeFacingDirection(m_Right); break; case "Left": Move(state == EInputState.Held ? -1 : 0); ChangeFacingDirection(m_Left); break; case "Blast": if (state == EInputState.Down) { Fire(); } break; case "Slash": if (state == EInputState.Down) { Slash(); } break; default: break; } }
private void OnGUI() { switch (m_State) { case EInputState.MouseKeyBoard: if (IsControllerInput()) { m_State = EInputState.Controller; } break; case EInputState.Controller: if (IsMouseKeyBoard()) { m_State = EInputState.MouseKeyBoard; } break; } }
protected void UpdateInputState() { var isPressed = IsPressed(); #if (LOG_INPUT_DEBUG) var previousState = m_InputState; #endif switch (m_InputState) { case EInputState.Released: if (isPressed) { m_InputState = EInputState.JustPressed; } break; case EInputState.JustPressed: m_InputState = EInputState.Pressed; break; case EInputState.Pressed: if (!isPressed) { m_InputState = EInputState.JustReleased; } break; case EInputState.JustReleased: m_InputState = EInputState.Released; break; } #if (LOG_INPUT_DEBUG) if (m_InputState != previousState) { Debug.Log("[InputState] InputState changed from: " + previousState + " to " + m_InputState); } #endif }
public void OnGameEvent(PlayerInputGameEvent inputEvent) { string input = inputEvent.GetInput(); EInputState state = inputEvent.GetInputState(); if (state != EInputState.Up) { switch (input) { case "Right": Move(true); break; case "Left": Move(false); break; default: break; } } }
public void AddButtonListener(string _buttonName, EInputState _state, EButtonType _type, UnityEvent _func) { if (!CheckButton(_buttonName)) { AddButton(_buttonName); } switch (_state) { case EInputState.Pressed: AddPressedListener(_buttonName, _type, _func); break; case EInputState.Stay: AddStayPressedListener(_buttonName, _type, _func); break; case EInputState.Released: AddReleasedListener(_buttonName, _type, _func); break; default: break; } }
public void OnGameEvent(PlayerInputGameEvent inputEvent) { if (UpdaterProxy.Get().IsPaused()) { return; } string input = inputEvent.GetInput(); EInputState state = inputEvent.GetInputState(); if (state == EInputState.Down) { switch (input) { case "TurnRight": AddTurnCommand((int)EFacingDirection.Right); break; case "TurnLeft": AddTurnCommand((int)EFacingDirection.Left); break; case "TurnUp": AddTurnCommand((int)EFacingDirection.Up); break; case "TurnDown": AddTurnCommand((int)EFacingDirection.Down); break; case "Grab / Ungrab": AddToggleGrabCommand(); break; case "BinSpawnRequest": AddBinSpawnCommand(); break; default: break; } } if (state == EInputState.Held || state == EInputState.Down) { switch (input) { case "Right": AddMoveCommand(1, 0); break; case "Left": AddMoveCommand(-1, 0); break; case "Up": AddMoveCommand(0, 1); break; case "Down": AddMoveCommand(0, -1); break; case "Undo": m_TimeHoldingUndo += Time.deltaTime; if (!m_IsUndoing && (m_TimeHoldingUndo > m_HeldUndoTreshold || state == EInputState.Down)) { StartCoroutine(Undo()); } break; default: break; } } if (state == EInputState.Up && input == "Undo") { m_TimeHoldingUndo = 0f; } }
public void Stay() { _direction = EInputState.None; }
public PlayerInputGameEvent(string input, EInputState state) : base("Player", EProtocol.Instant) { m_Input = input; m_State = state; }
void UpdateInput() { if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.WebGLPlayer) { if (Input.GetMouseButtonDown(0)) { if (EventSystem.current.IsPointerOverGameObject()) { return; } m_InputState = EInputState.Down; foreach (var item in m_EventHandleres) { item.OnPressDown(Input.mousePosition); } } else if (Input.GetMouseButtonUp(0)) { if (m_InputState != EInputState.Down) { return; } if (EventSystem.current.IsPointerOverGameObject()) { return; } m_InputState = EInputState.Up; foreach (var item in m_EventHandleres) { item.OnReleaseUp(Input.mousePosition); } } if (m_InputState == EInputState.Down) { foreach (var item in m_EventHandleres) { item.OnDrag(Input.mousePosition); } } } else { bool foundTouch = false; Touch thisTouch = new Touch(); for (int i = 0; i < Input.touches.Length; i++) { thisTouch = Input.touches[i]; foundTouch = true; } if (foundTouch) { Vector2 screenPos = thisTouch.position; switch (thisTouch.phase) { case TouchPhase.Began: { if (EventSystem.current.IsPointerOverGameObject(thisTouch.fingerId)) { return; } m_InputState = EInputState.Down; foreach (var item in m_EventHandleres) { item.OnPressDown(thisTouch.position); } } break; case TouchPhase.Ended: { if (m_InputState != EInputState.Down) { return; } if (EventSystem.current.IsPointerOverGameObject(thisTouch.fingerId)) { return; } m_InputState = EInputState.Up; foreach (var item in m_EventHandleres) { item.OnReleaseUp(thisTouch.position); } } break; case TouchPhase.Moved: if (m_InputState == EInputState.Down) { if (EventSystem.current.IsPointerOverGameObject(thisTouch.fingerId)) { return; } foreach (var item in m_EventHandleres) { item.OnDrag(thisTouch.position); } } break; case TouchPhase.Stationary: break; default: break; } } } }
public void AddStateToHistory(EInputState inputState) { _previousStates.Push(inputState); }