private List <ICombatEffect> GetNewEffects(ref ICombatAction action, out List <ICombatEffect> newEffects) { newEffects = new List <ICombatEffect>(); foreach (var effect in action.GetEffects()) { newEffects.Add(effect); } return(newEffects); }
private void GetApplicableCombos(ref ICombatAction action, out List <ICombatCombo> combos) { combos = new List <ICombatCombo>(); foreach (var combo in action.GetCombos()) { foreach (var trigger in combo.GetTriggers()) { if (trigger == CombatElement.Instance.ActiveElement) { combos.Add(combo); break; } } } }
/// <summary>Calculate receiving damage from action.</summary> /// <param name="action">Action that hits the unit.</param> /// <param name="unitAttackValue">Attack value of the attacking unit (required for damage formula).</param> /// <returns>Does the unit survive?</returns> public bool ExecuteActionOnUnit(ICombatAction action, int unitAttackValue) { // Note: Put this in CUS? int totalValue = action.GetValue() + unitAttackValue; List <ICombatEffect> newEffects; GetNewEffects(ref action, out newEffects); List <ICombatCombo> applicableCombos; GetApplicableCombos(ref action, out applicableCombos); ExtrudeValueAndEffectsFromCombo(ref applicableCombos, ref totalValue, ref newEffects); combatStats.AddEffects(newEffects); combatStats.CalculateResultingValue(totalValue, action.element); ApplyEffectsOnHit(ref newEffects); CombatElement.Instance.ActiveElement = action.element; return(true); }