void _checkCotainedPkg() { mDownloadingPkg = new List <string>(mCotainPkgs); for (int i = 0; i < mCotainPkgs.Count; i++) { string pkg = mCotainPkgs[i]; ResPkgDownloder downloader; if (!mDownloaders.TryGetValue(pkg, out downloader)) { downloader = new ResPkgDownloder(pkg); mDownloaders[pkg] = downloader; } downloader.CheckUpdate((long size, string msg) => { _onPkgChecked(pkg, size); }); } }
void _onDownloadCotain(string pkg, double progress, string msg) { long size = 0; float time = Time.time; foreach (var item in mDownloaders) { ResPkgDownloder downloader = item.Value; size += downloader.DoneSize; } long sizePerSec = (long)((size - mLastSize) / (time - mLastTime)); double progr = size / (double)mTotalSize; // 通知下载进度 EventManager.NotifyAll(mDownloadEventKey, progr, sizePerSec); mLastTime = time; mLastSize = size; //通知下载是否完全成功 if (Tools.Equals(1d, progress)) { mDownloadRst[pkg] = WWWTO.STR_SUCCEEDED.Equals(msg); if (mDownloadRst.Keys.Count == mDownloaders.Keys.Count) { bool rst = true; foreach (var r in mDownloadRst) { if (!r.Value) { rst = false; break; } } EventManager.NotifyAll(mFinishEventKey, rst); } } }