private void Update()
    {
        hInput = Input.GetAxisRaw("Horizontal");
        vInput = Input.GetAxisRaw("Vertical");

        if (Input.GetButtonDown("Jump"))
        {
            OnJumpPressed?.Invoke();
        }
    }
Beispiel #2
0
    private void Update()
    {
        TimeSpentInGame = (float)Math.Round(Time.time, 2);

        OnAxisChanged?.Invoke(Input.GetAxis("Horizontal"));

        if (Input.GetButtonDown("Jump"))
        {
            OnJumpPressed?.Invoke();
        }

        PlayerAnimator.SetFloat("movementSpeed", MovementSpeed);
        PlayerAnimator.SetBool("IsJumping", IsJumping);
        PlayerAnimator.SetBool("IsHurt", IsHurt);

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene(0);
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (BlockInput)
        {
            return;
        }
        if (input.GetButtonDown("Melee"))
        {
            OnMeleePressed?.Invoke();
        }

        var throwPressed = false;

        if (usingController)
        {
            print(GetAimingDirection());
            if (GetAimingDirection().sqrMagnitude > 0.25f)
            {
                SetAimingLine();
                print(input.GetAxis("Throw"));
                if (input.GetAxis("Throw") > 0.3f)
                {
                    throwPressed       = true;
                    throwPressedBefore = true;
                }
            }
            else
            {
                HideAimingLine();
            }
        }
        else
        {
            SetAimingLine();
            if (input.GetButton("Throw"))
            {
                throwPressed       = true;
                throwPressedBefore = true;
            }
        }

        if (throwPressed)
        {
            allLaunchTimer += Time.deltaTime;
            if (allLaunchTimer >= allLaunchTime)
            {
                OnChargedRangePressed?.Invoke();
                allLaunchTimer     = 0;
                throwPressedBefore = false;
            }
        }
        else
        {
            if (throwPressedBefore)
            {
                if (allLaunchTimer < allLaunchTime)
                {
                    OnRangePressed?.Invoke();
                }

                allLaunchTimer     = 0;
                throwPressedBefore = false;
            }
        }

        if (input.GetButtonDown("Jump"))
        {
            OnJumpPressed?.Invoke();
        }

        //if (input.GetButtonDown("WithdrawOnAir"))
        //      {
        //          OnWithdrawAirPressed?.Invoke();
        //      }

        //      if (input.GetButtonDown("WithdrawOnStuck"))
        //      {
        //          OnWithdrawStuckPressed?.Invoke();
        //      }

        if (input.GetButton("WithdrawOnAir") || input.GetButton("WithdrawOnStuck"))
        {
            withdrawPressedBefore = true;
            withdrawTimer        += Time.deltaTime;
            if (withdrawTimer >= withdrawTime)
            {
                OnWithdrawAirPressed?.Invoke();
            }
        }
        else if (withdrawPressedBefore)
        {
            withdrawPressedBefore = false;
            if (withdrawTimer < withdrawTime)
            {
                OnWithdrawStuckPressed?.Invoke();
            }
            withdrawTimer = 0;
        }
    }