// Special Methods public void TakeDamage(float amount, DamageType type, AttrModType modType) { // A switch can be implemented here to reduce the amount based on the // damage type and the associated resitances health.AddModifier(new AttrModifier(-amount, modType)); Debug.Log(gameObject.name + " health " + health.value + " remaining after " + amount + " damage delt"); }
//"Main" constructor.Requires all variables. public AttributeModifier(float value, AttrModType type, int order, object source) { mValue = value; mType = type; mOrder = order; mSource = source; }
//constructor public AttrModifier(float value, AttrModType type, int order, object source) { baseValue = value; _type = type; _order = order; _source = source; }
public void Heal(float amount, AttrModType type) { // Checks if a modifier equal to the negative of the amount to heal can be found if (health.RemoveModifier(new AttrModifier(-amount, type)) == false) { // If not adds the amount to heal as a new modifier health.AddModifier(new AttrModifier(amount, type)); } Debug.Log(gameObject.name + " health of " + health.value + " after " + amount + " healing."); }
public bool RemoveModifierOfType(AttrModType modType) { bool didRemove = false; for (int i = _attrModifiers.Count - 1; i >= 0; i--) { if (_attrModifiers[i].type == modType) { isDirty = true; _attrModifiers.RemoveAt(i); didRemove = true; break; } } return(didRemove); }
// Requires Value, Type and Source. Sets Order to its default value: (int)Type public AttributeModifier(float value, AttrModType type, object source) : this(value, type, (int)type, source) { }
// Requires Value, Type and Order. Sets Source to its default value: null public AttributeModifier(float value, AttrModType type, int order) : this(value, type, order, null) { }
// Requires Value and Type.Calls the "Main" constructor and sets Order and Source to their default values: (int) type and null, respectively. public AttributeModifier(float value, AttrModType type) : this(value, type, (int)type, null) { }
public void AddAttributeModifier(float value, AttrModType type) { testAttribute.AddModifier(new AttrModifier(value, AttrModType.FLAT)); }
// Methods to Add Modifiers to Attributes #region public void AddAttributeModifier(float value, AttrModType type, object source) { testAttribute.AddModifier(new AttrModifier(value, AttrModType.FLAT, this)); }