// Update is called once per frame
    void Update()
    {
        //renderers[2].sprite = Resources.Load("capHead",typeof(Sprite)) as Sprite;

        Vector2 directonalInput = new Vector2(gamepadInput.GetLeftHorizontalValue(), 0);

        if (directonalInput.x > 0 && !isfacingRight)
        {
            changeDirection();
            isfacingRight = true;
        }

        if (directonalInput.x < 0 && isfacingRight)
        {
            changeDirection();
            isfacingRight = false;
        }

        if (directonalInput.x != 0 && controller.collisions.below)
        {
            animator.SetInteger("State", 1);
        }

        if (directonalInput.x == 0 && controller.collisions.below)
        {
            animator.SetInteger("State", 0);
        }

        if (!controller.collisions.below)
        {
            animator.SetInteger("State", 3);
        }

        if (!isDead && animator.GetCurrentAnimatorStateInfo(0).IsName("death") &&
            animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
        {
            foreach (var t in renderers)
            {
                t.enabled = false;
            }
            if (isfacingRight)
            {
                isfacingRight = false;
                changeDirection();
            }
            renderers[renderers.Length - 2].enabled = true;
            isDead = true;
        }
    }
Esempio n. 2
0
    void Update()
    {
        Vector2 directionalInput = new Vector2(gamepadInput.GetLeftHorizontalValue(), 0);

        player.SetDirectionalInput(directionalInput);

        if (gamepadInput.IsJumpPressed())
        {
            player.OnJumpInputDown();
        }
        if (gamepadInput.IsJumpReleased())
        {
            player.OnJumpInputUp();
        }
    }