Пример #1
0
    private IEnumerator PerformPlayerMove()
    {
        battleState = BattleState.Battle;
        var move = playerUnit.Pokemon.Moves[currentMoveIndex];

        yield return(dialogBox.TypeDialog($"{playerUnit.Pokemon.Base.Name} used {move.Base.Name}."));

        playerUnit.AttackAnimation();
        yield return(new WaitForSeconds(1.0f));

        enemy.enemyUnit.HitAnimation();

        var dmgInfo = enemy.enemyUnit.Pokemon.TakeDamage(move, playerUnit.Pokemon);

        yield return(enemyHud.UpdateHp());

        yield return(ShowDamageInfo(dmgInfo));

        if (dmgInfo.Faint)
        {
            yield return(dialogBox.TypeDialog($"{enemy.enemyUnit.Pokemon.Base.Name} fainted."));

            enemy.enemyUnit.FaintAnimation();
            AudioManager.instance.StopSound("BattleTheme");
            AudioManager.instance.PlaySound("Win");
        }
        else
        {
            StartCoroutine(PerformEnemyMove());
        }
    }