public override IEnumerator StartMyActivationCoroutine() { Ability rockToss = mySpellBook.GetAbilityByName("Rock Toss"); Ability move = mySpellBook.GetAbilityByName("Move"); ActionStart: while (EventManager.Instance.gameOverEventStarted) { yield return(null); } if (EntityLogic.IsAbleToTakeActions(this) == false) { LivingEntityManager.Instance.EndEntityActivation(this); } // Rock Toss else if (EntityLogic.IsTargetInRange(this, EntityLogic.GetClosestEnemy(this), rockToss.abilityRange) && EntityLogic.IsAbilityUseable(this, rockToss) ) { SetTargetDefender(EntityLogic.GetClosestEnemy(this)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Can't do anything more, end activation else { LivingEntityManager.Instance.EndEntityActivation(this); } }
public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); ActionStart: while (EventManager.Instance.gameOverEventStarted) { yield return(null); } SetTargetDefender(EntityLogic.GetClosestValidEnemy(this)); if (EntityLogic.IsAbleToTakeActions(this) == false) { LivingEntityManager.Instance.EndEntityActivation(this); } // Strike else if (EntityLogic.IsAbilityUseable(this, strike) && EntityLogic.IsTargetInRange(this, myCurrentTarget, currentMeleeRange)) { 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, currentMeleeRange) == false && EntityLogic.IsAbleToMove(this) && EntityLogic.CanPerformAbilityTwoAfterAbilityOne(move, strike, this) && EntityLogic.IsAbilityUseable(this, move) && EntityLogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, EntityLogic.GetTotalMobility(this)) != null) { SetTargetDefender(EntityLogic.GetClosestEnemy(this)); 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); } }
public void ChooseRandomTargetingLogic() { Debug.Log("ChooseRandomTargetingLogic() called..."); int randomNumber = Random.Range(0, 2); if (randomNumber == 0) { SetTargetDefender(EntityLogic.GetClosestEnemy(this)); } else { SetTargetDefender(EntityLogic.GetEnemyWithLowestCurrentHP(this)); } Debug.Log("ChooseRandomTargetingLogic() set target as: " + myCurrentTarget.name); }
public override IEnumerator StartMyActivationCoroutine() { Ability move = mySpellBook.GetAbilityByName("Move"); Ability siphonLife = mySpellBook.GetAbilityByName("Siphon Life"); Ability twinStrike = mySpellBook.GetAbilityByName("Twin Strike"); Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability dash = mySpellBook.GetAbilityByName("Dash"); ChooseRandomTargetingLogic(); ActionStart: while (EventManager.Instance.gameOverEventStarted) { yield return(null); } if (myCurrentTarget.currentHealth <= 0 || myCurrentTarget == null) { ChooseRandomTargetingLogic(); } if (EntityLogic.IsAbleToTakeActions(this) == false) { LivingEntityManager.Instance.EndEntityActivation(this); } // Siphon Life else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, siphonLife.abilityRange) && EntityLogic.IsAbilityUseable(this, siphonLife) ) { //SetTargetDefender(GetClosestDefender()); VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Siphon Life"); yield return(new WaitForSeconds(0.5f)); //Action slAction = AbilityLogic.Instance.PerformSiphonLife(this, myCurrentTarget); // yield return new WaitUntil(() => slAction.ActionResolved() == true); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // If unable to siphon life the ideal target, siphon the closest valid target else if (EntityLogic.IsTargetInRange(this, EntityLogic.GetClosestEnemy(this), siphonLife.abilityRange) && EntityLogic.IsAbilityUseable(this, siphonLife) ) { SetTargetDefender(EntityLogic.GetClosestEnemy(this)); VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Siphon Life"); yield return(new WaitForSeconds(0.5f)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Twin Strike else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, currentMeleeRange) && EntityLogic.IsAbilityUseable(this, twinStrike)) { //SetTargetDefender(GetDefenderWithLowestCurrentHP()); VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Twin Strike"); yield return(new WaitForSeconds(0.5f)); Action twinStrikeAction = AbilityLogic.Instance.PerformTwinStrike(this, myCurrentTarget); yield return(new WaitUntil(() => twinStrikeAction.ActionResolved() == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, currentMeleeRange) && EntityLogic.IsAbilityUseable(this, strike)) { //SetTargetDefender(GetDefenderWithLowestCurrentHP()); VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike"); yield return(new WaitForSeconds(0.5f)); Action strikeAction = AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); yield return(new WaitUntil(() => strikeAction.ActionResolved() == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Dash else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, currentMeleeRange) == false && EntityLogic.IsAbleToMove(this) && EntityLogic.IsAbilityUseable(this, dash) && EntityLogic.CanPerformAbilityTwoAfterAbilityOne(dash, strike, this) && EntityLogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, dash.abilityPrimaryValue) != null ) { VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Dash"); yield return(new WaitForSeconds(0.5f)); Tile destination = EntityLogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, dash.abilityPrimaryValue); Action dashAction = AbilityLogic.Instance.PerformDash(this, destination); yield return(new WaitUntil(() => dashAction.ActionResolved() == true)); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (EntityLogic.IsTargetInRange(this, myCurrentTarget, currentMeleeRange) == false && EntityLogic.IsAbleToMove(this) && EntityLogic.IsAbilityUseable(this, move) && EntityLogic.CanPerformAbilityTwoAfterAbilityOne(move, strike, this) && EntityLogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, EntityLogic.GetTotalMobility(this)) != null ) { VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move"); yield return(new WaitForSeconds(0.5f)); 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); } }