Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        direction.x = Input.GetAxisRaw("Horizontal");
        direction.y = Input.GetAxisRaw("Vertical");

        playerAnim.SetFloat("Speed", Mathf.Abs(direction.x) + Mathf.Abs(direction.y));

        Vector2 dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);

        if (dir.x > 0 && !facingRight || dir.x < 0 && facingRight)
        {
            Flip();
        }

        if (Input.GetMouseButtonDown(0))
        {
            bow.Shoot();
        }

        if (recovering)
        {
            recoveryCounter += Time.deltaTime;

            if (recoveryCounter >= recoveryTime)
            {
                recoveryCounter = 0;
                recovering      = false;
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        // Le o comando do teclado (WASD e/ou as setas)
        direction.x = Input.GetAxisRaw("Horizontal");
        direction.y = Input.GetAxisRaw("Vertical");

        // Passa o parametro para o animator para fazer o controle das animacoes
        playerAnim.SetFloat("Speed", Mathf.Abs(direction.x) + Mathf.Abs(direction.y));

        // Faz o controle de rotacao do player (virado para a esquerda ou direita)
        Vector2 dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);

        if (dir.x > 0 && !facingRight || dir.x < 0 && facingRight)
        {
            Flip();
        }

        // Le o clique do mouse
        if (Input.GetMouseButtonDown(0))
        {
            // Chama a funcao de atirar, que esta no script do arco
            bow.Shoot();
        }

        // Rotina de cooldown de levar dano
        if (recovering)
        {
            recoveryCounter += Time.deltaTime;
            if (recoveryCounter >= recoveryTime)
            {
                recoveryCounter = 0;
                recovering      = false;
            }
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        direction.x = Input.GetAxisRaw("Horizontal");
        direction.y = Input.GetAxisRaw("Vertical");

        if (Input.GetMouseButtonDown(0))
        {
            bow.Shoot();
        }
    }
Esempio n. 4
0
    private void UpdateAttackRangeHeavy()
    {
        if (_heavyAttack && !_bowScript.gameObject.activeSelf)
        {
            _bowScript.gameObject.SetActive(true);
            _bowScript.ChargeShot();
            anim.SwitchMode(HeroMode.Aim);
        }
        else if (_heavyAttackRelease && _bowScript.gameObject.activeSelf)
        {
            _bowScript.Shoot();
            _bowScript.gameObject.SetActive(false);
        }

        anim.UpdateDirection(ShootingDirection);
        anim.UpdateSlashDirection(ShootingDirection);
    }