/// <summary> /// Executes an ability from a given combatant to the given target combatants. /// </summary> /// <param name="ability">The Ability object being executed</param> /// <param name="source">The combatant using the ability.</param> /// <param name="targets">A list of combatants being targeted by the ability.</param> private void DoAbility(AbilityData ability, CombatantController source, List <CombatantController> targets) { // Start the ability's animation Debug.Log("TODO: Ability animations!"); // Apply the ability to each target combatant foreach (CombatantController target in targets) { // Apply any effects the ability has on the target foreach (EffectData effect in ability.effects) { target.ApplyEffect(effect, source); // Generate any floating combat text if required floatingTextController.PlayTextForEffect(effect, GetCombatantTransform(target.BattleID)); } // If the target combatant died, set their animation state if (target.HP <= 0) { KillCombatant(target); } else { // Apply any auras the ability has on the target foreach (AuraData aura in ability.auras) { target.AddAura(aura, source); } } // Modify the caster's resource values if (source.Allegiance == Allegiance.PLAYER) { HeroController heroSource = (HeroController)source; if (heroSource.IsProtag) { // Jack's Calm and Strife generation are not mutually exclusive heroSource.Calm += ability.calmGen; heroSource.Strife += ability.strifeGen; } else { // Abilities which generate Calm and Strife exist, but should // not be usable by anyone other than the protagonist if (ability.calmGen != 0 && ability.strifeGen != 0) { Debug.LogError("Abilities which generate Calm and Strife should not be usable by non-protagonist!"); Debug.Break(); } // Non-protagonists lose one resource when they gain another if (ability.calmGen > 0) { if (heroSource.Strife > 0) { heroSource.Strife -= ability.calmGen; } else { heroSource.Calm += ability.calmGen; } } else if (ability.strifeGen > 0) { if (heroSource.Calm > 0) { heroSource.Calm -= ability.strifeGen; } else { heroSource.Strife += ability.strifeGen; } } } } } }