/// <summary> /// 获取一个Pool /// </summary> /// <param name="name"></param> /// <returns></returns> public ObjectPool GetObjectPool(string name) { ObjectPool pool; if (!cache.TryGetValue(name, out pool)) { pool = GameFactory.Create <ObjectPool>(name); cache.Add(name, pool); } return(pool); }
public T GetController <T>(string type) where T : UIController { UIController controller; if (controllerDic.TryGetValue(type, out controller) == false) { UI config = ConfigUI.Get(type); GameObject obj; controller = GameFactory.Create <T>(config.AssetbundleName, config.AssetName, out obj); if (controller == null) { controller = obj.AddComponent <T>(); } controller.Config = config; controllerDic.Add(type, controller); } return(controller as T); }
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); } }