Beispiel #1
0
    IEnumerator EnemyTurnCoroutine()
    {
        textDisplayObject.ClearText();
        yield return(new WaitForSeconds(0.5f));

        AttackData enemyAttack = enemy.GetRandomAttack();

        isHit = player.TakeAttack(enemyAttack.damage);

        egoText.text = player.ego.ToString();

        anim.SetBool("IsHit", isHit);
        anim.SetTrigger("EnemyAttack1");

        string attackText;

        if (!isHit)
        {
            attackText = "It missed!";
            AudioSource.PlayClipAtPoint(missSound, Camera.main.transform.position);
        }
        else
        {
            attackText = "It hit!";
            AudioSource.PlayClipAtPoint(attackSound, Camera.main.transform.position);
        }

        //textObject.text = string.Format ("{0} used {1}!\n{2}", enemy.data.name, enemyAttack.name, attackText);
        textDisplayObject.SetText(string.Format("{0} used {1}!\n{2}", enemy.data.name, enemyAttack.name, attackText));

        yield return(null);

        yield return(StartCoroutine(WaitForInput()));

        yield return(null);

        yield return(StartCoroutine(textDisplayObject.DisplayTextCoroutine(enemyAttack.dialog, enemy.color)));


        if (player.ego > 0f)
        {
            DisplayFightMenu();
        }
        else
        {
            player.Die();
            Defeat();
        }
    }