示例#1
0
    IEnumerator PlayerAttack()
    {
        playerUnit.Attack();
        yield return(new WaitForSeconds(1f));

        bool isDead = enemyUnit.TakeDamage(playerUnit.damage);

        enemyHUD.SetHP(enemyUnit.currentHP);
        dialogueText.text = "The attack is successful!";

        yield return(new WaitForSeconds(1f));

        if (isDead)
        {
            State = BattleState.WON;
            EndBattle();
        }
        else
        {
            State = BattleState.ENEMY_TURN;
            StartCoroutine(EnemyTurn());
        }
    }
示例#2
0
    private IEnumerator EnemyTurn()
    {
        dialogueText.text = "\"" + enemyUnit.unitName + "\" attacks!";

        enemyUnit.Attack();
        yield return(new WaitForSeconds(1f));

        bool isDead = playerUnit.TakeDamage(enemyUnit.damage);

        playerHUD.SetHP(playerUnit.currentHP);

        yield return(new WaitForSeconds(1f));

        if (isDead)
        {
            State = BattleState.LOST;
            EndBattle();
        }
        else
        {
            State = BattleState.PLAYER_TURN;
            PlayerTurn();
        }
    }