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; //a list of attributes that modify this stat
- private int _modValue; //the amount added to the baseValue from the modifiers
- 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.AdjustedBaseValue * att.ratio);
- }
- public new int AdjustedBaseValue {
- get{ return BaseValue + BuffValue + _modValue;}
- }
- public void update() {
- CalculateModValue ();
- }
- public string GetModifyingAttributeString (){
- string temp;
- for (int cnt = 0; cnt < _mods.Count; cnt++) {
- UnityEngine.Debug.Log(_mods[cnt].Name);
- }
- return "";
- }
- }
- 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