示例#1
0
    // Update is called once per frame
    public void PlayerUpdate()
    {
        if (VerticalVelocity > 0 || pb.Keys.Vertical() < -0.8)
        {
            gameObject.layer = 11;
        }
        else if (gameObject.layer == 11)
        {
            gameObject.layer = 8;
        }

        TrackGrounded();

        LerpingKnockBack();
        sliding = (CheckSide(Direction.Left) || CheckSide(Direction.Right)) && !CheckSide(Direction.Bottom);
        pb.animator.SetBool("IsSliding", sliding);


        pb.animator.SetBool("IsRunning", Mathf.Abs(pb.Keys.Horizontal()) > 0.1f && !pb.CanNotMove);

        pb.animator.SetBool("IsGrounded", CheckSide(Direction.Bottom));

        pb.animator.SetInteger("JumpsLeft", jumpsLeft);

        var atDir = 0;

        if (pb.Keys.Vertical() > 0.5f)
        {
            atDir = 2;
        }
        else if (pb.Keys.Vertical() < -0.5f)
        {
            atDir = 3;
        }
        else if (Mathf.Abs(pb.Keys.Horizontal()) > 0.5f)
        {
            atDir = 1;
        }
        pb.animator.SetInteger("AttackDirection", atDir);

        pb.CheckWithinArena();
        UpdateFaceDirection();


        VerticalVelocityMin = sliding ? pb.currentCharacter.maxGravity / 13 : pb.currentCharacter.maxGravity;


        if (VerticalVelocity > -VerticalVelocityMin)
        {
            VerticalVelocity -= pb.currentCharacter.gravitySpeed * Time.deltaTime;
        }
        else
        {
            VerticalVelocity = -VerticalVelocityMin;
        }


        controlUpdate();
    }