Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- public class ModifiedStat : BaseStat {
- private List<ModifyingAttribute> _mods;
- private int _modValue;
- public ModifiedStat()
- {
- _mods = new List<ModifyingAttribute>();
- _modValue = 0;
- }
- public void AddModifier(ModifyingAttribute mod)
- {
- _mods.Add(mod);
- }
- private void CalculateModValue()
- {
- _modValue = 0;
- if (_mods.Count > 0)
- foreach (ModifyingAttribute att in _mods)
- _modValue += (int)(att.attribute.BuffedValue * att.ratio);
- }
- public new int BuffedValue
- {
- get { return BaseValue + BuffValue +_modValue; }
- }
- public void Update()
- {
- CalculateModValue();
- }
- public string GetModifyingAttributesString()
- {
- string temp="";
- //UnityEngine.Debug.Log(_mods.Count);
- for (int i = 0;i<_mods.Count ;i++ )
- {
- temp += _mods[i].attribute.Name;
- temp += "_";
- temp += _mods[i].ratio;
- if (i < _mods.Count - 1)
- temp += "|";
- }
- //UnityEngine.Debug.Log(temp);
- return temp;
- }
- }
- public struct ModifyingAttribute
- {
- public Attribute attribute;
- public float ratio;
- public ModifyingAttribute(Attribute att, float rat)
- {
- attribute = att;
- ratio = rat;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement