Exemplo n.º 1
0
    void Update()
    {
        Vector3 feetPosition = new Vector3();

        feetPosition.x = transform.position.x;
        feetPosition.z = transform.position.z;
        feetPosition.y = transform.position.y - (transform.localScale.y * 1.1f);
        // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer.
        grounded = Physics2D.Linecast(transform.position, feetPosition, groundLayer);

        // If the jump button is pressed and the player is grounded then the player should jump.
        if (grounded)
        {
            HandleJumpLanding();
            if (Input.GetButtonDown("Jump"))
            {
                jump = true;
            }

            if (Input.GetButtonDown("Skill-1"))
            {
                if (CanPerformSkill())
                {
                    anim.SetTrigger("Punch");
                    StartDoublePunch();
                }
            }

            if (Input.GetButton("Skill-2"))
            {
                if (CanPerformSkill())
                {
                    preaching = true;
                    anim.SetBool("Preaching", true);
                    soundFx.StartDivineRaySound();
                }
            }
            else
            {
                preaching = false;
                StopPreach();
                anim.SetBool("Preaching", false);
            }
        }
        else
        {
            isInAir = true;
        }
    }