public void OnEnable() { _statCollection = GetComponent <RPGStatCollection>(); if (_statCollection != null) { if (_statCollection.IsCollectionSetup == false) { _statCollection.SetupCollection(); } if (_statCollection.TryGetStat(_healthType, out _health) == false) { Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}", this.name, _healthType.ToString()); } if (_statCollection.TryGetStat(_healthRegenType, out _healthRegen) == false) { Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}", this.name, _healthRegenType.ToString()); } if (_statCollection.TryGetStat(_energyType, out _energy) == false) { Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}", this.name, _energyType.ToString()); } if (_statCollection.TryGetStat(_energyRegenType, out _energyRegen) == false) { Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}", this.name, _energyRegenType.ToString()); } if (_statCollection.TryGetStat(_manaType, out _mana) == false) { Debug.LogWarningFormat("[{0}]: Collection does not contain vital of type {1}", this.name, _manaType.ToString()); } if (_statCollection.TryGetStat(_manaRegenType, out _manaRegen) == false) { Debug.LogWarningFormat("[{0}]: Collection does not contain stat of type {1}", this.name, _manaRegenType.ToString()); } } }
/// <summary> /// Scales the target stat in the collection to the target level /// </summary> public void ScaleStat(RPGStatType target, int level) { if (ContainStat(target)) { var stat = GetStat(target) as IStatScalable; if (stat != null) { stat.ScaleStat(level); } else { Debug.Log("[RPGStats] Trying to Scale Stat with a non scalable stat \"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to Scale Stat for \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Updates the target stat's modifier value /// </summary> public void UpdateStatModifer(RPGStatType target) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.UpdateModifiers(); } else { Debug.Log("[RPGStats] Trying to Update Stat Modifiers for a non modifiable stat \"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to Update Stat Modifiers for \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Adds the modifier. /// </summary> /// <param name="target">Target.</param> /// <param name="mod">Mod.</param> /// <param name="update">If set to <c>true</c> update.</param> public void AddModifier(RPGStatType target, RPGStatModifier mod, bool update) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.AddModifier(mod); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStatCollection] Trying to add Stat Modifier to non modifiable stat\"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStatCollection] Trying to add Stat Modifier to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Scales the stat. /// </summary> /// <param name="target">Target.</param> /// <param name="level">Level.</param> public void ScaleStat(RPGStatType target, int level) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatScalable; if (modStat != null) { modStat.ScaleStat(level); } else { Debug.Log("[RPGStatCollection] Trying to scale Stat Modifiers to non modifiable stat\"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStatCollection] Trying to scale Stat Modifiers to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
public void ClearStatModifier(RPGStatType target, bool update) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.ClearModifiers(); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStatCollection] Trying to clear all Stat Modifiers from non modifiable stat \"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStatCollection] Trying to clear all Stat Modifier from \"" + target.ToString() + "\" but RPGStatCollection does not contain that stat."); } }