Пример #1
0
        public void SerializeDeserializeRepReserializeTest()
        {
            var root = CoreAI_BT.InitRootNode(null, null, null);

            var repFirst  = BehaviorNodeDef.FromNode(root);
            var jsonFirst = repFirst.ToJSONString();

            var repSecond  = SerializeUtil.FromJSON <BehaviorNodeDef>(jsonFirst);
            var jsonSecond = repSecond.ToJSONString();

            Assert.AreEqual(jsonFirst, jsonSecond);
        }
Пример #2
0
        public static void DumpTree(BehaviorNode root, string directory, string name, DumpType type)
        {
            // dump to json
            if (type == DumpType.JSON || type == DumpType.Both)
            {
                BehaviorNodeDef.FromNode(root)
                .ToJSONFile(Path.Combine(directory, $"{name}.json"));
            }

            // dump to text
            if (type == DumpType.Text || type == DumpType.Both)
            {
                root.DumpTree(Path.Combine(directory, $"{name}.txt"));
            }
        }