Exemplo n.º 1
0
 private void MainDataGUI()
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label("MainData", GUILayout.Width(LabelWidth));
     if (GUILayout.Button(Target.MainDataType, EditorGlobalTools.Styles.MiniPopup))
     {
         GenericMenu gm    = new GenericMenu();
         List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
         {
             return(type.IsSubclassOf(typeof(MainDataBase)));
         });
         gm.AddItem(new GUIContent("<None>"), Target.MainDataType == "<None>", () =>
         {
             Undo.RecordObject(target, "Set Main Data");
             Target.MainDataType = "<None>";
             HasChanged();
         });
         for (int i = 0; i < types.Count; i++)
         {
             int j = i;
             gm.AddItem(new GUIContent(types[j].FullName), Target.MainDataType == types[j].FullName, () =>
             {
                 Undo.RecordObject(target, "Set Main Data");
                 Target.MainDataType = types[j].FullName;
                 HasChanged();
             });
         }
         gm.ShowAsContext();
     }
     GUILayout.EndHorizontal();
 }
Exemplo n.º 2
0
        private void ActiveComponentSkip()
        {
            Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(StringValue);

            if (type != null)
            {
                Component component = Target.GetComponent(type);
                Behaviour behaviour = component as Behaviour;
                Collider  collider  = component as Collider;
                Renderer  renderer  = component as Renderer;
                if (behaviour)
                {
                    behaviour.enabled = BoolValue;
                }
                else if (collider)
                {
                    collider.enabled = BoolValue;
                }
                else if (renderer)
                {
                    renderer.enabled = BoolValue;
                }
            }
            else
            {
                Log.Error("步骤控制者:未获取到组件类型 " + StringValue + " !");
            }
        }
        protected override void OnInspectorDefaultGUI()
        {
            base.OnInspectorDefaultGUI();

            if (Targets.Length > 1)
            {
                EditorGUILayout.HelpBox("FSM cannot be multi-edited.", MessageType.None);
                return;
            }

            GUI.enabled = !EditorApplication.isPlaying;

            GUILayout.BeginHorizontal();
            EditorGUILayout.HelpBox("Finite state machine!", MessageType.Info);
            GUILayout.EndHorizontal();

            PropertyField(nameof(FSM.IsAutoRegister), "Auto Register");
            PropertyField(nameof(FSM.Name), "Name");
            PropertyField(nameof(FSM.Group), "Group");

            _stateList.DoLayoutList();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Data", GUILayout.Width(LabelWidth));
            if (GUILayout.Button(Target.Data, EditorStyles.popup, GUILayout.Width(EditorGUIUtility.currentViewWidth - LabelWidth - 25)))
            {
                GenericMenu gm = new GenericMenu();
                gm.AddItem(new GUIContent("<None>"), Target.Data == "<None>", () =>
                {
                    Undo.RecordObject(target, "Set FSM Data Class");
                    Target.Data = "<None>";
                    HasChanged();
                });
                gm.AddItem(new GUIContent("<New Data Script>"), false, () =>
                {
                    EditorGlobalTools.CreateScriptFormTemplate(EditorPrefsTable.Script_FSMData_Folder, "FSMData", "FSMDataTemplate");
                });
                gm.AddSeparator("");
                List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                {
                    return(type.IsSubclassOf(typeof(FSMDataBase)) && !type.IsAbstract);
                });
                for (int i = 0; i < types.Count; i++)
                {
                    int j = i;
                    gm.AddItem(new GUIContent(types[j].FullName), Target.Data == types[j].FullName, () =>
                    {
                        Undo.RecordObject(target, "Set FSM Data Class");
                        Target.Data = types[j].FullName;
                        HasChanged();
                    });
                }
                gm.ShowAsContext();
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;

            OnArgsGUI();
        }
Exemplo n.º 4
0
        internal override void OnPreparatory()
        {
            base.OnPreparatory();

            //流程初始化
            foreach (var procedureInstance in _procedureInstances)
            {
                procedureInstance.Value.OnInit();
            }

            //进入默认流程
            if (DefaultProcedure != "")
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(DefaultProcedure);
                if (type != null)
                {
                    if (_procedureInstances.ContainsKey(type))
                    {
                        _currentProcedure = _procedureInstances[type];
                        _currentProcedure.OnEnter(null);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Procedure, "进入流程失败:不存在流程 " + type.Name + " 或者流程未激活!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Procedure, "进入流程失败:丢失流程 " + DefaultProcedure + " !");
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 创建步骤助手
 /// </summary>
 private StepHelper CreateHelper(StepContent content, StepHelperTask task)
 {
     if (!string.IsNullOrEmpty(content.Helper) && content.Helper != "<None>")
     {
         Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(content.Helper);
         if (type != null)
         {
             StepHelper helper = Activator.CreateInstance(type) as StepHelper;
             helper.Parameters = content.Parameters;
             for (int i = 0; i < helper.Parameters.Count; i++)
             {
                 if (helper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                 {
                     if (_targets.ContainsKey(helper.Parameters[i].GameObjectGUID))
                     {
                         helper.Parameters[i].GameObjectValue = _targets[helper.Parameters[i].GameObjectGUID].gameObject;
                     }
                 }
             }
             helper.Content = content;
             helper.Target  = content.Target.GetComponent <StepTarget>();
             helper.Task    = task;
             helper.OnInit();
             return(helper);
         }
         else
         {
             Log.Error(string.Format("步骤控制器:步骤 {0}.{1} 的助手 {2} 丢失!", _currentStepIndex + 1, _currentContent.Name, _currentContent.Helper));
         }
     }
     return(null);
 }
Exemplo n.º 6
0
        protected override void OnInspectorDefaultGUI()
        {
            base.OnInspectorDefaultGUI();

            GUI.enabled = !EditorApplication.isPlaying;

            GUILayout.BeginHorizontal();
            GUILayout.Label("InputDevice ");
            if (GUILayout.Button(Target.InputDeviceType, EditorGlobalTools.Styles.MiniPopup))
            {
                GenericMenu gm    = new GenericMenu();
                List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                {
                    return(type.IsSubclassOf(typeof(InputDeviceBase)) && !type.IsAbstract);
                });
                for (int i = 0; i < types.Count; i++)
                {
                    int j = i;
                    gm.AddItem(new GUIContent(types[j].FullName), Target.InputDeviceType == types[j].FullName, () =>
                    {
                        Undo.RecordObject(target, "Set InputDevice");
                        Target.InputDeviceType = types[j].FullName;
                        HasChanged();
                    });
                }
                gm.ShowAsContext();
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;
        }
Exemplo n.º 7
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            ProcedureManager manager = Module as ProcedureManager;

            //创建所有已激活的流程对象
            for (int i = 0; i < manager.ActivatedProcedures.Count; i++)
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(manager.ActivatedProcedures[i]);
                if (type != null)
                {
                    if (type.IsSubclassOf(typeof(ProcedureBase)))
                    {
                        if (!Procedures.ContainsKey(type))
                        {
                            Procedures.Add(type, Activator.CreateInstance(type) as ProcedureBase);
                            ProcedureTypes.Add(type);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Procedure, "创建流程失败:流程 " + manager.ActivatedProcedures[i] + " 必须继承至流程基类:ProcedureBase!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Procedure, "创建流程失败:丢失流程 " + manager.ActivatedProcedures[i] + "!");
                }
            }
            _defaultProcedure = manager.DefaultProcedure;
        }
Exemplo n.º 8
0
 /// <summary>
 /// 更新步骤助手的名称
 /// </summary>
 internal void RefreshHelperName()
 {
     if (Helper == "<None>")
     {
         HelperName = "未设置助手";
     }
     else
     {
         Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(Helper);
         if (type == null)
         {
             HelperName = "无效的助手";
         }
         else
         {
             CustomHelperAttribute helper = type.GetCustomAttribute <CustomHelperAttribute>();
             if (helper != null)
             {
                 HelperName = helper.Name;
             }
             else
             {
                 HelperName = type.FullName;
             }
         }
     }
 }
        protected override void OnEnable()
        {
            base.OnEnable();

            _components.Clear();
            _componentInfos.Clear();
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies((type) =>
            {
                return(type.IsSubclassOf(typeof(ECS_Component)) && !type.IsAbstract);
            });

            for (int i = 0; i < types.Count; i++)
            {
                _components.Add(types[i]);
                _componentInfos.Add(types[i], new ECS_ComponentInfo(types[i]));
            }

            _systems.Clear();
            _systemInfos.Clear();
            types = ReflectionToolkit.GetTypesInRunTimeAssemblies((type) =>
            {
                return(type.IsSubclassOf(typeof(ECS_System)) && !type.IsAbstract);
            });
            for (int i = 0; i < types.Count; i++)
            {
                _systems.Add(types[i]);
                _systemInfos.Add(types[i], new ECS_SystemInfo(types[i], _componentInfos));
            }

            Entity = null;
        }
        public DebuggerScene()
        {
            Type        baseType = typeof(DebuggerComponentBase);
            List <Type> types    = ReflectionToolkit.GetTypesInRunTimeAssemblies();

            for (int i = 0; i < types.Count; i++)
            {
                if (types[i].IsSubclassOf(baseType))
                {
                    CustomDebuggerAttribute attr = types[i].GetCustomAttribute <CustomDebuggerAttribute>();
                    if (attr != null)
                    {
                        _debuggerComponents.Add(attr.InspectedType, types[i]);
                    }
                }
            }

            baseType = typeof(Component);
            for (int i = 0; i < types.Count; i++)
            {
                if (types[i].IsSubclassOf(baseType))
                {
                    _componentTypes.Add(types[i]);
                }
            }
        }
Exemplo n.º 11
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            _helper = Helper as IInputHelper;

            //加载输入设备
            Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(InputDeviceType);

            if (type != null)
            {
                if (type.IsSubclassOf(typeof(InputDeviceBase)))
                {
                    _inputDevice = Activator.CreateInstance(type) as InputDeviceBase;
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Input, "加载输入设备失败:输入设备类 " + InputDeviceType + " 必须继承至输入设备基类:InputDeviceBase!");
                }
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.Input, "加载输入设备失败:丢失输入设备类 " + InputDeviceType + "!");
            }
        }
Exemplo n.º 12
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            //创建所有已激活的流程对象
            for (int i = 0; i < ActivatedProcedures.Count; i++)
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(ActivatedProcedures[i]);
                if (type != null)
                {
                    if (type.IsSubclassOf(typeof(ProcedureBase)))
                    {
                        if (!_procedureInstances.ContainsKey(type))
                        {
                            _procedureInstances.Add(type, Activator.CreateInstance(type) as ProcedureBase);
                            _procedureTypes.Add(type);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Procedure, "创建流程失败:流程 " + ActivatedProcedures[i] + " 必须继承至流程基类:ProcedureBase!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Procedure, "创建流程失败:丢失流程 " + ActivatedProcedures[i] + "!");
                }
            }
        }
Exemplo n.º 13
0
 private void FSMSkip()
 {
     if (StringValue != "<None>")
     {
         Target.GetComponent <FSM>().SwitchState(ReflectionToolkit.GetTypeInRunTimeAssemblies(StringValue));
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            _module     = Module as EntityManager;
            _entityRoot = _module.transform.Find("EntityRoot");

            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(EntityLogicBase)) && !type.IsAbstract);
            });

            for (int i = 0; i < types.Count; i++)
            {
                EntityResourceAttribute attribute = types[i].GetCustomAttribute <EntityResourceAttribute>();
                if (attribute != null)
                {
                    Entities.Add(types[i], new List <EntityLogicBase>());

                    GameObject group = new GameObject(types[i].Name + "[Group]");
                    group.transform.SetParent(_entityRoot);
                    group.transform.localPosition = Vector3.zero;
                    group.transform.localRotation = Quaternion.identity;
                    group.transform.localScale    = Vector3.one;
                    group.SetActive(true);
                    _entitiesGroup.Add(types[i], group);

                    ObjectPools.Add(types[i], new Queue <GameObject>());
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Entity, "创建实体逻辑对象失败:实体逻辑类 " + types[i].Name + " 丢失 EntityResourceAttribute 标记!");
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 初始化模块
        /// </summary>
        public virtual void OnInitialization()
        {
            if (HelperType != "<None>")
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(HelperType);
                if (type != null)
                {
                    if (typeof(IInternalModuleHelper).IsAssignableFrom(type))
                    {
                        _helper        = Activator.CreateInstance(type) as H;
                        _helper.Module = this;
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Main, "创建内置模块助手失败:内置模块助手类 " + HelperType + " 必须实现该模块对应的助手接口!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Main, "创建内置模块助手失败:丢失内置模块助手类 " + HelperType + "!");
                }
            }

            if (_helper != null)
            {
                _helper.OnInitialization();
            }
        }
Exemplo n.º 16
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            if (IsEnableDebugger)
            {
                //创建调试器
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(DebuggerType);
                if (type != null)
                {
                    if (type == typeof(Debugger) || type.IsSubclassOf(typeof(Debugger)))
                    {
                        _debugger = Activator.CreateInstance(type) as Debugger;
                        _debugger.OnInit(DebuggerSkin);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Debug, "创建调试器失败:调试器类 " + DebuggerType + " 必须继承至:Debugger!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Debug, "创建调试器失败:丢失调试器类 " + DebuggerType + "!");
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 助手准备工作
        /// </summary>
        public void OnPreparatory()
        {
            //流程初始化
            foreach (var procedure in Procedures)
            {
                procedure.Value.OnInit();
            }

            //进入默认流程
            if (_defaultProcedure != "")
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(_defaultProcedure);
                if (type != null)
                {
                    if (Procedures.ContainsKey(type))
                    {
                        CurrentProcedure = Procedures[type];
                        CurrentProcedure.OnEnter(null);
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Procedure, "进入流程失败:不存在流程 " + type.Name + " 或者流程未激活!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Procedure, "进入流程失败:丢失流程 " + _defaultProcedure + " !");
                }
            }
        }
Exemplo n.º 18
0
        protected override void OnDefaultEnable()
        {
            base.OnDefaultEnable();

            _module = Target as InternalModuleBase <H>;
            _types  = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(typeof(H).IsAssignableFrom(type) && typeof(H) != type);
            });
        }
Exemplo n.º 19
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(ECS_System)));
            });

            for (int i = 0; i < types.Count; i++)
            {
                Systems.Add(types[i], Activator.CreateInstance(types[i]) as ECS_System);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(DataSetBase)));
            });

            for (int i = 0; i < types.Count; i++)
            {
                DataSets.Add(types[i], new List <DataSetBase>());
            }
        }
Exemplo n.º 21
0
        private void LicenseGUI()
        {
            GUILayout.BeginVertical(EditorGlobalTools.Styles.Box);

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            _showLicense = EditorGUILayout.Foldout(_showLicense, "License", true);
            GUILayout.EndHorizontal();

            if (_showLicense)
            {
                GUILayout.BeginHorizontal();
                Toggle(Target.IsPermanentLicense, out Target.IsPermanentLicense, "Permanent License");
                GUILayout.EndHorizontal();

                if (!Target.IsPermanentLicense)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Licenser");
                    if (GUILayout.Button(Target.LicenserType, EditorGlobalTools.Styles.MiniPopup))
                    {
                        GenericMenu gm    = new GenericMenu();
                        List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                        {
                            return(type.IsSubclassOf(typeof(LicenserBase)) && !type.IsAbstract);
                        });
                        gm.AddItem(new GUIContent("<None>"), Target.LicenserType == "<None>", () =>
                        {
                            Undo.RecordObject(target, "Set Licenser");
                            Target.LicenserType = "<None>";
                            HasChanged();
                        });
                        for (int i = 0; i < types.Count; i++)
                        {
                            int j = i;
                            gm.AddItem(new GUIContent(types[j].FullName), Target.LicenserType == types[j].FullName, () =>
                            {
                                Undo.RecordObject(target, "Set Licenser");
                                Target.LicenserType = types[j].FullName;
                                HasChanged();
                            });
                        }
                        gm.ShowAsContext();
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.EndVertical();
        }
Exemplo n.º 22
0
        /// <summary>
        /// 初始化助手
        /// </summary>
        public void OnInitialization()
        {
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(EventHandlerBase)) && !type.IsAbstract);
            });

            for (int i = 0; i < types.Count; i++)
            {
                EventHandlerList1.Add(types[i], null);
                EventHandlerList2.Add(types[i], null);
                EventHandlerList3.Add(types[i], null);
            }
        }
        protected override void OnInspectorRuntimeGUI()
        {
            base.OnInspectorRuntimeGUI();

            if (Targets.Length > 1)
            {
                return;
            }

            GUILayout.BeginHorizontal();
            string currentStateName = "<None>";

            if (Target.CurrentState != null)
            {
                FiniteStateNameAttribute nameAttribute = Target.CurrentState.GetType().GetCustomAttribute <FiniteStateNameAttribute>();
                currentStateName = nameAttribute != null ? nameAttribute.Name : Target.CurrentState.GetType().FullName;
            }
            GUILayout.Label("Current State: " + currentStateName);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("States: " + _stateNames.Count);
            GUILayout.EndHorizontal();

            foreach (var state in _stateNames)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.Label(state.Value);
                GUILayout.FlexibleSpace();
                GUI.enabled = Target.CurrentState.GetType().FullName != state.Key;
                if (GUILayout.Button("Switch", EditorStyles.miniButton))
                {
                    Target.SwitchState(ReflectionToolkit.GetTypeInRunTimeAssemblies(state.Key));
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Renewal", EditorStyles.miniButtonLeft))
            {
                Target.Renewal();
            }
            if (GUILayout.Button("Final", EditorStyles.miniButtonRight))
            {
                Target.Final();
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 24
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            //注册所有数据集
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(DataSetBase)));
            });

            for (int i = 0; i < types.Count; i++)
            {
                _dataSets.Add(types[i], new List <DataSetBase>());
            }
        }
Exemplo n.º 25
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            //加载通信协议通道
            for (int i = 0; i < ChannelTypes.Count; i++)
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(ChannelTypes[i]);
                if (type != null)
                {
                    if (type.IsSubclassOf(typeof(ProtocolChannelBase)))
                    {
                        if (!_protocolChannels.ContainsKey(type))
                        {
                            _protocolChannels.Add(type, Activator.CreateInstance(type) as ProtocolChannelBase);
                        }
                    }
                    else
                    {
                        throw new HTFrameworkException(HTFrameworkModule.Network, "加载通信协议通道失败:通信协议通道类 " + ChannelTypes[i] + " 必须实现接口:IProtocolChannel!");
                    }
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Network, "加载通信协议通道失败:丢失通信协议通道类 " + ChannelTypes[i] + "!");
                }
            }

            //初始化通道
            foreach (var channel in _protocolChannels)
            {
                channel.Value.OnInitialization();
                channel.Value.SendMessageEvent += (cha) =>
                {
                    SendMessageEvent?.Invoke(cha);
                };
                channel.Value.ReceiveMessageEvent += (cha, message) =>
                {
                    ReceiveMessageEvent?.Invoke(cha, message);
                };
                channel.Value.DisconnectServerEvent += (cha) =>
                {
                    DisconnectServerEvent?.Invoke(cha);
                };
            }
        }
Exemplo n.º 26
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            //注册所有存在的事件
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(EventHandlerBase)));
            });

            for (int i = 0; i < types.Count; i++)
            {
                _eventHandlerList1.Add(types[i], null);
                _eventHandlerList2.Add(types[i], null);
                _eventHandlerList3.Add(types[i], null);
            }
        }
Exemplo n.º 27
0
        private void ChangeHelper()
        {
            GenericMenu gm    = new GenericMenu();
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(HelperInterface.IsAssignableFrom(type) && HelperInterface != type);
            });

            for (int i = 0; i < types.Count; i++)
            {
                int j = i;
                gm.AddItem(new GUIContent(types[j].FullName), _module.HelperType == types[j].FullName, () =>
                {
                    _module.HelperType = types[j].FullName;
                });
            }
            gm.ShowAsContext();
        }
Exemplo n.º 28
0
        private void LicenseInitialization()
        {
            if (IsPermanentLicense)
            {
                _isLicenseEnd  = true;
                _isLicensePass = true;
            }
            else
            {
                if (LicenserType != "<None>")
                {
                    Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(LicenserType);
                    if (type != null)
                    {
                        if (type.IsSubclassOf(typeof(LicenserBase)))
                        {
                            _licenser = Activator.CreateInstance(type) as LicenserBase;
                            _licenser.OnInitialization();
                        }
                        else
                        {
                            Log.Error(string.Format("创建授权者失败:授权者类 {0} 必须继承至基类:LicenserBase!", LicenserType));
                        }
                    }
                    else
                    {
                        Log.Error(string.Format("创建授权者失败:丢失授权者类 {0}!", LicenserType));
                    }
                }
                else
                {
                    Log.Error("已启用授权验证,但授权者类型不能为 <None>!");
                }

                _promptStyle                  = new GUIStyle();
                _promptStyle.alignment        = TextAnchor.MiddleCenter;
                _promptStyle.normal.textColor = Color.red;
                _promptStyle.fontSize         = 30;

                _isLicenseEnd  = false;
                _isLicensePass = false;
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// 加载输入设备
 /// </summary>
 /// <param name="deviceType">输入设备类型</param>
 public void LoadDevice(string deviceType)
 {
     Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(deviceType);
     if (type != null)
     {
         if (type.IsSubclassOf(typeof(InputDeviceBase)))
         {
             Device = Activator.CreateInstance(type) as InputDeviceBase;
         }
         else
         {
             throw new HTFrameworkException(HTFrameworkModule.Input, "加载输入设备失败:输入设备类 " + deviceType + " 必须继承至输入设备基类:InputDeviceBase!");
         }
     }
     else
     {
         throw new HTFrameworkException(HTFrameworkModule.Input, "加载输入设备失败:丢失输入设备类 " + deviceType + "!");
     }
 }
Exemplo n.º 30
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            for (int i = 0; i < DefineEntityNames.Count; i++)
            {
                if (!_defineEntities.ContainsKey(DefineEntityNames[i]))
                {
                    _defineEntities.Add(DefineEntityNames[i], DefineEntityTargets[i]);
                }
            }

            _entityRoot = transform.Find("EntityRoot");

            //创建所有实体的逻辑对象
            List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
            {
                return(type.IsSubclassOf(typeof(EntityLogicBase)));
            });

            for (int i = 0; i < types.Count; i++)
            {
                EntityResourceAttribute attribute = types[i].GetCustomAttribute <EntityResourceAttribute>();
                if (attribute != null)
                {
                    _entities.Add(types[i], new List <EntityLogicBase>());

                    GameObject group = new GameObject(types[i].Name + "[Group]");
                    group.transform.SetParent(_entityRoot);
                    group.transform.localPosition = Vector3.zero;
                    group.transform.localRotation = Quaternion.identity;
                    group.transform.localScale    = Vector3.one;
                    group.SetActive(true);
                    _entitiesGroup.Add(types[i], group);

                    _objectPool.Add(types[i], new Queue <GameObject>());
                }
                else
                {
                    throw new HTFrameworkException(HTFrameworkModule.Entity, "创建实体逻辑对象失败:实体逻辑类 " + types[i].Name + " 丢失 EntityResourceAttribute 标记!");
                }
            }
        }