private void OnValidatePatchEnter(int eventID, FSMState preState, FSMState currentState) { PreloadingUIView.SetProgressName("正在校验更新文件..."); Debug.Log("校验补丁包"); string newPatch = this.GetNewPatchPath(); Loom.Current.RunAsync(delegate { bool flag = false; FileInfo fileInfo = new FileInfo(newPatch); if (fileInfo.get_Exists()) { string text = MD5Util.EncryptFile(newPatch); FileBaseInfo newPatchFileInfo = this.GetNewPatchFileInfo(); flag = text.Equals(newPatchFileInfo.Md5); if (!flag && fileInfo.get_Length() == (long)newPatchFileInfo.FileSize) { File.Delete(newPatch); } } if (flag) { this.ReactSync(UpdateEvent2.True); } else { this.ReactSync(UpdateEvent2.False); } }); }
private void DoDownloadPatch() { string apkPatchUrl = GameManager.Instance.GetApkPatchUrl(this.GetNewPatchName()); Debug.LogFormat("正在下载补丁包 :{0}", new object[] { apkPatchUrl }); FileBaseInfo newPatchFileInfo = this.GetNewPatchFileInfo(); this.DoDownloadPackage(apkPatchUrl, this.GetNewPatchPath(), newPatchFileInfo); }
private void BeginDownloadPackage(string url, string localPath, FileBaseInfo fileInfo) { GameManager.Instance.OpenPreloadingUI(); PreloadingUIView.SetProgressName("正在下载更新文件..."); PreloadingUIView.ResetProgress(); List <string> list = new List <string>(); list.Add(url); List <string> list2 = new List <string>(); list2.Add(localPath); List <string> list3 = new List <string>(); list3.Add(fileInfo.Md5); List <long> list4 = new List <long>(); list4.Add((long)fileInfo.FileSize); Downloader.Instance.Download(list, list2, list3, list4, new Action <int, int, string>(this.DownloadPackageUpdate), new Action <bool>(this.EndDownloadPackage)); }
private void DoDownloadPackage(string url, string localPath, FileBaseInfo fileInfo) { PreloadingUIView.SetProgressName("正在计算下载量..."); long fileDownloadAmmount = Downloader.GetFileDownloadAmmount(localPath, (long)fileInfo.FileSize, fileInfo.Md5); if (fileDownloadAmmount == 0L) { base.React(UpdateEvent2.Next); } else { switch (Application.get_internetReachability()) { case 0: DialogBoxUIViewModel.Instance.ShowAsConfirm("错误", "更新失败,请检查网络后重试", delegate { this.DoDownloadPackage(url, localPath, fileInfo); }, "确 定", "button_orange_1", UINodesManager.T4RootOfSpecial); DialogBoxUIView.Instance.isClick = false; break; case 1: DialogBoxUIViewModel.Instance.ShowAsOKCancel("更新", this.GetUpdateSizeMsg(fileDownloadAmmount), delegate { ClientApp.QuitApp(); }, delegate { this.BeginDownloadPackage(url, localPath, fileInfo); }, "取 消", "确 定", "button_orange_1", "button_yellow_1", UINodesManager.T4RootOfSpecial, true, true); DialogBoxUIView.Instance.isClick = false; break; case 2: this.BeginDownloadPackage(url, localPath, fileInfo); break; } } }