static void print(TestAttrBase tb, string desc) { Console.WriteLine(); foreach (var it in tb.GetBaseAttribute().Data) { Console.WriteLine(desc + ":base:key={0},value={1}", it.Key, it.Value); } Console.WriteLine(); foreach (var it in tb.GetFinalAttribute().Data) { Console.WriteLine(desc + ":final:key={0},value={1}", it.Key, it.Value); } }
static void test1() { var config = LuaConfigs.LoadSingleConfig <TestAttrConfig>("test_bak.lua"); config.WriteToFile("test.lua"); Console.WriteLine(config.ToLuaString()); var initattr = LuaConfigs.LoadSingleConfig <InitAttr>("init.lua"); Console.WriteLine(config.ToString()); Console.WriteLine(initattr.ToString()); TestAttrBase tb = new TestAttrBase(config); tb.AddAttributes(initattr.init_attr); print(tb, "BEF"); tb.Rebuild(true); print(tb, "AFT"); Console.WriteLine("adddddddddddddddddddd"); tb.AddAttribute(ATTR_ID.AGILITY_ABL, 1); tb.Rebuild(); print(tb, "ADD1"); tb.AddAttribute(ATTR_ID.STRENGTH_ABL, 1); tb.Rebuild(); print(tb, "ADD2"); Console.WriteLine("removeeeeeeeeeeeeeeeee"); tb.RemoveAttribute(ATTR_ID.AGILITY_ABL, 1); tb.Rebuild(); print(tb, "REM1"); tb.RemoveAttribute(ATTR_ID.STRENGTH_ABL, 1); tb.Rebuild(); print(tb, "REM2"); Console.WriteLine("addlistttttttttttttttttt"); var attList = new Dictionary <ATTR_ID, double> { { ATTR_ID.AGILITY_ABL, 1 }, { ATTR_ID.STRENGTH_ABL, 1 }, }; tb.AddAttributes(attList); tb.Rebuild(); print(tb, "addlist"); Console.WriteLine("removelistttttttttttttttttt"); tb.RemoveAttributes(attList); tb.Rebuild(); print(tb, "removelist"); }