Esempio n. 1
0
        /// <summary>
        /// 模块被启动的时候调用
        /// </summary>
        protected internal override void OnStart(IModuleManager t_IModuleManager)
        {
            //TODO:模块启动时候的一些操作

            var t_FSMArray = IListDataStructure.ToArray();

            for (int i = 0; i < t_FSMArray.Length; i++)
            {
                if (null != t_FSMArray[i] && false == t_FSMArray[i].IsRunning) //如果该状态机的状态为不运行状态,那么去调用状态机的启动方法
                {
                    t_FSMArray[i].OnStart(this);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取一个事件主题
        /// </summary>
        /// <param name="t_EventTopicName">事件主题名字</param>
        /// <returns>返回事件主题接口</returns>
        public IEventTopic GetEventTopic(string t_EventTopicName)
        {
            var         t_EventTopicArray = IListDataStructure.ToArray();
            IEventTopic t_Target          = null;

            for (int i = 0; i < t_EventTopicArray.Length; i++)
            {
                if (t_EventTopicArray[i].EventTopicName == t_EventTopicName)
                {
                    t_Target = t_EventTopicArray[i];
                    t_EventTopicArray[i].Weight++; //权重自加
                    IListDataStructure.Sort();     //重新排序
                    break;
                }
            }
            return(t_Target);
        }
        /// <summary>
        /// 模块管家销毁
        /// </summary>
        public void Destroy()
        {
            var t_ModuleArray = IListDataStructure.ToArray();

            for (int i = 0; i < t_ModuleArray.Length; i++)
            {
                if (null != t_ModuleArray[i])
                {
                    t_ModuleArray[i].OnDestroy(this);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 销毁所有的GameBox的组件
        /// </summary>
        /// <typeparam name="T">GameBox的组件类型</typeparam>
        /// <returns>返回GamBox的组件</returns>
        public void DestroyComponents <T>() where T : IComponent
        {
            var t_ComponentArray = IListDataStructure.ToArray();

            for (int i = 0; i < t_ComponentArray.Length; i++)
            {
                if (t_ComponentArray[i] is T)
                {
                    IListDataStructure.RemoveNode(component => component.Equals(t_ComponentArray[i]));
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 获取注册GameBox的组件数组
        /// </summary>
        /// <typeparam name="T">GameBox的组件类型</typeparam>
        /// <returns>返回GamBox的组件</returns>
        public T[] GetComponents <T>() where T : IComponent
        {
            List <T> t_Components     = new List <T>();
            var      t_ComponentArray = IListDataStructure.ToArray();

            for (int i = 0; i < t_ComponentArray.Length; i++)
            {
                if (t_ComponentArray[i] is T)
                {
                    t_Components.Add((T)t_ComponentArray[i]);
                }
            }
            IListDataStructure.Sort();
            return(0 < t_Components.Count ? t_Components.ToArray():null);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取GameBox的组件
        /// </summary>
        /// <typeparam name="T">GameBox的组件类型</typeparam>
        /// <returns>返回GamBox的组件</returns>
        public T GetComponent <T>() where T : IComponent
        {
            var t_ComponentArray = IListDataStructure.ToArray();

            for (int i = 0; i < t_ComponentArray.Length; i++)
            {
                if (t_ComponentArray[i] is T)
                {
                    t_ComponentArray[i].Weight++;
                    return((T)t_ComponentArray[i]);
                }
            }
            IListDataStructure.Sort();
            return(default(T));
        }