Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System.Collections.Generic;
  2. public class ModifiedStat : BaseStat {
  3. private List<ModifyingAttribute> _mods; //a list of attributes that modify this stat
  4. private int _modValue; //the amount added to the baseValue from the modifiers
  5.  
  6. public ModifiedStat() {
  7. _mods = new List<ModifyingAttribute> ();
  8. _modValue = 0;
  9. }
  10.  
  11. public void AddModifier( ModifyingAttribute mod) {
  12. _mods.Add (mod);
  13. }
  14.  
  15. private void CalculateModValue() {
  16. _modValue = 0;
  17.  
  18. if(_mods.Count > 0)
  19. foreach(ModifyingAttribute att in _mods)
  20. _modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
  21. }
  22.  
  23. public new int AdjustedBaseValue {
  24. get{ return BaseValue + BuffValue + _modValue;}
  25. }
  26.  
  27. public void update() {
  28. CalculateModValue ();
  29. }
  30.  
  31. public string GetModifyingAttributeString (){
  32. string temp;
  33.  
  34. for (int cnt = 0; cnt < _mods.Count; cnt++) {
  35. UnityEngine.Debug.Log(_mods[cnt].Name);
  36. }
  37.  
  38. return "";
  39. }
  40. }
  41.  
  42. public struct ModifyingAttribute {
  43. public Attribute attribute;
  44. public float ratio;
  45. public ModifyingAttribute(Attribute att, float rat) {
  46. attribute = att;
  47. ratio = rat;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement