Beispiel #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float   left;
        float   up;
        Vector3 vtr3 = Vector3.zero;


        left = Input.GetAxis("Horizontal");
        up   = Input.GetAxis("Vertical");
        vtr3 = new Vector3(left, 0, up);
        hb.Move(vtr3);
        PressKey();
    }
Beispiel #2
0
    void CheckKeys()
    {
        float direction = Input.GetAxis("Horizontal");

        heroBody.Move(direction);

        if (Input.GetKeyDown(KeyCode.Space))
        {
            heroBody.Jump(direction);
        }

        if (canSlide)
        {
            if (Input.GetButtonDown("slide"))
            {
                if (direction > 0)
                {
                    direction = 1;
                }
                else if (direction < 0)
                {
                    direction = -1;
                }
                if (direction != 0)
                {
                    heroBody.Slide(direction);
                    canSlide = false;
                    Invoke("CanSlideAgain", 0.7f);
                }
            }
        }


        if (!heroBody.onAir)
        {
            canGlide = true;
        }
        if (heroBody.onAir && canGlide && Input.GetButtonDown("slide"))
        {
            heroBody.Glide();
            canGlide = false;
        }


        if (Input.GetButtonDown("swordAttack"))
        {
            if (canAttack)
            {
                heroBody.SwordAttack();
                canAttack = false;
                Invoke("CanAttackAgain", 0.3f);
            }
        }

        if (Input.GetButtonDown("kunaiThrow"))
        {
            if (canShoot)
            {
                if (heroBody.onAir)
                {
                    heroBody.AirKunaiThrow();
                }
                else
                {
                    heroBody.KunaiThrow();
                }

                canShoot = false;
                Invoke("CanShootAgain", 0.7f);
            }
        }
    }