예제 #1
0
    public IEnumerator AttackCoroutine(Vector3 targetPosition, bool melee = false)
    {
        deadCharactersThisTurn = new List <CharacterBase>();
        infoBox.AttackText(main, other);
        yield return(new WaitForSecondsRealtime(attackPause));

        Vector3 oldPosition = main.transform.position;

        Tween tween = main.transform.DOMove(targetPosition, attackTweenTime).SetEase(easeType);

        yield return(tween.WaitForCompletion());

        Instantiate(hitEffect, other.transform.position, hitEffect.transform.rotation, other.transform);
        int  damage  = Calculator.GetDamage(main, other, attack);
        bool hasDied = other.SubtractHealth(damage);

        if (other.Faction == Faction.Player)
        {
            battleSystem.UpdateStats();
        }
        infoBox.DamageText(main, other, damage);
        yield return(new WaitForSecondsRealtime(returnDelay));

        if (melee)
        {
            yield return(StartCoroutine(CounterAttackCoroutine()));
        }

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

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

        yield return(KillCharacterCoroutine());

        battleSystem.NextTurn();
    }