// ----------------------------------------------------------------------------------- // CalculateBonusProperty // ----------------------------------------------------------------------------------- public float CalculateBonusProperty(PropertyModifier modifier, int level) { return(GetPropertySum(modifier, PropertyTypes.BonusValue, level)); }
// =================================================================================== // PROPERTY CALCULATIONS // =================================================================================== // ----------------------------------------------------------------------------------- // GetPropertySum // ----------------------------------------------------------------------------------- public float GetPropertySum(PropertyModifier modifier, PropertyTypes property, int level) { float tmpValue = 0; int additive = 1; if (modifier != null) { if (modifier.template is NumericAttributeTemplate) { int index = attributes.attributes.FindIndex(m => m.template == modifier.template); if (index != -1) { if (property == PropertyTypes.Value) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, attributes.attributes[index].Value); } else if (property == PropertyTypes.TotalValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, attributes.attributes[index].TotalValue); } else if (property == PropertyTypes.BonusValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, attributes.attributes[index].BonusValue); } } } else if (modifier.template is NumericElementTemplate) { int index = resistances.resistances.FindIndex(m => m.template == modifier.template); if (index != -1) { if (property == PropertyTypes.Value) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, resistances.resistances[index].Value); } else if (property == PropertyTypes.TotalValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, resistances.resistances[index].TotalValue); } else if (property == PropertyTypes.BonusValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, resistances.resistances[index].BonusValue); } } } else if (modifier.template is NumericStatisticTemplate) { int index = statistics.statistics.FindIndex(m => m.template == modifier.template); if (index != -1) { if (property == PropertyTypes.Value) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, statistics.statistics[index].Value); } else if (property == PropertyTypes.TotalValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, statistics.statistics[index].TotalValue); } else if (property == PropertyTypes.BonusValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, statistics.statistics[index].BonusValue); } } } else if (modifier.template is SkillTemplate) { var index = skills.skills.FindIndex(m => m.template == modifier.template); if (index != -1) { if (property == PropertyTypes.Value) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, skills.skills[index].Value); } else if (property == PropertyTypes.TotalValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, skills.skills[index].TotalValue); } else if (property == PropertyTypes.BonusValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, skills.skills[index].BonusValue); } } } else if (modifier.template is StatusTemplate) { var index = states.states.FindIndex(m => m.template == modifier.template); if (index != -1) { if (property == PropertyTypes.Value) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, states.states[index].Value); } else if (property == PropertyTypes.TotalValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, states.states[index].TotalValue); } else if (property == PropertyTypes.BonusValue) { tmpValue += GetModifierValue(modifier.FixedValue, modifier.PercentValue, level, additive, states.states[index].BonusValue); } } } } return(tmpValue); }