Example #1
0
 public void ReleaseModule(LogicModule module)
 {
     if (module != null)
     {
         if (_modules.ContainsKey(module.Name))
         {
             _modules.Remove(module.Name);
             module.Release();
         }
         else
         {
             Debug.Log("ReleaseModule() dont has module");
         }
     }
     else
     {
         Debug.Log("ReleaseModule() module = null!");
     }
 }
Example #2
0
        public LogicModule CreateModule(string name)
        {
            LogicModule module = null;
            //Type type = Type.GetType(string.Format("{0}.{1}", _domain, name));
            Type type = Type.GetType(name);

            if (type != null)
            {
                var m = Activator.CreateInstance(type);
                module = m as LogicModule;
            }

            _modules.Add(name, module);

            if (_listenEvents.ContainsKey(name))
            {
                EventTable mgrEvent = null;
                mgrEvent = _listenEvents[name];
                _listenEvents.Remove(name);

                module.SetEventTable(mgrEvent);
            }

            module.Create();

            if (_cacheMessages.ContainsKey(name))
            {
                List <MessageObject> list = _cacheMessages[name];
                for (int i = 0; i < list.Count; i++)
                {
                    MessageObject msgobj = list[i];
                    module.HandleMessage(msgobj.msg, msgobj.args);
                }
                _cacheMessages.Remove(name);
            }

            return(module);
        }