Beispiel #1
0
    public IEnumerator UseAbility(AbilityItem abilityItem, Character target)
    {
        Ability ability = abilityItem.ability;

        GamePlay.instance.LockButs();
        if (!ability.isPossibleUse(this, target))
        {
            createPopup("WRONG TARGET");
        }
        else
        {
            if (ability.PossibleTarget == PossibleTarget.Enemy)
            {
                Vector3 StartPos = transform.position;
                yield return(new WaitForSeconds(0.2f));

                anim.SetBool("Run", true);
                yield return(StartCoroutine(MoveTo(target.transform.position, 1.5f)));

                anim.SetBool("Run", false);
                yield return(new WaitForSeconds(0.2f));

                if (isEvil)
                {
                    anim.SetTrigger("EnemyAttack");
                }
                else
                {
                    anim.SetTrigger("Attack");
                }
                ability.AbilityUse(target);
                yield return(new WaitForSeconds(0.2f));

                anim.SetBool("Run", true);
                yield return(StartCoroutine(MoveTo(StartPos, 0.001f)));

                anim.SetBool("Run", false);
            }
            if (ability.PossibleTarget == PossibleTarget.Ally)
            {
                yield return(new WaitForSeconds(0.2f));

                anim.SetTrigger("Cast");
                yield return(new WaitForSeconds(0.2f));

                ability.AbilityUse(target);
                yield return(new WaitForSeconds(0.3f));
            }
            abilitiesCooldown();
            abilityItem.cooldown = ability.AbilityCooldown;
            GamePlay.instance.TURN();
        }
        GamePlay.instance.UnlockButs();
    }