public IEnumerator FireSpell(DataPlayerChange manaBar)
    {
        if (counterSpell == 0)
        {
            if (manaBar.GetMana() >= 30)
            {
                playerAnimator.SetBool("Spell", true);
                manaBar.UseMana(30);
                counterSpell = 1;
                yield return(new WaitForSeconds(0.7f));

                playerAnimator.SetBool("Spell", false);
                if (!playerSprite.flipX)
                {
                    Instantiate(fireSpellRight, spawnFireBallRight.position, spawnFireBallRight.rotation);
                }
                else
                {
                    Instantiate(fireSpellLeft, spawnFireBallLeft.position, spawnFireBallLeft.rotation);
                }
                yield return(new WaitForSeconds(3f));

                counterSpell = 0;
            }
        }
    }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.CompareTag("Player"))
        {
            DataPlayerChange manaHealthBar = player.GetComponent <DataPlayerChange>();
            playerAnimator.SetBool("Spell", true);
            manaHealthBar.UseMana(50);
            manaHealthBar.AddHealth(30);

            if (manaHealthBar.GetHealth() > 100)
            {
                manaHealthBar.ResetHealth();
            }
            playerAnimator.SetBool("Spell", false);
        }
    }