public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability layBroodlingEgg = mySpellBook.GetAbilityByName("Lay Broodling Egg"); ActionStart: SetTargetDefender(GetClosestDefender()); if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Lay Broodling Egg else if (HasEnoughAP(currentAP, layBroodlingEgg.abilityAPCost) && IsAbilityOffCooldown(layBroodlingEgg.abilityCurrentCooldownTime)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Lay Broodling Egg", false)); yield return(new WaitForSeconds(0.5f)); Action layEgg = AbilityLogic.Instance.PerformLayBroodlingEgg(this); yield return(new WaitUntil(() => layEgg.actionResolved == true)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (IsTargetInRange(myCurrentTarget, currentMeleeRange) && HasEnoughAP(currentAP, strike.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (IsTargetInRange(myCurrentTarget, currentMeleeRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, currentMobility); Action action = AbilityLogic.Instance.PerformMove(this, destination); yield return(new WaitUntil(() => action.ActionResolved() == true)); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability charge = mySpellBook.GetAbilityByName("Charge"); Ability whirlwind = mySpellBook.GetAbilityByName("Whirlwind"); ActionStart: SetTargetDefender(GetClosestDefender()); // below line used later to prevent charging this is already in melee with List <TileScript> tilesInMyMeleeRange = LevelManager.Instance.GetTilesWithinRange(currentMeleeRange, TileCurrentlyOn); if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Charge else if (IsAbilityOffCooldown(charge.abilityCurrentCooldownTime) && IsTargetInRange(myCurrentTarget, charge.abilityRange) && HasEnoughAP(currentAP, charge.abilityAPCost) && tilesInMyMeleeRange.Contains(myCurrentTarget.TileCurrentlyOn) == false && IsAbleToMove() ) { TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, charge.abilityRange); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Charge", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformCharge(this, myCurrentTarget, destination); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Whirlwind else if (IsTargetInRange(myCurrentTarget, currentMeleeRange) && HasEnoughAP(currentAP, whirlwind.abilityAPCost) && IsAbilityOffCooldown(whirlwind.abilityCurrentCooldownTime)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Whirlwind", false)); yield return(new WaitForSeconds(1f)); AbilityLogic.Instance.PerformWhirlwind(this); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (IsTargetInRange(myCurrentTarget, currentMeleeRange) && HasEnoughAP(currentAP, strike.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (IsTargetInRange(myCurrentTarget, currentMeleeRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability fireBall = mySpellBook.GetAbilityByName("Fire Ball"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability frostBolt = mySpellBook.GetAbilityByName("Frost Bolt"); ActionStart: if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Frost Bolt else if (IsTargetInRange(GetClosestDefender(), frostBolt.abilityRange) && HasEnoughAP(currentAP, frostBolt.abilityAPCost) && IsAbilityOffCooldown(frostBolt.abilityCurrentCooldownTime) ) { SetTargetDefender(GetClosestDefender()); // VFX notification StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Frost Bolt", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformFrostBolt(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Fireball the most vulnerable target else if (IsTargetInRange(GetMostVulnerableDefender(), fireBall.abilityRange) && GetMostVulnerableDefender().isKnockedDown&& HasEnoughAP(currentAP, fireBall.abilityAPCost) && IsAbilityOffCooldown(fireBall.abilityCurrentCooldownTime)) { SetTargetDefender(GetMostVulnerableDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Fire Ball", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformFireBall(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Fireball the target with lowest current HP else if (IsTargetInRange(GetDefenderWithLowestCurrentHP(), fireBall.abilityRange) && HasEnoughAP(currentAP, fireBall.abilityAPCost) && IsAbilityOffCooldown(fireBall.abilityCurrentCooldownTime)) { SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Fire Ball", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformFireBall(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Fireball the closest target if the most vulnerable and the weakest cant be targetted else if (IsTargetInRange(GetClosestDefender(), fireBall.abilityRange) && HasEnoughAP(currentAP, fireBall.abilityAPCost) && IsAbilityOffCooldown(fireBall.abilityCurrentCooldownTime)) { SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Fire Ball", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformFireBall(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if ( IsTargetInRange(GetClosestDefender(), fireBall.abilityRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost) ) { SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, fireBall.abilityRange, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability invigorate = mySpellBook.GetAbilityByName("Invigorate"); Ability healingLight = mySpellBook.GetAbilityByName("Healing Light"); /* AI LOGIC * if invigorate ready, invigorate * Find the closest wounded ally * if heal ready and wounded ally in range, heal. * If closest wounded ally is not in range and move ready, move towards them. * Check if all allies are at full hp * GetClosestAlly(dont include self) * If all allies are at full health, and move ready, move towards ally * will try to move adjacent to an ally to give the protector bonus. * If no allies are in range to move next to, it will try to move into a grass tile. * If no grass tile is within range, it will stand still. * Only attacks enemies with strike if all allies are dead, and will target the closest enemy. */ ActionStart: if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Invigorate else if (IsTargetInRange(GetBestInvigorateTarget(invigorate.abilityRange), invigorate.abilityRange) && IsAbilityOffCooldown(invigorate.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, invigorate.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Invigorate", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformInvigorate(this, GetBestInvigorateTarget(invigorate.abilityRange)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Healing Light else if (IsTargetInRange(GetBestHealingLightTarget(), healingLight.abilityRange) && GetBestHealingLightTarget().currentHealth < GetBestHealingLightTarget().currentMaxHealth&& IsAbilityOffCooldown(healingLight.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, healingLight.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Healing Light", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformHealingLight(this, GetBestHealingLightTarget()); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move towards an ally to give Encouraging presence bonus else if (GetClosestFriendlyTarget() != this && IsTargetInRange(GetClosestFriendlyTarget(), currentMobility) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost) && IsAbilityOffCooldown(move.abilityCurrentCooldownTime) ) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, GetClosestFriendlyTarget(), 1, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (IsTargetInRange(GetClosestDefender(), currentMeleeRange) && HasEnoughAP(currentAP, strike.abilityAPCost) && IsAbilityOffCooldown(strike.abilityCurrentCooldownTime)) { SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability doom = mySpellBook.GetAbilityByName("Doom"); Ability whirlwind = mySpellBook.GetAbilityByName("Whirlwind"); Ability crushingBlow = mySpellBook.GetAbilityByName("Crushing Blow"); ActionStart: if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Doom else if (IsAbilityOffCooldown(doom.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, doom.abilityAPCost) ) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Doom", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformDoom(this); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Crushing Blow else if (IsTargetInRange(GetClosestDefender(), currentMeleeRange) && HasEnoughAP(currentAP, crushingBlow.abilityAPCost) && IsAbilityOffCooldown(crushingBlow.abilityCurrentCooldownTime)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Crushing Blow", false)); yield return(new WaitForSeconds(0.6f)); AbilityLogic.Instance.PerformCrushingBlow(this, GetClosestDefender()); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // try to move to a position that we can hit two or more enemies with a whirlwind from else if ( IsAdjacentToTwoOrMoreDefenders() == false && GetClosestValidTileThatHasTwoAdjacentDefenders() != null && LevelManager.Instance.GetTilesWithinRange(currentMobility, TileCurrentlyOn).Contains(GetClosestValidTileThatHasTwoAdjacentDefenders()) && HasEnoughAP(currentAP, move.abilityAPCost) && IsAbilityOffCooldown(whirlwind.abilityCurrentCooldownTime) ) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformMove(this, GetClosestValidTileThatHasTwoAdjacentDefenders()); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } // Whirlwind else if (IsTargetInRange(GetClosestDefender(), currentMeleeRange) && HasEnoughAP(currentAP, whirlwind.abilityAPCost) && IsAbilityOffCooldown(whirlwind.abilityCurrentCooldownTime)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Whirlwind", false)); yield return(new WaitForSeconds(1f)); AbilityLogic.Instance.PerformWhirlwind(this); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (IsTargetInRange(GetClosestDefender(), currentMeleeRange) && HasEnoughAP(currentAP, strike.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformStrike(this, GetClosestDefender()); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (IsTargetInRange(GetClosestDefender(), currentMeleeRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost)) { SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability move = mySpellBook.GetAbilityByName("Move"); Ability siphonLife = mySpellBook.GetAbilityByName("Siphon Life"); Ability twinStrike = mySpellBook.GetAbilityByName("Twin Strike"); Ability teleport = mySpellBook.GetAbilityByName("Teleport"); Ability fireBall = mySpellBook.GetAbilityByName("Fire Ball"); ChooseRandomTargetingLogic(); ActionStart: if (myCurrentTarget.currentHealth <= 0 || myCurrentTarget == null) { ChooseRandomTargetingLogic(); } if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Siphon Life else if (IsAbilityOffCooldown(siphonLife.abilityCurrentCooldownTime) && IsTargetInRange(myCurrentTarget, siphonLife.abilityRange) && HasEnoughAP(currentAP, siphonLife.abilityAPCost) ) { //SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Siphon Life", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformSiphonLife(this, myCurrentTarget); // 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 (IsAbilityOffCooldown(siphonLife.abilityCurrentCooldownTime) && IsTargetInRange(GetClosestDefender(), siphonLife.abilityRange) && HasEnoughAP(currentAP, siphonLife.abilityAPCost) ) { SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Siphon Life", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformSiphonLife(this, myCurrentTarget); // brief delay between actions yield return(new WaitForSeconds(1f)); goto ActionStart; } // Twin Strike else if (IsTargetInRange(myCurrentTarget, currentMeleeRange) && HasEnoughAP(currentAP, twinStrike.abilityAPCost) && IsAbilityOffCooldown(twinStrike.abilityCurrentCooldownTime)) { //SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Twin Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformTwinStrike(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Fireball else if (IsTargetInRange(myCurrentTarget, fireBall.abilityRange) && HasEnoughAP(currentAP, fireBall.abilityAPCost) && IsAbilityOffCooldown(fireBall.abilityCurrentCooldownTime)) { //SetTargetDefender(GetMostVulnerableDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Fire Ball", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformFireBall(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (IsTargetInRange(myCurrentTarget, fireBall.abilityRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost) && IsAbilityOffCooldown(move.abilityCurrentCooldownTime) ) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, fireBall.abilityRange, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } else if (AILogic.IsEngagedInMelee(this) && IsAbilityOffCooldown(teleport.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, teleport.abilityAPCost) ) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Teleport", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformTeleport(this, GetBestTeleportLocation(myCurrentTarget.TileCurrentlyOn)); yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability dash = mySpellBook.GetAbilityByName("Dash"); Ability twinStrike = mySpellBook.GetAbilityByName("Twin Strike"); /* AI LOGIC * If enemy is in melee range and twin strike ready, twin strike * if enemy is in melee range and strike ready, strike * If enemy is not in melee range, and dash ready, dash towards them * if enemy is not in melee range and move ready, move towards them. */ ActionStart: if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Twin Strike else if (IsTargetInRange(GetDefenderWithLowestCurrentHP(), currentMeleeRange) && HasEnoughAP(currentAP, twinStrike.abilityAPCost) && IsAbilityOffCooldown(twinStrike.abilityCurrentCooldownTime)) { SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Twin Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformTwinStrike(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (IsTargetInRange(GetDefenderWithLowestCurrentHP(), currentMeleeRange) && HasEnoughAP(currentAP, strike.abilityAPCost) && IsAbilityOffCooldown(strike.abilityCurrentCooldownTime)) { SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Dash else if (IsTargetInRange(GetDefenderWithLowestCurrentHP(), currentMeleeRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, dash.abilityAPCost) && IsAbilityOffCooldown(dash.abilityCurrentCooldownTime) ) { SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Dash", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, dash.abilityPrimaryValue); AbilityLogic.Instance.PerformDash(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (IsTargetInRange(GetDefenderWithLowestCurrentHP(), currentMeleeRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost) && IsAbilityOffCooldown(move.abilityCurrentCooldownTime) ) { SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }
public override IEnumerator StartMyActivationCoroutine() { Ability strike = mySpellBook.GetAbilityByName("Strike"); Ability move = mySpellBook.GetAbilityByName("Move"); Ability guard = mySpellBook.GetAbilityByName("Guard"); Ability inspire = mySpellBook.GetAbilityByName("Inspire"); /* AI LOGIC * If inspire is ready and best inspire target is in range and inspire ready, inspire * prioritise archer>assassin>barbarian>warrior>self) * if best inspire target is not in range, inspire something random within range * if an ally is not at max hp and in range of barrier and barrier is ready, barrier them * if in melee range of closest target and strike ready, strike * if move ready and not on grass and a grass tile is within movement range, move to grass * if not in melee range of closest target and both move and strike ready, move towards them * (stops Ai from moving onto grass, then off the grass towards an enemy without being able to attack) */ ActionStart: if (IsAbleToTakeActions() == false) { EndMyActivation(); } // Inspire best target if they are in range else if (IsTargetInRange(GetBestInspireTarget(), inspire.abilityRange) && IsAbilityOffCooldown(inspire.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, inspire.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Inspire", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformInspire(this, GetBestInspireTarget()); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Inspire something else if the best target is not in range else if (GetBestInspireTargetInRange(inspire.abilityRange) != null && IsAbilityOffCooldown(inspire.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, inspire.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Inspire", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformInspire(this, GetBestInspireTargetInRange(inspire.abilityRange)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Guard an ally if they are injured and in range else if (GetBestBarrierTargetInRange(guard.abilityRange) != null && IsAbilityOffCooldown(guard.abilityCurrentCooldownTime) && HasEnoughAP(currentAP, guard.abilityAPCost)) { StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Guard", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformGuard(this, GetBestBarrierTargetInRange(guard.abilityRange)); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Strike else if (IsTargetInRange(GetClosestDefender(), currentMeleeRange) && HasEnoughAP(currentAP, strike.abilityAPCost) && IsAbilityOffCooldown(strike.abilityCurrentCooldownTime)) { SetTargetDefender(GetClosestDefender()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Strike", false)); yield return(new WaitForSeconds(0.5f)); AbilityLogic.Instance.PerformStrike(this, myCurrentTarget); yield return(new WaitForSeconds(1f)); goto ActionStart; } // Move else if (IsTargetInRange(GetDefenderWithLowestCurrentHP(), currentMeleeRange) == false && IsAbleToMove() && HasEnoughAP(currentAP, move.abilityAPCost) && IsAbilityOffCooldown(move.abilityCurrentCooldownTime) ) { SetTargetDefender(GetDefenderWithLowestCurrentHP()); StartCoroutine(VisualEffectManager.Instance.CreateStatusEffect(transform.position, "Move", false)); yield return(new WaitForSeconds(0.5f)); TileScript destination = AILogic.GetBestValidMoveLocationBetweenMeAndTarget(this, myCurrentTarget, currentMeleeRange, currentMobility); AbilityLogic.Instance.PerformMove(this, destination); // small delay here in order to seperate the two actions a bit. yield return(new WaitForSeconds(1f)); goto ActionStart; } EndMyActivation(); }