Example #1
0
    IEnumerator EnemyMove()
    {
        state = BattleState.EnemyMove;

        for (int i = 0; i < ghostTarget.Count; i++)
        {
            //-------------------------------------Ghost Move-------------------------------------------
            var move = ghostTarget[i].Ghost.getRandomMove();
            audioSource.PlayOneShot(move.Base.getAudio());
            //AOE or Single
            if (move.Base.getTargetType() == targetType.Enemy || move.Base.getTargetType() == targetType.Aoe)
            {
                state = BattleState.Busy;
                player.PlayHitAnimation();
                int dmg = ghostTarget[i].Ghost.GiveDmg(move.Base);
                dialogueBox.ActivateDialogue();
                yield return(dialogueBox.TypeDialogue($"{ghostTarget[i].Ghost.Base.getName()} menggunakan {move.Base.getMoveName()} sebesar {dmg.ToString()} Damage"));
            }

            if (move.Base.getTargetType() == targetType.Self)
            {
                state = BattleState.Busy;
                int heal = ghostTarget[i].Ghost.GiveHeal(move.Base);
                dialogueBox.ActivateDialogue();
                yield return(dialogueBox.TypeDialogue($"{ghostTarget[i].Ghost.Base.getName()} menggunakan {move.Base.getMoveName()} dan pulih sebesar {heal.ToString()} HP"));
            }

            //-------------------------------------Ghost Move-------------------------------------------

            state = BattleState.EnemyMove;
            playerHud.UpdateUI();
            ghostTarget[i].GetComponent <BattleHud>().UpdateUI(ghostTarget[i].Ghost);
            yield return(new WaitForSeconds(waitDialogue));
        }

        if (PlayerStat.health <= 0)
        {
            dialogueBox.ActivateDialogue();
            yield return(dialogueBox.TypeDialogue("Dara gagal menyelamatkan sekolah!"));

            onBattleOver(false, 0);
        }

        state = BattleState.PlayerBattle;
        ghostTarget[currentChooseTarget].GetComponent <BattleHud>().DeactivateTarget();
        playerHud.Fight();
        playerHud.CloseSkill();
        ghostTarget[currentChooseTarget].gameObject.GetComponent <BattleHud>().DeactivateTarget();
        currentChooseTarget = 0;
    }