Beispiel #1
0
 public override void loadConfig(TezReader reader)
 {
     reader.beginObject("Node");
     m_Child = TezBehaviorTree.create(reader.readString("CID"));
     m_Child.loadConfig(reader);
     reader.endObject("Node");
 }
Beispiel #2
0
 private static void writeClasses(ICollection <string> children, TezReader reader, StringBuilder builder, string parentClass, string rootClass, string rootMemeber, List <string> finalList)
 {
     ///从Key中获得所有Class的名称
     foreach (var class_name in children)
     {
         ///如果是Object
         ///说明是Path
         if (reader.tryBeginObject(class_name))
         {
             ///写入当前PathClass
             ///并且得到下一级Class的Name
             var new_children = writePathClass(reader, builder, class_name, parentClass);
             ///调用自己写入下一个Class
             writeClasses(new_children, reader, builder, class_name, rootClass, rootMemeber, finalList);
             reader.endObject(class_name);
         }
         ///如果不是Object
         ///说明是Final
         else
         {
             reader.beginArray(class_name);
             writeFinalClass(reader, builder, class_name, parentClass, rootClass, rootMemeber);
             reader.endArray(class_name);
             finalList.Add(class_name);
         }
     }
 }
 public void readFromSave(TezReader reader)
 {
     for (int i = 0; i < reader.count; i++)
     {
         reader.beginObject(i);
         m_Wrappers[i].readFromSave(reader);
         reader.endObject(i);
     }
 }
        public void readFromSave(TezReader reader)
        {
            var layer_names = reader.getKeys();

            foreach (var layer_name in layer_names)
            {
                reader.beginObject(layer_name);
                m_Dic[layer_name].readFromSave(reader);
                reader.endObject(layer_name);
            }
        }
Beispiel #5
0
        public override void loadConfig(TezReader reader)
        {
            reader.beginArray("Nodes");

            var count = reader.count;

            for (int i = 0; i < count; i++)
            {
                reader.beginObject(i);
                var node = TezBehaviorTree.create(reader.readString("CID"));
                this.addNode(node);
                node.loadConfig(reader);
                reader.endObject(i);
            }

            reader.endArray("Nodes");
        }
 public void resetToDefault(TezReader reader, string layerName)
 {
     reader.beginObject(layerName);
     m_Dic[layerName].resetToDefault(reader);
     reader.endObject(layerName);
 }
Beispiel #7
0
        /// <summary>
        ///
        /// Category Cshap File Generator
        ///
        /// </summary>
        /// <param name="outPath"></param>
        /// <param name="reader"></param>
        public static void generateCodeFile(string outPath, TezReader reader)
        {
            List <string> final_list = new List <string>();
            StringBuilder builder    = new StringBuilder();

            var root_class    = "Root";
            var wrapper_class = reader.readString("WrapperClass");

            var name_space = reader.readString("Namespace");

            builder.AppendLine("using System;");
            builder.AppendLine("using System.Collections.Generic;");
            builder.AppendLine("using tezcat.Framework.Core;");
            builder.AppendLine();
            builder.AppendLine();

            ///Namespace
            builder.AppendLine(string.Format("namespace {0}", name_space));
            builder.AppendLine("{");

            ///Config Class
            builder.AppendLine(string.Format("public static class {0}", wrapper_class));
            builder.AppendLine("{");

            #region 写类
            reader.beginObject(root_class);
            var children = writeRootClass(reader, builder, root_class);
            ///从Key中获得所有Class的名称
            foreach (var class_name in children)
            {
                ///如果是Object
                ///说明是Path
                if (reader.tryBeginObject(class_name))
                {
                    ///写入当前PathClass
                    ///并且得到下一级Class的Name
                    var new_children = writePathClass(reader, builder, class_name, root_class);
                    writeClasses(new_children, reader, builder, class_name, root_class, class_name, final_list);
                    reader.endObject(class_name);

                    ///调用自己写入下一个Class
                }
                ///如果不是Object
                ///说明是Final
                else
                {
                    reader.beginArray(class_name);
                    writeFinalClass(reader, builder, class_name, root_class, root_class, class_name);
                    reader.endArray(class_name);
                    final_list.Add(class_name);
                }
            }
            reader.endObject(root_class);
            #endregion

            #region 初始化函数
            builder.AppendLine("public static void init()");
            builder.AppendLine("{");
            for (int i = 0; i < final_list.Count; i++)
            {
                builder.AppendLine(string.Format("{0}.init();", final_list[i]));
            }
            builder.AppendLine("}");
            #endregion

            ///Config Class
            builder.AppendLine("}");

            ///Namespace
            builder.AppendLine("}");

            var writer = TezFilePath.createTextFile(outPath + "/" + wrapper_class + ".cs");
            writer.Write(builder.ToString());
            writer.Close();
        }