示例#1
0
    /*
     * Coroutine that attacks an enemy with a selected skill
     */
    private IEnumerator Skill(int i)
    {
        partyStats.SetSelectedDialog(i);
        Skill skill = thing[i] as Skill;
        EnemyBattleController ebc = target[i].GetComponent <EnemyBattleController>();

        // If the enemy is already dead choose another
        if (ebc.enemy.hp == 0)
        {
            EnemyBattleController[] others = FindObjectsOfType <EnemyBattleController>();
            foreach (EnemyBattleController e in others)
            {
                if (e.gameObject.activeSelf)
                {
                    ebc = e;
                    break;
                }
            }
        }

        // Hit the enemy if lives
        if (ebc.enemy.hp != 0)
        {
            GameController.dialogController.ShowBattleText(GameManager.party[i].fullname + " uses " + skill.skillName);
            while (DialogController.isTextShown)
            {
                yield return(null);
            }
            GameManager.party[i].sp -= skill.cost;
            partyStats.SetPartyStats();

            ebc.HitAnim();
            yield return(new WaitForSeconds(1.5f));

            int damage = GameController.CalculateDamage(GameManager.party[i], ebc.enemy, skill);
            ebc.enemy.TakeDamage(damage);
            StartCoroutine(ebc.ShowNumber(damage, Color.red));
            yield return(new WaitForSeconds(1));

            if (ebc.enemy.hp == 0)
            {
                xpGained   += ebc.enemy.xpDrop;
                goldGained += ebc.enemy.gold;
                DropItem(ebc.enemy);
                ebc.Kill();
            }
        }
        partyStats.SetDefaultDialog(i);
        finish = true;
    }
示例#2
0
    /*
     * Coroutine that attacks an enemy
     */
    private IEnumerator Attack(int i)
    {
        partyStats.SetSelectedDialog(i);
        EnemyBattleController ebc = target[i].GetComponent <EnemyBattleController>();

        // If the enemy is already dead choose another
        if (ebc.enemy.hp == 0)
        {
            EnemyBattleController[] others = FindObjectsOfType <EnemyBattleController>();
            foreach (EnemyBattleController e in others)
            {
                if (e.gameObject.activeSelf)
                {
                    ebc = e;
                    break;
                }
            }
        }

        // Hit the enemy if lives
        if (ebc.enemy.hp != 0)
        {
            ebc.HitAnim();
            yield return(new WaitForSeconds(1.5f));

            int damage = GameController.CalculateDamage(GameManager.party[i], ebc.enemy);
            ebc.enemy.TakeDamage(damage);
            StartCoroutine(ebc.ShowNumber(damage, Color.red));
            yield return(new WaitForSeconds(1));

            if (ebc.enemy.hp == 0)
            {
                xpGained   += ebc.enemy.xpDrop;
                goldGained += ebc.enemy.gold;
                DropItem(ebc.enemy);
                ebc.Kill();
            }
        }
        partyStats.SetDefaultDialog(i);
        finish = true;
    }