Esempio n. 1
0
File: Dice.cs Progetto: chanmob/Dice
    private IEnumerator AttackCoroutine()
    {
        float soa = 1 / attackSpeed;

        while (true)
        {
            yield return(new WaitForSeconds(soa));

            Enemy e = InGameManager.instance.GetNearEnemy(pos);

            if (e != null)
            {
                Bullet b = ObjectPoolManager.instance.GetBullet();

                Color c;
                if (ColorUtility.TryParseHtmlString(InGameManager.instance.DiceColorHexCode[(int)diceType], out c))
                {
                    b.SetBulletColor(c);
                }

                if (mp >= MaxMP)
                {
                    SetMP(0);
                    b.AddAction(SkillAttack);
                }

                else
                {
                    SetMP(mp + perMP);
                    b.AddAction(Attack);
                }

                b.transform.position = transform.position;
                b.targetEnemy        = e;
                b.gameObject.SetActive(true);
            }
        }
    }