Esempio n. 1
0
    private void ShootArrow()
    {
        if (levelManager.getArrowCount(arrowType) > 0)
        {
            GameObject arrowInstance;
            if (arrowType == LevelManager.ArrowType.normal)
            {
                arrowInstance = Instantiate(arrowPrefab);
            }
            else
            {
                arrowInstance = Instantiate(iceArrowPrefab);
            }
            audioSource.Play();
            arrowInstance.transform.position = transform.position + transform.right * initialArrowOffset;
            arrowInstance.transform.rotation = transform.rotation;
            Rigidbody2D arrowRb = arrowInstance.GetComponent <Rigidbody2D>();
            arrowRb.AddForce(arrowInstance.transform.right * shootForce);

            levelManager.AddFlyingArrow(arrowType);

            displayArrow();
        }
    }