/// <summary> /// /// Adds the stat modifier to the enchantment for a particular stat type dropdown and an input /// /// </summary> private void GetStatModifier(UnitEnchantment enchantment, Unit.StatTypes statType, TMP_Dropdown statModTypeDropdown, TMP_InputField statValueInput) { var statModType = (StatModifierTypes)Enum.Parse(typeof(StatModifierTypes), statModTypeDropdown.captionText.text); if (statModType != StatModifierTypes.None) { if (string.IsNullOrWhiteSpace(statValueInput.text)) { statValueInput.text = "0"; } var statValue = int.Parse(statValueInput.text); enchantment.AddStatModifier(statType, statModType, statValue); } }
public void AddStatModifier(Unit.StatTypes statType, StatModifierTypes modType, int value) { if (statType == Unit.StatTypes.Default || modType == StatModifierTypes.None) { throw new Exception("Not valid stat modifier inputs"); } if (StatModifiers.Any(x => x.StatType == statType)) { StatModifiers.RemoveAll(x => x.StatType == statType); } StatModifiers.Add(new StatModifier() { StatType = statType, ModType = modType, Value = value }); }