public override IEnumerator ExecuteAction(FightingEntity user, List <FightingEntity> targets, BattleFight battleFight) { _battleFight = battleFight; FightResult result = new FightResult(user, this); if (CheckCost(user)) { PayCost(user); targets = GetAllPossibleActiveTargets(user); Vector3 userStartingPos = user.transform.position; // Slide in if (animation != null && animation.slideType != SlideType.NONE) { yield return(GameManager.Instance.time.GetController().StartCoroutine(animation.SlideIn(user, targets))); } List <FightingEntity> potentialTargets = targets; for (int i = 0; i < _numHits; i++) { potentialTargets = targets.Filter(target => target != null); if (potentialTargets.Count == 0) { break; } List <FightingEntity> currTargets = SetTargets(user, targets); // Play animation GameManager.Instance.time.GetController().StartCoroutine(animation.AnimateAction(user, currTargets)); yield return(GameManager.Instance.time.GetController().WaitForSeconds(animation.GetAnimWindup(false))); result = ApplyEffect(user, currTargets); OnPostEffect(result); _battleFight.EndFight(result, this); yield return(GameManager.Instance.time.GetController().WaitForSeconds(animation.GetAnimCooldown(false))); } // Slide back if (animation != null && animation.slideType != SlideType.NONE) { yield return(GameManager.Instance.time.GetController().StartCoroutine(animation.Slide(user.transform, user.transform.position, userStartingPos))); } } }
public override IEnumerator ExecuteAction(FightingEntity user, List <FightingEntity> targets, BattleFight battleFight) { _battleFight = battleFight; FightResult result = new FightResult(user, this); if (CheckCost(user)) { PayCost(user); ActionBase selectedAction = _actions[Random.Range(0, _actions.Length)]; targets = selectedAction.GetNewTargets(user); // Play animation yield return(GameManager.Instance.time.GetController().StartCoroutine(selectedAction.PlayAnimation(user, targets))); result = selectedAction.ApplyEffect(user, targets); OnPostEffect(result); _battleFight.EndFight(result, this); yield return(GameManager.Instance.time.GetController().WaitForSeconds(selectedAction.animation.GetAnimCooldown())); } }
public virtual IEnumerator ExecuteAction(FightingEntity user, List <FightingEntity> targets, BattleFight battleFight) { _battleFight = battleFight; FightResult result = new FightResult(user, this); Coroutine animationCor = null; if (CheckCost(user)) { PayCost(user); targets = SetTargets(user, targets); // Play animation yield return(GameManager.Instance.time.GetController().StartCoroutine(PlayAnimation(user, targets))); result = ApplyEffect(user, targets); OnPostEffect(result); _battleFight.EndFight(result, this); if (animation != null) { yield return(GameManager.Instance.time.GetController().WaitForSeconds(animation.GetAnimCooldown())); } } }