Esempio n. 1
0
        private static void LoadLuaAssetList(string group, List <RemoteConfig.AssetInfo> assetInfoList, Action <string, List <RemoteConfig.AssetInfo> > callback)
        {
            List <string> list = new List <string>();

            for (int i = 0; i < assetInfoList.Count; i++)
            {
                RemoteConfig.AssetInfo assetInfo = assetInfoList[i];
                if (assetInfo.url.Contains("_lua"))
                {
                    if (CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5))
                    {
                        string cachedProgramAssetUrl = CacheManager.GetCachedProgramAssetUrl(assetInfo.url);
                        list.Add(cachedProgramAssetUrl);
                    }
                    else
                    {
                        CacheManager.DeleteUnmatchCacheFile(assetInfo.name);
                        list.Add(assetInfo.url);
                    }
                }
            }
            AssetManager._assetLoader.LoadLuaAssetList(list, delegate(List <string> pLuaAssetUrlList)
            {
                callback(group, assetInfoList);
            });
        }
Esempio n. 2
0
        public static void LoadProgramAssetList(string group, List <RemoteConfig.AssetInfo> assetInfoList, Action <string, List <RemoteConfig.AssetInfo> > callback)
        {
            List <RemoteConfig.AssetInfo> list = new List <RemoteConfig.AssetInfo>();

            for (int i = 0; i < assetInfoList.Count; i++)
            {
                RemoteConfig.AssetInfo assetInfo = assetInfoList[i];
                if (PandoraSettings.UseStreamingAssets || !CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5))
                {
                    CacheManager.DeleteUnmatchCacheFile(assetInfo.name);
                    assetInfo.url = CacheManager.GetAssetRealUrl(assetInfo.url);
                    list.Add(assetInfo);
                }
            }
            if (list.Count == 0)
            {
                callback(group, assetInfoList);
            }
            else
            {
                CacheManager._cacheLoader.LoadProgramAssetList(group, list, delegate(List <string> pAssetList)
                {
                    CacheManager.OnLoadProgramAssetList(assetInfoList);
                    callback(group, assetInfoList);
                });
            }
        }
Esempio n. 3
0
 private static void OnLoadProgramAssetList(List <RemoteConfig.AssetInfo> assetInfoList)
 {
     for (int i = 0; i < assetInfoList.Count; i++)
     {
         RemoteConfig.AssetInfo assetInfo = assetInfoList[i];
         CacheManager.RefreshProgramAssetMeta(assetInfo.name, assetInfo.size, assetInfo.md5);
     }
 }
Esempio n. 4
0
        public static void CreatePanel(string name, Action <int> callback)
        {
            string panelAssetFullName = PanelManager.GetPanelAssetFullName(name);

            RemoteConfig.AssetInfo assetInfo = Pandora.Instance.GetRemoteConfig().GetAssetInfo(panelAssetFullName);
            AssetManager.GetPanelGameObject(assetInfo, delegate(GameObject go)
            {
                PanelManager.OnGetGameObject(go, callback);
            });
        }
Esempio n. 5
0
 public static bool IsProgramAssetExists(List <RemoteConfig.AssetInfo> assetInfoList)
 {
     for (int i = 0; i < assetInfoList.Count; i++)
     {
         RemoteConfig.AssetInfo assetInfo = assetInfoList[i];
         if (!CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 6
0
 public static void ReleaseProgramAsset(RemoteConfig.AssetInfo assetInfo)
 {
     if (CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5))
     {
         string cachedProgramAssetUrl = CacheManager.GetCachedProgramAssetUrl(assetInfo.url);
         AssetPool.ReleaseAsset(cachedProgramAssetUrl);
     }
     else
     {
         AssetPool.ReleaseAsset(assetInfo.url);
     }
 }
Esempio n. 7
0
        private static void LoadProgramPrefab(RemoteConfig.AssetInfo assetInfo, bool isCacheInMemory, Action <GameObject> callback)
        {
            string url = assetInfo.url;

            if (CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5))
            {
                url = CacheManager.GetCachedProgramAssetUrl(assetInfo.url);
            }
            AssetConfig config = new AssetConfig(AssetType.Prefab, isCacheInMemory);

            AssetManager._assetLoader.LoadAsset(url, config, delegate(string pUrl)
            {
                AssetManager.OnLoadPrefab(pUrl, callback);
            });
        }
Esempio n. 8
0
        public static void GetPanelGameObject(RemoteConfig.AssetInfo assetInfo, Action <GameObject> callback)
        {
            string cachedProgramAssetUrl = CacheManager.GetCachedProgramAssetUrl(assetInfo.url);

            if (AssetPool.HasAsset(cachedProgramAssetUrl))
            {
                AssetManager.OnLoadPrefab(cachedProgramAssetUrl, callback);
            }
            else if (CacheManager.IsProgramAssetExists(assetInfo.name, assetInfo.md5))
            {
                AssetManager.LoadProgramPrefab(assetInfo, true, callback);
            }
            else
            {
                CacheManager.DeleteUnmatchCacheFile(assetInfo.name);
                CacheManager.LoadAsset(assetInfo.url, delegate(string pUrl)
                {
                    AssetManager.LoadProgramPrefab(assetInfo, true, callback);
                });
            }
        }
Esempio n. 9
0
        private Dictionary <string, RemoteConfig.AssetInfo> ParseAssetInfoDict(Dictionary <string, object> content, out bool hasError)
        {
            hasError = false;
            Dictionary <string, RemoteConfig.AssetInfo> dictionary = new Dictionary <string, RemoteConfig.AssetInfo>();

            if (!content.ContainsKey("sourcelist"))
            {
                Logger.LogError("文件列表配置错误,未发现sourcelist字段");
                hasError = true;
                return(dictionary);
            }
            Dictionary <string, object> dictionary2 = content["sourcelist"] as Dictionary <string, object>;

            if (dictionary2 == null || !dictionary2.ContainsKey("count") || !dictionary2.ContainsKey("list"))
            {
                Logger.LogError("文件列表配置错误,sourcelist字段中count或list不存在");
                hasError = true;
                return(dictionary);
            }
            int           num  = Convert.ToInt32(dictionary2["count"]);
            List <object> list = dictionary2["list"] as List <object>;

            if (num != list.Count)
            {
                Logger.LogError("文件列表配置错误,sourcelist字段中count值或list内容长度值不一致");
                hasError = true;
                return(dictionary);
            }
            foreach (object current in list)
            {
                Dictionary <string, object> dictionary3 = current as Dictionary <string, object>;
                if (!dictionary3.ContainsKey("url") || !dictionary3.ContainsKey("luacmd5") || !dictionary3.ContainsKey("size"))
                {
                    string text = "文件列表配置错误,sourcelist.list某一个文件的url,luacmd5,size字段不存在";
                    Logger.LogError(text);
                    Pandora.Instance.ReportError(text, 0);
                    hasError = true;
                    Dictionary <string, RemoteConfig.AssetInfo> result = dictionary;
                    return(result);
                }
                RemoteConfig.AssetInfo assetInfo = new RemoteConfig.AssetInfo();
                assetInfo.url  = (dictionary3["url"] as string);
                assetInfo.url  = assetInfo.url.ToLower().Replace("http://", "https://");
                assetInfo.size = (int)((long)dictionary3["size"]);
                assetInfo.md5  = (dictionary3["luacmd5"] as string);
                assetInfo.name = Path.GetFileName(assetInfo.url);
                if (string.IsNullOrEmpty(assetInfo.name) || string.IsNullOrEmpty(assetInfo.md5) || assetInfo.size <= 0 || string.IsNullOrEmpty(assetInfo.url))
                {
                    string text2 = "文件列表配置错误,sourcelist.list某一个文件的url,luacmd5,size字段内容不正确";
                    Logger.LogError(text2);
                    Pandora.Instance.ReportError(text2, 0);
                    hasError = true;
                    Dictionary <string, RemoteConfig.AssetInfo> result = dictionary;
                    return(result);
                }
                if (dictionary.ContainsKey(assetInfo.name))
                {
                    Logger.LogError("文件列表配置错误,sourcelist.list存在同名的资源配置信息");
                    hasError = true;
                    Dictionary <string, RemoteConfig.AssetInfo> result = dictionary;
                    return(result);
                }
                dictionary.Add(assetInfo.name, assetInfo);
            }
            return(dictionary);
        }