/// <summary> /// 下载资源 /// </summary> /// <param name="absolutPath"></param> /// <param name="callback"></param> /// <param name="obj"></param> /// <returns></returns> public bool DownloadResource(string absolutPath, UpdateAction <string, bool, object> callback, object obj) { string fixPath = absolutPath; MapFileData data = null; if (!IsExistOrDownloaded(absolutPath, out data, out fixPath)) { if (data != null) { lock (BackDownload.GetLocker()) { //暂停中,则不接受请求,原样返回 if (IsPaused()) { UpdateLog.WARN_LOG("当前是暂停状态,直接返回请求:" + absolutPath); data.DownloadCallBack = null; data.ArgObj = null; callback(fixPath, false, obj); return(true); } else { data.DownloadCallBack = callback; data.ArgObj = obj; data.DataLevel = DataLevel.High; } } if (!data.Downloading) { BackDownload.AddDataToPool(data, DataLevel.High); } else { UpdateLog.WARN_LOG("resource is downloading: " + fixPath); } } else { //UpdateLog.WARN_LOG("no map data found: " + absolutPath); callback(absolutPath, false, obj); return(true); } } else { callback(fixPath, true, obj); } return(false); }
private void AddDataList(IEnumerable dataList, DataLevel level, bool append = false) { if (dataList != null && !append) { BackDownload.ClearData(level); if (_sceneResList.ContainsKey(level) && _sceneResList[level] != null) { _sceneResList[level].Clear(); } } Flow8ExCheckResource resource = InstanceFlow8Ex; string fixPath = ""; IEnumerator enumerator = dataList.GetEnumerator(); while (enumerator.MoveNext()) { //不存在的文件才加入到下载队列 if (!Exist(enumerator.Current as string, out fixPath)) { lock (BackDownload.GetLocker()) { MapFileData mapFileData = resource.GetMapFileDataByPath(fixPath); if (((mapFileData == null) || mapFileData.Downloading) || mapFileData.Downloaded) { UpdateLog.WARN_LOG("no map data: " + fixPath); } else { mapFileData.FullPath = fixPath; if (mapFileData.DataLevel > level) { mapFileData.DataLevel = level; } BackDownload.AddDataToPool(mapFileData, level); //添加到当前场景资源列表,用于统计大小,显示进度 AddToCurSceneResList(level, mapFileData); } } } } }