Пример #1
0
    // === SERIALIZATION ===

    public void OnBeforeSerialize()
    {
        Dictionary <string, float> statStrings = new Dictionary <string, float>();

        foreach (var stat in stats)
        {
            statStrings[stat.Key.ToString()] = stat.Value;
        }
        serializedStats = new StatDictionary(statStrings);
    }
Пример #2
0
    private StatSet(StatDictionary stats) : this()
    {
        Dictionary <string, float> statStrings = stats.ToDictionary();

        this.stats = new Dictionary <StatTag, float>();
        foreach (var stat in statStrings)
        {
            StatTag result;
            if (Enum.TryParse(stat.Key, true, out result))
            {
                this.stats[result] = stat.Value;
            }
        }
    }
Пример #3
0
    // === SERIALIZATION ===

    public void OnBeforeSerialize()
    {
        serializedStats = new StatDictionary(stats);
    }
Пример #4
0
 private StatSet(StatDictionary stats)
 {
     this.stats = stats.ToDictionary();
 }
Пример #5
0
 Stat()
 {
     stats = new StatDictionary();
 }
Пример #6
0
 public void ClampInBounds()
 {
     Assert.Equal(StatDictionary.Clamp(50), 50);
 }
Пример #7
0
 public void ClampBelow()
 {
     Assert.Equal(StatDictionary.Clamp(-50), 0);
 }
Пример #8
0
 public void ClampAbove()
 {
     Assert.Equal(StatDictionary.Clamp(500), 100);
 }