Пример #1
0
        private static XWorldGameManagerBase RegisterGameManager(Type managerClass)
        {
            XWorldGameManagerBase newManager = Activator.CreateInstance(managerClass) as XWorldGameManagerBase;

            if (newManager == null)
            {
                GameLogger.Error(LOG_CHANNEL.LOGIC, "Register manager " + managerClass.ToString() + " failed!");
                return(null);
            }

            GameLogger.DebugLog(LOG_CHANNEL.LOGIC, " Register manager " + managerClass.ToString());
            InsertManagerToList(newManager);
            newManager.InitManager();
            return(newManager);
        }
Пример #2
0
        public static T GetGameManager <T>() where T : class
        {
            Type classType = typeof(T);

            if (!classType.FullName.StartsWith("XWorld"))
            {
                return(null);
            }

            Type fullClassType = Type.GetType(classType.FullName);
            XWorldGameManagerBase findClass = FindManager(fullClassType);

            if (findClass == null)
            {
                findClass = RegisterGameManager(fullClassType);
            }

            return(findClass as T);
        }
Пример #3
0
        public static void RemoveGameManager(XWorldGameManagerBase gameManager)
        {
            if (gameManager == null)
            {
                return;
            }

            foreach (XWorldGameManagerBase item in m_lManagers)
            {
                if (item == null)
                {
                    continue;
                }

                if (item == gameManager)
                {
                    item.ShutDown();
                    m_lManagers.Remove(item);
                    break;
                }
            }
        }
Пример #4
0
 private static void InsertManagerToList(XWorldGameManagerBase manager)
 {
     m_lManagers.Add(manager);
 }