public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability healingLight = mySpellBook.GetAbilityByName("Healing Light"); Ability chaosBolt = mySpellBook.GetAbilityByName("Chaos Bolt"); Ability invigorate = mySpellBook.GetAbilityByName("Invigorate"); ActionStart: SetTargetDefender(EntityLogic.GetBestTarget(this, true)); while (EventManager.Instance.gameOverEventStarted) { yield return(null); } if (EntityLogic.IsAbleToTakeActions(this) == false) { LivingEntityManager.Instance.EndEntityActivation(this); } // Healing Light else if (EntityLogic.IsTargetInRange(this, GetBestHealingLightTarget(), healingLight.abilityRange) && GetBestHealingLightTarget().currentHealth < GetBestHealingLightTarget().currentMaxHealth&& EntityLogic.IsAbilityUseable(this, healingLight, GetBestHealingLightTarget())) { Action action = AbilityLogic.Instance.PerformHealingLight(this, GetBestHealingLightTarget()); yield return(new WaitUntil(() => action.ActionResolved() == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Invigorate else if (EntityLogic.IsTargetInRange(this, EntityLogic.GetBestInvigorateTarget(this), invigorate.abilityRange) && EntityLogic.IsAbilityUseable(this, invigorate, EntityLogic.GetBestInvigorateTarget(this))) { Action action = AbilityLogic.Instance.PerformInvigorate(this, EntityLogic.GetBestInvigorateTarget(this)); yield return(new WaitUntil(() => action.ActionResolved() == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Chaos Bolt else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, chaosBolt.abilityRange) && EntityLogic.IsAbilityUseable(this, chaosBolt, myCurrentTarget)) { Action action = AbilityLogic.Instance.PerformChaosBolt(this, myCurrentTarget); yield return(new WaitUntil(() => action.ActionResolved() == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, currentMeleeRange) && EntityLogic.IsAbilityUseable(this, strike, myCurrentTarget)) { Action action = AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); yield return(new WaitUntil(() => action.ActionResolved() == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, chaosBolt.abilityRange) == false && EntityLogic.IsAbleToMove(this) && EntityLogic.CanPerformAbilityTwoAfterAbilityOne(move, chaosBolt, this) && EntityLogic.IsAbilityUseable(this, move) && EntityLogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, EntityLogic.GetTotalMobility(this)) != null ) { Tile destination = EntityLogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, EntityLogic.GetTotalMobility(this)); Action movementAction = AbilityLogic.Instance.PerformMove(this, destination); yield return(new WaitUntil(() => movementAction.ActionResolved() == true)); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } // Can't do anything more, end activation else { LivingEntityManager.Instance.EndEntityActivation(this); } }