Пример #1
0
 public void RemoveModifer(RPGStatModifier mod)
 {
     if (_stats.ContainsKey(mod.StatType))
     {
         var stat = GetStat <RPGStatModifiable>(mod.StatType);
         if (stat != null)
         {
             stat.RemoveModifier(mod);
             stat.UpdateModifierValue();
         }
     }
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        entityStats.OnStatValueChange += OnStatChange;

        DisplayStats();

        var conMod = new RPGStatModifier(RPGStatType.Attribute_Constitution, RPGStatModifier.Types.BaseValueAdd, 20);
        var defMod = new RPGStatModifier(RPGStatType.Skill_Melee_Defence, RPGStatModifier.Types.BaseValuePercent, 2f);

        entityStats.AddModifier(conMod);
        entityStats.AddModifier(defMod);
        entityStats.RemoveModifer(conMod);
        entityStats.RemoveModifer(defMod);
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        entityStats.OnStatValueChange += OnStatChange;

        DisplayStats();

        var conMod = new RPGStatModifier(RPGStatType.Attribute_Constitution, RPGStatModifier.Types.BaseValueAdd, 20);
        var defMod = new RPGStatModifier(RPGStatType.Skill_Melee_Defence, RPGStatModifier.Types.BaseValuePercent, 2f);

        entityStats.AddModifier(conMod);
        entityStats.AddModifier(defMod);
        entityStats.RemoveModifer(conMod);
        entityStats.RemoveModifer(defMod);
    }
Пример #4
0
 /// <summary>
 /// Removes a Stat Modifier to the Target stat and then updates the stat's value.
 /// </summary>
 public void RemoveStatModifier(RPGStatType target, RPGStatModifier mod, bool update)
 {
     if (ContainStat(target))
     {
         var modStat = GetStat(target) as IStatModifiable;
         if (modStat != null)
         {
             modStat.RemoveModifier(mod);
             if (update == true)
             {
                 modStat.UpdateModifiers();
             }
         }
         else
         {
             Debug.Log("[RPGStats] Trying to remove Stat Modifier from non modifiable stat \"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStats] Trying to remove Stat Modifier from \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat");
     }
 }
Пример #5
0
 /// <summary>
 /// Adds a Stat Modifier to the Target stat and then updates the stat's value.
 /// </summary>
 public void AddStatModifier(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("[RPGStats] Trying to add Stat Modifier to non modifiable stat \"" + target.ToString() + "\"");
         }
     }
     else
     {
         Debug.Log("[RPGStats] Trying to add Stat Modifier to \"" + target.ToString() + "\", but RPGStats does not contain that stat");
     }
 }
Пример #6
0
 /// <summary>
 /// Adds a Stat Modifier to the Target stat.
 /// </summary>
 public void AddStatModifier(RPGStatType target, RPGStatModifier mod)
 {
     AddStatModifier(target, mod, false);
 }
 public void RemoveModifier(RPGStatModifier mod)
 {
     _statMods.Remove(mod);
 }
 public void AddModifier(RPGStatModifier mod)
 {
     _statMods.Add(mod);
 }
Пример #9
0
 public void RemoveStatModifier(RPGStatModifier mod)
 {
     _statMods.Remove(mod);
     mod.OnValueChange -= OnModValueChange;
 }
Пример #10
0
 public void AddModifiers(RPGStatModifier mod)
 {
     _statMods.Add(mod);
     mod.OnValueChange += OnModValueChange;
 }
 public void RemoveModifier(RPGStatModifier mod)
 {
     _statMods.Remove(mod);
 }
 public void AddModifier(RPGStatModifier mod)
 {
     _statMods.Add(mod);
 }
	void Start () {
        bool passed = true;
        stat = new RPGStatModifiable();
        
        // Set the Starting base value
        int statTargetValue = 100;
        stat.StatBaseValue = statTargetValue;
        
        // Create instance of the modifiers with all values set to 0
        RPGStatModifier[] mods = new RPGStatModifier[] {
            new RPGStatModBaseAdd(0),
            new RPGStatModBasePercent(0),
            new RPGStatModTotalAdd(0),
            new RPGStatModTotalPercent(0)
        };

        // Add lisener event to each modifier and add mod to stat
        foreach (var mod in mods) {
            //Debug.Log("Stat Listening to Mod: " + mod.GetType().ToString());
            mod.OnValueChange += OnValueChange;
            stat.AddModifier(mod);
        }

        // Change the Base Add Mod Value
        int baseAddValue = 100;
        statTargetValue += baseAddValue;
        mods[0].Value = baseAddValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        // Change the Base Percent Mod Value
        float basePercentValue = 0.5f;
        statTargetValue += (int)(statTargetValue * basePercentValue);
        mods[1].Value = basePercentValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        // Change the Base Add Mod Value
        int totalAddValue = 100;
        statTargetValue += totalAddValue;
        mods[2].Value = totalAddValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        // Change the Base Percent Mod Value
        float totalPercentValue = 0.5f;
        statTargetValue += (int)(statTargetValue * totalPercentValue);
        mods[3].Value = totalPercentValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        Debug.Log(string.Format("Stat Modifier Test: {0}", passed ? "Passed" : "Failed"));
	}
Пример #14
0
 /// <summary>
 /// Removes a Stat Modifier to the Target stat.
 /// </summary>
 public void RemoveStatModifier(RPGStatType target, RPGStatModifier mod)
 {
     RemoveStatModifier(target, mod, false);
 }
Пример #15
0
    void Start()
    {
        bool passed = true;

        stat = new RPGStatModifiable();

        // Set the Starting base value
        int statTargetValue = 100;

        stat.StatBaseValue = statTargetValue;

        // Create instance of the modifiers with all values set to 0
        RPGStatModifier[] mods = new RPGStatModifier[] {
            new RPGStatModBaseAdd(0),
            new RPGStatModBasePercent(0),
            new RPGStatModTotalAdd(0),
            new RPGStatModTotalPercent(0)
        };

        // Add lisener event to each modifier and add mod to stat
        foreach (var mod in mods)
        {
            //Debug.Log("Stat Listening to Mod: " + mod.GetType().ToString());
            mod.OnValueChange += OnValueChange;
            stat.AddModifier(mod);
        }

        // Change the Base Add Mod Value
        int baseAddValue = 100;

        statTargetValue += baseAddValue;
        mods[0].Value    = baseAddValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        // Change the Base Percent Mod Value
        float basePercentValue = 0.5f;

        statTargetValue += (int)(statTargetValue * basePercentValue);
        mods[1].Value    = basePercentValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        // Change the Base Add Mod Value
        int totalAddValue = 100;

        statTargetValue += totalAddValue;
        mods[2].Value    = totalAddValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        // Change the Base Percent Mod Value
        float totalPercentValue = 0.5f;

        statTargetValue += (int)(statTargetValue * totalPercentValue);
        mods[3].Value    = totalPercentValue;

        // Check if the target value is the same as the stat's value
        passed = passed && stat.StatValue == statTargetValue;
        Debug.Log(string.Format("Check[{0}]: Stat Value {1}, Target Value {2}", passed, stat.StatValue, statTargetValue));

        Debug.Log(string.Format("Stat Modifier Test: {0}", passed ? "Passed" : "Failed"));
    }
 /// <summary>
 /// Removes modifier from stat and stops listening to value change event
 /// </summary>
 public void RemoveModifier(RPGStatModifier mod) {
     _statMods.Add(mod);
     mod.OnValueChange -= OnModValueChange;
 }
 /// <summary>
 /// Adds Modifier to stat and listens to the mod's value change event
 /// </summary>
 public void AddModifier(RPGStatModifier mod) {
     _statMods.Add(mod);
     mod.OnValueChange += OnModValueChange;
 }