Example #1
0
        private void Start()
        {
            module = FrameworkModule.CreatInstance <ECSModule>("", "");
            module.SubscribeSystem(new PlayerSystem(module));
            module.SubscribeSystem(new PCSystem(module));

            var player = module.CreateEntity <SimpleEntity>();

            player.AddComponent <PlayerComponent>();
            var playerRO = player.AddComponent <RotaComponet>();

            playerRO.go      = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube);
            playerRO.go.name = "Player";
            playerRO.go.transform.position = new UnityEngine.Vector3(0, -2, 0);

            var pc = module.CreateEntity <SimpleEntity>();

            pc.AddComponent <SpeedComponent>();
            pc.AddComponent <PCComponent>();
            var pcRO = pc.AddComponent <RotaComponet>();

            pcRO.go      = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube);
            pcRO.go.name = "Pc";
            pcRO.go.transform.position = new UnityEngine.Vector3(0, 2, 0);
        }
Example #2
0
 public static void RegisterComponent(FrameworkModule frameworkComponent)
 {
     if (HasComponent(frameworkComponent.GetType()))
     {
         Debug.LogError("Can't Regist " + frameworkComponent.GetType().FullName + "twice");
     }
     else
     {
         _FrameworkComponents.AddLast(frameworkComponent);
     }
 }
Example #3
0
 private void Start()
 {
     mo = FrameworkModule.CreatInstance <CoroutineModule>("", "");
     this.Sequence(EnvironmentType.Ev0)
     .Repeat((r) => {
         r.Sequence((s) =>
         {
             s.TimeSpan(new TimeSpan(0, 0, 5))
             .Event(() => { Log.L("GG"); })
             .OnCompelete(() => { Log.L("comp"); })
             .OnBegin(() => { Log.L("begin"); });
         })
         ;
     }, 2)
     .TimeSpan(new TimeSpan(0, 0, 5))
     .OnCompelete((ss) => { /*ss.Reset();*/ })
     .OnRecyle(() => { Log.L(""); })
     .Run(mo);
 }
Example #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Initialize framework
            frameworkModule = FrameworkModule.Instance;
            frameworkModule.FrameworkForm = new UltraKitTestbed();
            frameworkModule.Initialize();

            frameworkModule.FrameworkForm.Visible = true;
            frameworkModule.FrameworkForm.BringToFront();
            frameworkModule.FrameworkForm.Activate();

            // Process command line
            //Script.ArkLua.Instance.ProcessCommadnLine(args);

            Application.Idle += new EventHandler(OnApplicationIdle);
            Application.Run(frameworkModule.FrameworkForm);

            frameworkModule.UnInitialize();
        }
Example #5
0
        private void Start()

        {
            fsm = FrameworkModule.CreatInstance <FsmModule>("", "");
            State1 s1 = new State1();
            State2 s2 = new State2();

            fsm.SubscribeState(s1);
            fsm.enterState = s1;
            fsm.SubscribeState(s2);
            // fsm.exitState = s2;
            var val = fsm.CreateConditionValue <bool>("bool", true);

            var t1 = fsm.CreateTransition(s1, s2);
            var t2 = fsm.CreateTransition(s2, s1);

            t1.BindCondition(fsm.CreateCondition <bool>("bool", false, CompareType.Equals));
            t2.BindCondition(fsm.CreateCondition <bool>(val, true, CompareType.Equals));

            fsm.Start();
        }
Example #6
0
        /// <summary>
        /// 获取所有模块
        /// </summary>
        /// <param name="controllers"></param>
        /// <returns></returns>
        private static List <FrameworkModule> GetAllModules(List <Type> controllers)
        {
            var modules = new List <FrameworkModule>();

            foreach (var ctrl in controllers)
            {
                var pubattr1  = ctrl.GetCustomAttributes(typeof(PublicAttribute), false);
                var pubattr12 = ctrl.GetCustomAttributes(typeof(AllowAnonymousAttribute), false);
                var rightattr = ctrl.GetCustomAttributes(typeof(AllRightsAttribute), false);
                var debugattr = ctrl.GetCustomAttributes(typeof(DebugOnlyAttribute), false);
                var areaattr  = ctrl.GetCustomAttributes(typeof(AreaAttribute), false);
                var model     = new FrameworkModule
                {
                    ClassName = ctrl.Name.Replace("Controller", string.Empty)
                };
                if (ctrl.Namespace == "WalkingTec.Mvvm.Mvc")
                {
                    continue;
                }
                if (areaattr.Length == 0 && model.ClassName == "Home")
                {
                    continue;
                }
                if (pubattr1.Length > 0 || pubattr12.Length > 0 || rightattr.Length > 0 || debugattr.Length > 0)
                {
                    model.IgnorePrivillege = true;
                }
                if (typeof(BaseApiController).IsAssignableFrom(ctrl))
                {
                    model.IsApi = true;
                }
                model.NameSpace = ctrl.Namespace;
                //获取controller上标记的ActionDescription属性的值
                var attrs = ctrl.GetCustomAttributes(typeof(ActionDescriptionAttribute), false);
                if (attrs.Length > 0)
                {
                    var ada     = attrs[0] as ActionDescriptionAttribute;
                    var nameKey = ada.GetDescription(ctrl);
                    model.ModuleName = nameKey;
                }
                else
                {
                    model.ModuleName = model.ClassName;
                }
                //获取该controller下所有的方法
                var methods = ctrl.GetMethods(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance);
                //过滤掉/Login/Login方法和特殊方法
                if (model.ClassName.ToLower() == "login")
                {
                    methods = methods.Where(x => x.IsSpecialName == false && x.Name.ToLower() != "login").ToArray();
                }
                else
                {
                    methods = methods.Where(x => x.IsSpecialName == false).ToArray();
                }
                model.Actions = new List <FrameworkAction>();
                //循环所有方法
                foreach (var method in methods)
                {
                    var pubattr2   = method.GetCustomAttributes(typeof(PublicAttribute), false);
                    var pubattr22  = method.GetCustomAttributes(typeof(AllowAnonymousAttribute), false);
                    var arattr2    = method.GetCustomAttributes(typeof(AllRightsAttribute), false);
                    var debugattr2 = method.GetCustomAttributes(typeof(DebugOnlyAttribute), false);
                    var postAttr   = method.GetCustomAttributes(typeof(HttpPostAttribute), false);
                    //如果不是post的方法,则添加到controller的action列表里
                    if (postAttr.Length == 0)
                    {
                        var action = new FrameworkAction
                        {
                            Module     = model,
                            MethodName = method.Name
                        };
                        if (pubattr2.Length > 0 || pubattr22.Length > 0 || arattr2.Length > 0 || debugattr2.Length > 0)
                        {
                            action.IgnorePrivillege = true;
                        }

                        var attrs2 = method.GetCustomAttributes(typeof(ActionDescriptionAttribute), false);
                        if (attrs2.Length > 0)
                        {
                            var ada     = attrs2[0] as ActionDescriptionAttribute;
                            var nameKey = ada.GetDescription(ctrl);
                            action.ActionName = nameKey;
                        }
                        else
                        {
                            action.ActionName = action.MethodName;
                        }
                        var pars = method.GetParameters();
                        if (pars != null && pars.Length > 0)
                        {
                            action.ParasToRunTest = new List <string>();
                            foreach (var par in pars)
                            {
                                action.ParasToRunTest.Add(par.Name);
                            }
                        }
                        model.Actions.Add(action);
                    }
                }
                //再次循环所有方法
                foreach (var method in methods)
                {
                    var pubattr2   = method.GetCustomAttributes(typeof(PublicAttribute), false);
                    var pubattr22  = method.GetCustomAttributes(typeof(AllowAnonymousAttribute), false);
                    var arattr2    = method.GetCustomAttributes(typeof(AllRightsAttribute), false);
                    var debugattr2 = method.GetCustomAttributes(typeof(DebugOnlyAttribute), false);

                    var postAttr = method.GetCustomAttributes(typeof(HttpPostAttribute), false);
                    //找到post的方法且没有同名的非post的方法,添加到controller的action列表里
                    if (postAttr.Length > 0 && model.Actions.Where(x => x.MethodName.ToLower() == method.Name.ToLower()).FirstOrDefault() == null)
                    {
                        if (method.Name.ToLower().StartsWith("dobatch"))
                        {
                            if (model.Actions.Where(x => "do" + x.MethodName.ToLower() == method.Name.ToLower()).FirstOrDefault() != null)
                            {
                                continue;
                            }
                        }
                        var action = new FrameworkAction
                        {
                            Module     = model,
                            MethodName = method.Name
                        };
                        if (pubattr2.Length > 0 || pubattr22.Length > 0 || arattr2.Length > 0 || debugattr2.Length > 0)
                        {
                            action.IgnorePrivillege = true;
                        }
                        var attrs2 = method.GetCustomAttributes(typeof(ActionDescriptionAttribute), false);
                        if (attrs2.Length > 0)
                        {
                            var    ada     = attrs2[0] as ActionDescriptionAttribute;
                            string nameKey = ada.GetDescription(ctrl);
                            action.ActionName = nameKey;
                        }
                        else
                        {
                            action.ActionName = action.MethodName;
                        }
                        model.Actions.Add(action);
                    }
                }
                if (model.Actions != null && model.Actions.Count() > 0)
                {
                    if (areaattr.Length > 0)
                    {
                        string areaName  = (areaattr[0] as AreaAttribute).RouteValue;
                        var    existArea = modules.Where(x => x.Area?.AreaName == areaName).Select(x => x.Area).FirstOrDefault();
                        if (existArea == null)
                        {
                            model.Area = new FrameworkArea
                            {
                                AreaName = (areaattr[0] as AreaAttribute).RouteValue,
                                Prefix   = (areaattr[0] as AreaAttribute).RouteValue,
                            };
                        }
                        else
                        {
                            model.Area = existArea;
                        }
                    }
                    modules.Add(model);
                }
            }

            return(modules);
        }
Example #7
0
        /// <summary>
        /// 同步Actions
        /// </summary>
        /// <param name="newActions"></param>
        /// <param name="oldActions"></param>
        /// <param name="model"></param>
        /// <param name="DC"></param>
        private static void SycActions(List <FrameworkAction> newActions, List <FrameworkAction> oldActions, FrameworkModule model, IDataContext DC)
        {
            var ToRemove = new List <FrameworkAction>();
            var ToAdd    = new List <FrameworkAction>();

            foreach (var oldItem in oldActions)
            {
                bool exist = false;
                foreach (var newItem in newActions)
                {
                    if (oldItem.MethodName == newItem.MethodName)
                    {
                        exist = true;
                        break;
                    }
                }
                if (exist == false)
                {
                    ToRemove.Add(oldItem);
                }
            }
            foreach (var newItem in newActions)
            {
                bool exist = false;
                foreach (var oldItem in oldActions)
                {
                    if (oldItem.MethodName == newItem.MethodName)
                    {
                        oldItem.ActionName = newItem.ActionName;
                        exist = true;
                        break;
                    }
                }
                if (exist == false)
                {
                    ToAdd.Add(newItem);
                }
            }
            foreach (var remove in ToRemove)
            {
                DC.Set <FrameworkAction>().Remove(remove);
            }
            foreach (var add in ToAdd)
            {
                add.ModuleId = model.ID;
                FrameworkAction act = new FrameworkAction();
                act.ModuleId       = model.ID;
                act.MethodName     = add.MethodName;
                act.Parameter      = add.Parameter;
                act.ParasToRunTest = add.ParasToRunTest;
                act.ActionName     = add.ActionName;
                DC.Set <FrameworkAction>().Add(act);
            }
        }