Example #1
0
        public void DestroyManager()
        {
            IsActiveMonoMethod = false;

            if (codeStream != null)
            {
                codeStream.Close();
                codeStream = null;
            }

            if (appdomain != null)
            {
                appdomain.Invoke(MainClassName, "Destroy", null, null);
                appdomain = null;
            }

            if (assembly != null)
            {
                m_DestroyMethod.Invoke(null, null);
                assembly = null;
            }

            p0 = null;

            i_updateMethod      = null;
            i_fixedUpdateMethod = null;
            i_lateUpdateMethod  = null;

            m_mainMethod        = null;
            m_updateMethod      = null;
            m_fixedUpdateMethod = null;
            m_lateUpdateMethod  = null;
            m_DestroyMethod     = null;

            Instance = null;
        }
Example #2
0
 public void Awake()
 {
     Instance           = this;
     IsActiveMonoMethod = false;
 }
Example #3
0
        void Awake()
        {
            if (Instance == null)
            {
                Instance        = this;
                gameObject.name = "HFGlobal";
                DontDestroyOnLoad(gameObject);

                Clear();

                //添加游戏工厂
                gameObject.AddComponent <GameFactory>();

                //负责提供路径
                gameObject.AddComponent <PathManager>();

                //资源加载
                resourcesManager = GameFactory.Create <HFResourceManager>("ResourcesManager", true);
                resourcesManager.InitWithRootPath(PathManager.Instance.PersistentDataAssetBundlesPath, PathManager.Instance.StreamingAssetsAssetBundlesPath, "AssetBundles");

                //添加游戏运行环境 + 配置文件
                gameObject.AddComponent <GameEnvironment>();

                //2通知中心
                notificationCenter = GameFactory.Create <NotificationCenter>("NotificationCenter", true);

                //3网络
                socketManager = GameFactory.Create <HFSocketManager>("SocketManager", true);

                //4声音
                audioManager = GameFactory.Create <AudioManager>("AudioManager", true);

                //5UI
                uiManager = GameFactory.Create <UIManager>("UIManager", true);

                //6图片下载
                webImageManager = GameFactory.Create <WebImageManager>("WebImageManager", true);

                //7游戏设置控制器
                inputManager = GameFactory.Create <InputManager>("InputManager", true);

                //8对象池
                poolManager = GameFactory.Create <ObjectPoolManager>("ObjectPoolManager", true);

                //9热更新入口
                appDomainManager = GameFactory.Create <AppDomainManager>("AppDomainManager", true);

                //添加游戏循环者
                gameObject.AddComponent <GameLooper>();

                //添加时间控制者
                gameObject.AddComponent <GameTimer>();

                //添加状态检查者
                gameObject.AddComponent <GameStateChecker>();

                //工具箱
                gameObject.AddComponent <GameUtils>();

                //添加状态检查者
                gameObject.AddComponent <GameFlowController>();

                //游戏开始
                gameObject.AddComponent <GameStart>();
            }
            else
            {
                Destroy(gameObject);
            }
        }