// 解压 streaming upk 包 public void UnpackStreaming() { state = STATE.UNPACK_FIRST_UPK; hotUI.HOT_InitUnpackStream(); //清空数据目录 if (Directory.Exists(Util.DataPath)) { Directory.Delete(Util.DataPath, true); } Directory.CreateDirectory(Util.DataPath); // 设备内存判断 if (PGameTools.GetStorageSize() < UnpackStreamingUpkMemorySize) { hotUI.OutOfMemory(UnpackStreamingUpkMemorySize); return; } // 解 streaming upk 包 string infoFilePath = Path.Combine(Util.AppContentPath(), "streaming.txt"); string upkFilePath = Path.Combine(Util.AppContentPath(), "streaming.upk"); UPKEngine.UnpackStreaming(infoFilePath, upkFilePath, Util.DataPath, this); }
private void DownloadHot() { state = STATE.DOWNLLOAD_HOT; hotUI.HOT_InitHot(); //内存判断 if (PGameTools.GetStorageSize() < updateSize) { hotUI.OutOfMemory(updateSize); return; } currentUpdateVersionFileIndex = updateVersionFileCount - updateVersionFileList.Count + 1; var fileInfo = updateVersionFileList[0]; var url = FormatUrl(serverUrl, GetRouteRoot() + fileInfo.WebPath); var localPath = fileInfo.DataLocalPath; if (download == null) { download = HotDownload.Create(); } download.Download(url, localPath, () => { RGLog.Log("热更新下载 url : " + url); }, () => { updateVersionFileList.RemoveAt(0); if (updateVersionFileList.Count > 0) { DownloadHot(); } else { hotUI.HOT_HotFinished(); EnterGame(); } }, (progress) => { hotUI.HOT_SetHotProgress(updateVersionFileCount, currentUpdateVersionFileIndex, progress); }, (error) => { hotUI.HOT_HotError(error, this); }); }
// 下载首包 private void DownloadFirstUpk() { state = STATE.DOWNLOAD_FIRST_ZIP; hotUI.HOT_InitDownloadFirst(); // 内存判断 if (PGameTools.GetStorageSize() < DownloadFirstMemorySize) { hotUI.OutOfMemory(DownloadFirstMemorySize); return; } var url = string.Format("{0}{1}/{2}/{3}", serverUrl, GetRouteRoot().TrimStart('/'), VersionInfo.BundleVersion, "first.upk"); var localPath = Path.Combine(Util.DataPath, "first.upk"); // 需要下载首包 if (download == null) { download = HotDownload.Create(); } download.Download(url, localPath, () => { RGLog.Log("首包开始下载"); }, () => { hotConfig.first_upk_download = HOT_STATE.SUCCEED; hotConfig.Save(); hotUI.HOT_DownloadFirstFinished(); //解首包 upk UnpackFirstUpk(); }, (progress) => { hotUI.HOT_SetDownloadFirstProgress(progress); }, (error) => { hotUI.HOT_DownloadFirstError(error, this); }); }
// 解首包 upk private void UnpackFirstUpk() { state = STATE.UNPACK_FIRST_UPK; hotUI.HOT_InitUnpackFirst(); // 内存判断 if (PGameTools.GetStorageSize() < UnpackFirstMemorySize) { hotUI.HOT_InitUnpackFirst(); // 内存判断 if (PGameTools.GetStorageSize() < UnpackFirstMemorySize) { hotUI.OutOfMemory(UnpackFirstMemorySize); return; } //解 first upk 包 string infoFilePath = Path.Combine(Util.AppContentPath(), "first.txt"); string upkFilePath = Path.Combine(Util.DataPath, "first.upk"); UPKEngine.UnpackFirst(infoFilePath, upkFilePath, Util.DataPath, this); } }