Ejemplo n.º 1
0
 public void ReleaseSkill()
 {
     if (arrow != null)
     {
         LightArrow arrowScript = arrow.GetComponent <LightArrow>();
         arrowScript.SetReleased();
     }
     chargeTime         = 0f;
     bowRenderer.sprite = bowSprites[0];
     AudioManager.GetInstance().PlaySound(Sound.BowRelease);
     AudioManager.GetInstance().StopSound(Sound.Charge);
 }
Ejemplo n.º 2
0
    public void UseSkill(Transform hand)
    {
        // Get arrow if necessary
        if (chargeTime == 0f || arrow == null)
        {
            arrow = ObjectPooler.instance.GetDanmaku(arrowIndex);
            LightArrow arrowScript = arrow.GetComponent <LightArrow>();
            arrowScript.SetCharging();
            arrowScript.SetOwner(gameObject);
            arrow.SetActive(true);
            AudioManager.GetInstance().PlaySound(Sound.Charge);
        }

        // Set bow transform
        bow.transform.rotation = hand.transform.rotation;
        Vector3 bowPos = hand.TransformPoint(0.275f, 0, 0);

        bow.transform.position = bowPos;

        // charge bow
        chargeTime += Time.deltaTime;

        // Set bow charge
        int chargeLevel = Mathf.FloorToInt(chargeTime / 0.25f);

        if (chargeLevel >= bowSprites.Length)
        {
            chargeLevel = bowSprites.Length - 1;
        }
        bowRenderer.sprite = bowSprites[chargeLevel];

        // Set arrow charge level
        LightArrow arrowScriptAgain = arrow.GetComponent <LightArrow>();

        arrowScriptAgain.SetChargeLevel(chargeLevel);

        // set arrow position based on charge level
        arrow.transform.rotation = bow.transform.rotation;
        Vector3 arrowPos = bow.transform.TransformPoint(FindArrowOffset(chargeLevel), 0, 0);

        arrow.transform.position = arrowPos;
    }