Esempio n. 1
0
    IEnumerator ShootWasteCardCR()
    {
        if (AccumulatedCards > 0)
        {
            Time.timeScale = 0.2f;
            GameObject cannon = CurrentPlayer.PlayerAvatar.GetRandomCannon;
            yield return(ShootCannonCR(cannon, uiAccumulatedCardsGo.transform));

            AudioSource audio = AccumulatedCardsLightingBolt.GetComponent <AudioSource>();
            AccumulatedCardsLightingBolt.Play();
            audio.Play();

            Fireball fireball = Instantiate(FireballPrefab, uiAccumulatedCardsGo.transform, false);
            fireball.Initialize(cannon.transform);
            AudioSourceCannon.Play();
            yield return(new WaitForFireball(fireball));

            AudioPlayExplosion();

            AccumulatedCards = 0;

            yield return(new WaitForSeconds(0.5f));

            Time.timeScale = 1f;
        }
        else
        {
            yield return(ShootCannonCR(CurrentPlayer, WasteCard.transform));

            yield return(AddCardToGraveyardCR(WasteCard));

            yield return(RemoveTopWasteCard());
        }
    }
Esempio n. 2
0
    IEnumerator ShootCannonCR(GameObject cannon, Transform target)
    {
        Vector3 dir   = target.position - cannon.transform.position;
        float   angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;

        cannon.transform.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);

        if (cannon != null)
        {
            Fireball fireball = Instantiate(FireballPrefab, cannon.transform, false);
            fireball.Initialize(target);
            AudioSourceCannon.Play();
            yield return(new WaitForFireball(fireball));
        }
    }