private void FixedUpdate()
    {
        // Moving event:
        if (Input.GetAxis("Horizontal") != 0)
        {
            OnMoveButtonPressed?.Invoke(Input.GetAxis("Horizontal"));
        }

        // Jumping event:
        if (Input.GetAxis("Jump") != 0)
        {
            OnJumpButtonPressed?.Invoke(Input.GetAxis("Horizontal"));
        }
    }
示例#2
0
    private void Update()
    {
        InputDirectionStorage.StoreLastNonZeroDirection(CrossPlatformInputManager.GetAxisRaw("Horizontal"));

        OnMovementButtonPressed?.Invoke(InputDirectionStorage.CurrentDirection);

        if (CrossPlatformInputManager.GetButtonDown("Jump"))
        {
            OnJumpButtonPressed?.Invoke();
        }

        if (CrossPlatformInputManager.GetButtonDown("Shift"))
        {
            OnDashButtonPressed?.Invoke(InputDirectionStorage.LastNonZeroDirection);
        }
    }
示例#3
0
        private void Update()
        {
            if (!GameEventsHandler.Instance.IsPlayerAlive)
            {
                return;
            }

            var horizontalInput = CrossPlatformInputManager.GetAxisRaw("Horizontal");

            OnMovementButtonPressed?.Invoke(horizontalInput);

            if (CrossPlatformInputManager.GetButtonDown("B_Button"))
            {
                OnJumpButtonPressed?.Invoke();
            }

            if (CrossPlatformInputManager.GetButtonDown("A_Button"))
            {
                OnAttackButtonPressed?.Invoke();
            }
        }
示例#4
0
 // Update is called once per frame
 void Update()
 {
     // we check inputs and if buttons are pressed, the appropriate events will be fired
     #region "Forward (W)"
     if (Input.GetKeyDown(KeyCode.W))
     {
         OnForwardKeyPressed?.Invoke();
     }
     if (Input.GetKey(KeyCode.W))
     {
         OnForwardKeyHold?.Invoke();
     }
     if (Input.GetKeyUp(KeyCode.W))
     {
         OnForwardKeyReleased?.Invoke();
     }
     #endregion
     #region "Backward (S)"
     if (Input.GetKeyDown(KeyCode.S))
     {
         OnBackwardKeyPressed?.Invoke();
     }
     if (Input.GetKey(KeyCode.S))
     {
         OnBackwardKeyHold?.Invoke();
     }
     if (Input.GetKeyUp(KeyCode.S))
     {
         OnBackwardKeyReleased?.Invoke();
     }
     #endregion
     #region "Left (A)"
     if (Input.GetKeyDown(KeyCode.A))
     {
         OnLeftKeyPressed?.Invoke();
     }
     if (Input.GetKey(KeyCode.A))
     {
         OnLeftKeyHold?.Invoke();
     }
     if (Input.GetKeyUp(KeyCode.A))
     {
         OnLeftKeyReleased?.Invoke();
     }
     #endregion
     #region "Right (D)"
     if (Input.GetKeyDown(KeyCode.D))
     {
         OnRightKeyPressed?.Invoke();
     }
     if (Input.GetKey(KeyCode.D))
     {
         OnRightKeyHold?.Invoke();
     }
     if (Input.GetKeyUp(KeyCode.D))
     {
         OnRightKeyReleased?.Invoke();
     }
     #endregion
     #region "Running (Left Shift)"
     if (Input.GetKeyDown(KeyCode.LeftShift))
     {
         OnRunningKeyPressed?.Invoke();
     }
     if (Input.GetKey(KeyCode.LeftShift))
     {
         OnRunningKeyHold?.Invoke();
     }
     if (Input.GetKeyUp(KeyCode.LeftShift))
     {
         OnRunningKeyReleased?.Invoke();
     }
     #endregion
     #region "Left Click (Mouse1)"
     if (Input.GetMouseButtonDown(0))
     {
         OnLeftClickPressed?.Invoke();
     }
     if (Input.GetMouseButton(0))
     {
         OnLeftClickHold?.Invoke();
     }
     if (Input.GetMouseButtonUp(0))
     {
         OnLeftClickReleased?.Invoke();
     }
     #endregion
     #region "Right Click (Mouse2)"
     if (Input.GetMouseButtonDown(1))
     {
         OnRightClickPressed?.Invoke();
     }
     if (Input.GetMouseButton(1))
     {
         OnRightClickHold?.Invoke();
     }
     if (Input.GetMouseButtonUp(1))
     {
         OnRightClickReleased?.Invoke();
     }
     #endregion
     #region "Jump (Spacebar)"
     if (Input.GetKeyDown(KeyCode.Space))
     {
         OnJumpButtonPressed?.Invoke();
     }
     #endregion
     #region "Lock On (F)"
     if (Input.GetKeyDown(KeyCode.F))
     {
         OnLockOnButtonPressed?.Invoke();
     }
     #endregion
 }