示例#1
0
文件: Player.cs 项目: AbbaVaR/2D_Game
    private void Normal()
    {
        anim.SetBool("Tired", false);
        IsGrounded = Physics2D.OverlapCircle(groundCheck.position, GroundRadius, whatIsGround);
        anim.SetBool("Grounded", IsGrounded);
        //движение
        float moveX = Input.GetAxis("Horizontal");

        anim.SetFloat("Speed", Mathf.Abs(moveX));
        if (!Blocking)
        {
            rb.velocity = new Vector2(moveX * Speed, rb.velocity.y);
        }
        if (moveX > 0 && !IsFacingRight && !Blocking)
        {
            Flip();
        }
        else if (moveX < 0 && IsFacingRight && !Blocking)
        {
            Flip();
        }
        //прыжок
        if (IsGrounded && Input.GetButtonDown("Jump") && !Blocking)
        {
            anim.SetBool("Grounded", false);
            //rb.AddForce(Vector2.up * JumpForce);
            rb.AddForce(Vector2.up * JumpForce, ForceMode2D.Impulse);
        }
        //атака
        if (Input.GetButtonDown("Fire1"))
        {
            SPDamage(30);
            anim.SetBool("Attacking", true);
            Fight.Action(attackCheck.position, AttackRadius, 9, PlayerD, false);
        }

        else
        {
            anim.SetBool("Attacking", false);
        }
        //блок

        if (Input.GetButton("Fire2"))
        {
            Blocking = true;
            anim.Play("Player_block");
        }
        if (Input.GetButtonUp("Fire2"))
        {
            Blocking = false;
            anim.Play("Player_idle");
        }


        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            LoadCharacter();
        }
    }