Esempio n. 1
0
 void Start()
 {
     anim  = GetComponent <Animator> ();
     bs    = Battlestate.None;
     rigid = GetComponent <Rigidbody> ();
     //	equipholder = GameObject.Find ("EquipHolder");
     //weapon = equipholder.GetComponentInChildren<sowd> ();
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        float v = Input.GetAxis("Vertical");            // 上下のキー入力を取得
        float h = Input.GetAxis("Horizontal");          // 左右のキー入力を取得

        Vector3 forward = transform.TransformDirection(Vector3.forward);
        Vector3 right   = transform.TransformDirection(Vector3.right);


        moveDirection = h * right + v * forward;

        playerDir = moveDirection * speed * 0.7f;

        moveDirection *= speed;
        anim.SetFloat("x", h);
        anim.SetFloat("z", v);

        /*
         * if (playerDir.magnitude > 0.1f) {
         *      Quaternion q = Quaternion.LookRotation (playerDir);			// 向きたい方角をQuaternionn型に直す .
         *      transform.rotation = Quaternion.RotateTowards (transform.rotation, q, rotationSpeed * Time.deltaTime);	// 向きを q に向けてじわ~っと変化させる.
         * }
         */

        //moveDirection.y -= gravity * Time.deltaTime;

        rigid.velocity += moveDirection;


        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Jump");
            //moveDirection.y += jumpSpeed;
            rigid.AddForce(transform.up * jumpSpeed);
        }



        if (Physics.Raycast(transform.position + (Vector3.up * 0.1f), Vector3.down, out hit, 0.2f))
        {
            isGround = true;
        }
        else
        {
            isGround = false;
        }



        if (!isGround)
        {
            rigid.AddForce(Physics.gravity * 10);
        }


        if (Input.GetKey("d"))
        {
            rigid.AddForce(moveDirection * dashSpeed);
            anim.SetBool("Dash", true);
        }

        if (Input.GetKeyUp("d"))
        {
            rigid.velocity = Vector3.zero;
            anim.SetBool("Dash", false);
        }


        if (Input.GetKeyDown("k"))
        {
            if (canCombo)
            {
                anim.SetTrigger("Combo");
                //bs = Battlestate.Combo;
                anim.SetFloat("attack", 1.0f);
                //isCombo = true;
            }
            else
            {
                //	bs = Battlestate.Attack;
                anim.SetTrigger("Attack");
            }
            anim.SetFloat("attack", 1.0f);
        }

        if (Input.GetKeyDown("l"))
        {
            anim.SetFloat("attack", -1.0f);
            StartCoroutine(CanselAnim());
        }


        if (Input.GetKey("p"))
        {
            anim.SetBool("parry", true);
            isparry = true;
        }
        else
        {
            anim.SetBool("parry", false);
            isparry = false;
        }


        if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack"))
        {
            canMove  = false;
            canCombo = true;
        }
        else
        {
            canMove  = false;
            canCombo = false;
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Move"))
        {
            isCombo = false;
            bs      = Battlestate.Normal;
            //anim.SetFloat ("attack",0);
            //	anim.SetFloat ("ComboAttack",0);
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsTag("Attack") && anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.98f)
        {
            //anim.SetFloat ("attack",0);
            anim.ResetTrigger("Attack");

            //anim.SetFloat ("ComboAttack", 0);
        }
    }