Esempio n. 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");
 }
 public override void loadConfig(TezReader reader)
 {
     m_Root        = (TezBTComposite)create(reader.readString("CID"));
     m_Root.tree   = this;
     m_Root.parent = this;
     m_Root.loadConfig(reader);
 }
Esempio n. 3
0
        private static void writeFinalClass(TezReader reader, StringBuilder builder, string className, string parentClass, string rootClass, string rootMember)
        {
            builder.AppendLine(string.Format("public class {0} : TezCategoryFinalToken<{0}, {0}.Category>", className));
            builder.AppendLine("{");

            #region 枚举变量
            builder.AppendLine("public enum Category");
            builder.AppendLine("{");
            for (int i = 0; i < reader.count; i++)
            {
                builder.AppendLine(reader.readString(i) + ",");
            }
            builder.AppendLine("}");
            #endregion

            #region 构造函数
            builder.AppendLine(string.Format("private {0}(Category value, ITezCategoryBaseToken parentToken) : base(value, parentToken)", className));
            builder.AppendLine("{");
            builder.AppendLine("}");
            #endregion

            #region 声明变量
            for (int i = 0; i < reader.count; i++)
            {
                builder.AppendLine(string.Format("public static readonly {0} {1} = new {0}(Category.{1}, {2}.{0});", className, reader.readString(i), parentClass));
            }
            #endregion

            #region 初始化变量
            builder.AppendLine("public static void init()");
            builder.AppendLine("{");
            for (int i = 0; i < reader.count; i++)
            {
                builder.AppendLine(string.Format("{0}.registerID({1}.{2});", reader.readString(i), rootClass, rootMember));
            }
            builder.AppendLine("}");
            #endregion


            builder.AppendLine("}");
            builder.AppendLine();
        }
Esempio n. 4
0
 public override void readFromSave(TezReader reader)
 {
     if (Enum.TryParse(reader.readString("KeyCode"), out KeyCode result))
     {
         keyCode = result;
     }
     else
     {
         throw new Exception();
     }
 }
Esempio n. 5
0
        public static void readProperty(this TezReader reader, TezValueWrapper vw)
        {
            switch (vw.valueType)
            {
            case TezValueType.Bool:
            {
                var result = (TezValueWrapper <bool>)vw;
                result.value = reader.readBool(result.name);
                break;
            }

            case TezValueType.Int:
            {
                var result = (TezValueWrapper <int>)vw;
                result.value = reader.readInt(result.name);
                break;
            }

            case TezValueType.Float:
            {
                var result = (TezValueWrapper <float>)vw;
                result.value = reader.readFloat(result.name);
                break;
            }

            case TezValueType.Double:
                break;

            case TezValueType.String:
            {
                var result = (TezValueWrapper <string>)vw;
                result.value = reader.readString(result.name);
                break;
            }

            case TezValueType.Class:
                break;

            case TezValueType.StaticString:
                break;

            case TezValueType.Type:
                break;

            case TezValueType.Unknown:
                break;

            default:
                break;
            }
        }
Esempio n. 6
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");
        }
Esempio n. 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();
        }