Exemplo n.º 1
0
    public void ShootBow(float speedX, float speedY)
    {
        if (speedX >= arrowMaxVelocity)
        {
            speedX = arrowMaxVelocity;
        }

        if (bowActive && !crouch && arrowsInQuiver > 0 && !dead && canStab)
        {
            canStab = false;
            StartCoroutine(SecondAttackDelay());
            animator.SetTrigger(shootForwardHash);
            GameObject arrow = Instantiate(arrowPrefab, arrowStartPoint.position, arrowStartPoint.transform.rotation);
            arrow.GetComponent <Rigidbody2D>().velocity = new Vector2(speedX * 2 * transform.right.x, -speedY * 2);
            arrowsInQuiver--;

            if (fireArrowsInQuiver > 0)
            {
                ArrowController arrowController = arrow.GetComponent <ArrowController>();
                arrowController.IncreaseDamage();
                arrowController.StartParticles();
                fireArrowsInQuiver--;
            }
        }
    }