Example #1
0
        /// <summary>
        /// 获取VIew层代码模板
        /// </summary>
        /// <returns></returns>
        public static string GetViewCode()
        {
            var build = new ScriptBuildHelp();

            build.WriteUsing("Entitas");
            build.WriteUsing("Entitas.Unity");
            build.WriteEmptyLine();

            build.WriteNamespace(ToolData.NamespaceBase + "." + ToolData.ViewPostfix);

            build.IndentTimes++;
            build.WriteClass(ToolData.ViewName + ToolData.ViewPostfix, "ViewBase");

            build.IndentTimes++;
            List <string> keyName = new List <string>();

            keyName.Add("override");
            keyName.Add("void");
            build.WriteFun(keyName, "Init", "", "Contexts contexts", "IEntity entity");

            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine(" base.Init(contexts, entity);", true);
            build.ToContentEnd();

            return(build.ToString());
        }
Example #2
0
        /// <summary>
        /// 获取其他系统代码模板
        /// </summary>
        /// <returns></returns>
        public static string GetOthersSystemCode()
        {
            string        className      = ToolData.SelectedContextName + ToolData.OtherSystemName + ToolData.SystemPostfix;
            List <string> selectedSystem = GetSelectedSysytem();

            var build = new ScriptBuildHelp();

            build.WriteUsing("Entitas");
            build.WriteNamespace(ToolData.NamespaceBase);

            build.IndentTimes++;
            build.WriteClass(className, GetSelectedSystemInterface(selectedSystem));

            build.IndentTimes++;
            build.WriteLine("protected Contexts _contexts;", true);
            build.WriteEmptyLine();
            //构造
            build.WriteFun(new List <string>(), className, "", "Contexts context");
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("_contexts = context;", true);
            build.IndentTimes--;
            build.ToContentEnd();
            //实现方法
            List <string> funName = GetFunName(selectedSystem);
            List <string> key     = new List <string>();

            key.Add("void");
            foreach (string fun in funName)
            {
                build.WriteFun(key, fun);
            }
            return(build.ToString());
        }
Example #3
0
        /// <summary>
        /// 获取ReactiveSystem层代码模板
        /// </summary>
        /// <returns></returns>
        public static string GetReactiveSystemCode()
        {
            string className  = ToolData.SelectedContextName + ToolData.ReactiveSystemName + "Reactive" + ToolData.SystemPostfix;
            string entityName = ToolData.SelectedContextName + "Entity";

            var build = new ScriptBuildHelp();

            build.WriteUsing("Entitas");
            build.WriteUsing("System.Collections.Generic");
            build.WriteNamespace(ToolData.NamespaceBase);

            build.IndentTimes++;
            build.WriteClass(className, "ReactiveSystem<" + entityName + ">");

            build.IndentTimes++;
            build.WriteLine(" protected Contexts _contexts;", true);
            build.WriteEmptyLine();
            //构造
            build.WriteFun(new List <string>(), className, " : base(context." + ToolData.SelectedContextName.ToLower() + ")", "Contexts context");
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine(" _contexts = context;", true);
            build.IndentTimes--;
            build.ToContentEnd();
            //GetTrigger
            List <string> triggerkeys = new List <string>();

            triggerkeys.Add("override");
            triggerkeys.Add("ICollector<" + entityName + ">");
            build.WriteFun("GetTrigger", ScriptBuildHelp.Protected, triggerkeys, "", "IContext<" + entityName + "> context");
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("return context.CreateCollector(" + ToolData.SelectedContextName + "Matcher." + ToolData.SelectedContextName + ToolData.ReactiveSystemName + ");", true);
            build.IndentTimes--;
            build.ToContentEnd();


            //Filter
            List <string> filerkeys = new List <string>();

            filerkeys.Add("override");
            filerkeys.Add("bool");
            build.WriteFun("Filter", ScriptBuildHelp.Protected, filerkeys, "", entityName + " entity");
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("return entity.has" + ToolData.SelectedContextName + ToolData.ReactiveSystemName + ";", true);
            build.IndentTimes--;
            build.ToContentEnd();


            //Execute
            List <string> executeKeys = new List <string>();

            executeKeys.Add("override");
            executeKeys.Add("void");
            build.WriteFun("Execute", ScriptBuildHelp.Protected, executeKeys, "", "List<" + entityName + "> entities");

            return(build.ToString());
        }
        //获取新的脚本内容
        private static string GetNewScriptContext(string className)
        {
            var script = new ScriptBuildHelp();

            script.WriteUsing("UnityEngine");
            script.WriteEmptyLine();
            script.WriteNamespace(GetNamespaceName());

            script.IndentTimes++;
            script.WriteClass(className);
            return(script.ToString());
        }
Example #5
0
        //获取新的脚本内容
        private static string GetNewScriptContext(string className)
        {
            var script = new ScriptBuildHelp();

            script.WriteEmptyLine();
            var    data = AddNamespaceWindow.GetData();
            string name = data == null ? "UIFrame" : data.name;

            script.WriteNamespace(name);

            script.IndentTimes++;
            script.WriteClass(className);

            return(script.ToString());
        }
        private string GetViewCode()
        {
            var script = new ScriptBuildHelp();

            script.WriteUsing("UnityEngine");
            script.WriteUsing(m_NameSpaceNamePrefix + m_Viewkey);
            script.WriteEmptyLine();
            script.WriteNamespace(m_NameSpaceNamePrefix + m_Viewkey);

            script.IndentTimes++;
            script.WriteClass(m_ScriptName + m_Viewkey, "ViewBase");

            script.IndentTimes++;
            script.WriteFun("Init");
            return(script.ToString());
        }
Example #7
0
        //获取新的脚本内容
        private static string GetNewScriptContext(string nameSpace, string className)
        {
            var script = new ScriptBuildHelp();

            script.WriteUsing("UnityEngine");
            script.WriteEmptyLine();
            script.WriteNamespace(nameSpace);

            script.IndentTimes++;
            script.WriteClass(className, "MonoBehaviour");

            script.IndentTimes++;
            List <string> keys = new List <string>();

            keys.Add("void");
            script.WriteFun(keys, "Start");
            return(script.ToString());
        }
        private string GetMediator()
        {
            var script = new ScriptBuildHelp();

            script.WriteUsing(m_NameSpaceNamePrefix + m_Viewkey);
            script.WriteUsing("strange.extensions.mediation.impl");
            script.WriteEmptyLine();
            script.WriteNamespace(m_NameSpaceNamePrefix + m_Mediatorkey);

            script.IndentTimes++;
            script.WriteClass(m_ScriptName + m_Mediatorkey, "Mediator");

            script.IndentTimes++;

            script.WriteProperty("Inject", m_ScriptName + m_Viewkey, m_NameSpaceNamePrefix + m_Viewkey);
            script.WriteFun("Init");
            return(script.ToString());
        }
        //获取新的脚本内容
        private static string GetNewScriptContext(string className)
        {
            var script = new ScriptBuildHelp();

            script.WriteUsing("UnityEngine");
            script.WriteEmptyLine();
            var    data = AddNamespaceWindow.GetData();
            string name = data == null ? "UIFrame" : data.name;

            script.WriteNamespace(name);

            script.IndentTimes++;
            script.WriteClass(className, "MonoBehaviour");

            script.IndentTimes++;
            List <string> keys = new List <string>();

            keys.Add("void");
            script.WriteFun(keys, "Start");
            return(script.ToString());
        }
Example #10
0
        /// <summary>
        /// 获取Service层代码模板
        /// </summary>
        /// <returns></returns>
        public static string GetServiceCode()
        {
            string className = ToolData.ServiceName + ToolData.ServicePostfix;

            var build = new ScriptBuildHelp();

            build.WriteNamespace(ToolData.NamespaceBase + "." + ToolData.ServicePostfix);
            //interface
            build.IndentTimes++;
            build.WriteInterface("I" + className, "IInitService");
            build.ToContentEnd();
            //class
            build.WriteClass(className, "I" + className);
            //init函数
            build.IndentTimes++;
            List <string> initKey = new List <string>();

            initKey.Add("void");
            build.WriteFun(initKey, "Init", "", "Contexts contexts");
            //init 内容
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("//contexts.service.SetGameService" + className + "(this);", true);
            build.IndentTimes--;
            build.ToContentEnd();
            //GetPriority函数
            var key = new List <string>();

            key.Add("int");
            build.WriteFun(key, "GetPriority");

            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("return 0;", true);
            build.ToContentEnd();

            return(build.ToString());
        }