示例#1
0
    protected void UpdateDynamic(Unit unit)
    {
        var mods = FilterModifiers(unit.modifiers.Get <UnitModifier>()).ToList();
        var old  = dynamics.ToList();

        dynamics.Clear();

        int i = 0;

        for (; i < mods.Count; i++)
        {
            if (i < old.Count)
            {
                dynamics.Add(mods[i], old[i].Value);
                SendValue(old[i].Value, mods[i]);
            }
            else
            {
                CreateItem(mods[i]);
            }
        }
        for (; i < old.Count; i++)
        {
            Destroy(old[i].Value);
        }
    }
示例#2
0
        public void TestDictSerializationPass()
        {
            var instance  = new TestObject();
            var reference = new SerializedDictionary <int, string>();

            instance.var1 = reference;
            reference.Add(1, "A");
            reference.Add(2, "B");
            reference.Add(3, "C");

            Assert.AreEqual(reference.Count, 3);
            Assert.AreEqual(reference.ContainsKey(1), true);
            Assert.AreEqual(reference.ContainsKey(2), true);
            Assert.AreEqual(reference.ContainsKey(3), true);
            Assert.AreEqual(reference[2], "B");
        }
 public void FillDictionary()
 {
     ResearchCostDictionary.Clear();
     for (var i = 0; i < 18; i++)
     {
         ResearchCostDictionary.Add((ResearchType)i, researchCosts[i]);
     }
 }
示例#4
0
    private SerializedDictionary <string, KalsiumObject> BuildDict()
    {
        var res = new SerializedDictionary <string, KalsiumObject>();

        sources.RemoveAll(v => v == null);
        foreach (var source in sources)
        {
            Debug.Assert(source.identifier != "", source);
            Debug.Assert(!res.ContainsKey(source.identifier), source);
            res.Add(source.identifier, source);
        }
        return(res);
    }