Exemplo n.º 1
0
    public IEnumerator CounterAttackCoroutine()
    {
        List <CharacterBase> counterAttackers = Calculator.GetCounterAttackers(other);

        if (counterAttackers.Count == 0)
        {
            yield break;
        }
        bool hasDied = false;

        yield return(new WaitForSecondsRealtime(returnDelay));

        foreach (CharacterBase character in counterAttackers)
        {
            infoBox.CounterAttackText(character, main);
            yield return(new WaitForSecondsRealtime(attackPause));

            Vector3 oldPosition = character.transform.position;
            Tween   tween       = character.transform.DOMove(new Vector3(main.transform.position.x, main.transform.position.y, main.transform.position.z + 0.05f), attackTweenTime).SetEase(easeType);
            yield return(tween.WaitForCompletion());

            Instantiate(hitEffect, main.transform.position, hitEffect.transform.rotation, main.transform);
            int damage = Calculator.GetDamage(character, main, character.stats.normalAttack, true);
            hasDied = main.SubtractHealth(damage);
            if (main.Faction == Faction.Player)
            {
                battleSystem.UpdateStats();
            }
            infoBox.DamageText(character, main, damage);
            yield return(new WaitForSecondsRealtime(returnDelay));

            tween = character.transform.DOMove(oldPosition, attackTweenTime).SetEase(easeType);
            yield return(tween.WaitForCompletion());
        }

        if (hasDied)
        {
            deadCharactersThisTurn.Add(main);
        }
    }