Пример #1
0
        void OnBackgroundComplete(bool is_error)
        {
            if (is_error)
            {
                var tips = Localization.Get("main_download_fail");
                SetProgressTxt(tips);
                UnityEngine.Events.UnityAction ReLoad = () => {
                    BackGroundDownload.instance.ReloadError();
                    BackGroundDownload.instance.Begin();
                    MessageBox.Destroy();
                };
                MessageBox.Show(tips, "", "", ReLoad);
            }
            else
            {
                if (remoteManifest != null)
                {
                    ManifestManager.SetUpdateFileManifest(remoteManifest);
                }
                remoteManifest = null;
                if (ManifestManager.CheckFirstLoad())
                {
                    ManifestManager.FinishFirstLoad();
                }

                FileHelper.DeletePersistentFile(UPDATED_LIST_NAME);  //删除旧文件
                FileHelper.ChangePersistentFileName(UPDATED_TEMP_LIST_NAME, UPDATED_LIST_NAME);

                FileHelper.DeletePersistentFile(VERSION_FILE_NAME);  //删除旧文件
                FileHelper.ChangePersistentFileName(VERSION_TEMP_FILE_NAME, VERSION_FILE_NAME);

                SetSliderProgress(Localization.Get("main_download_complete"), 4, 1);   //"更新完毕,进入游戏!"
                LoadBeginScene();
            }
        }
Пример #2
0
        void SwitchScreen(object sender, EventArgs e)
        {
            if (sender is InputMessageBox)
            {
                InputMessageBox imb = (InputMessageBox)sender;
                if (imb.InputText == "STORNO")
                {
                    return;
                }
            }
            MessageBox mb = (MessageBox)sender;

            mb.Destroy();
            if (mb.MessageResult == MessageBox.Result.Ok)
            {
                ScreenManager.ActiveScreen <MenuScreen>();
            }
        }
Пример #3
0
        //加载热更新文件
        public IEnumerator LoadRomoteFileList(VerionConfig remoteVer)
        {
            yield return(null);

            SetProgressTxt(Localization.Get("main_web_server_crc_list"));   //--加载服务器校验列表。")
            var crc             = remoteVer.crc32.ToString();
            var asset_name      = CUtils.GetAssetName(UPDATED_LIST_NAME);
            var assetbundleName = asset_name + Common.CHECK_ASSETBUNDLE_SUFFIX;
            var fileName        = CUtils.InsertAssetBundleName(assetbundleName, "_" + crc);
            var url             = CUtils.PathCombine(remoteVer.cdn_host[1], fileName); //server_ver.cdn_host[1] .. "/" .. file_name

            UnityWebRequest req   = UnityWebRequest.Get(url);
            var             async = req.SendWebRequest();

            yield return(async);

            if (req.responseCode == 200)
            {
                SetProgressTxt(Localization.Get("main_compare_crc_list"));    //校验列表对比中。"
                var bytes = req.downloadHandler.data;
                FileHelper.SavePersistentFile(bytes, UPDATED_TEMP_LIST_NAME); //--保存server端临时文件
                var ab             = LuaHelper.LoadFromMemory(bytes);
                var romoteManifest = ab.LoadAllAssets() [1] as FileManifest;
                ab.Unload(false);
                print("server file list is down");
                if (!CUtils.isRelease)
                {
                    Debug.Log(romoteManifest);
                    Debug.Log(ManifestManager.fileManifest);
                }

                //开始加载热更新文件
                var change = BackGroundDownload.instance.AddDiffManifestTask(ManifestManager.fileManifest, romoteManifest, OnProgressEvent, OnBackgroundComplete);
                Debug.Log("need load file size:" + change);
                if (change > 0)
                {
                    var is_wifi = Application.internetReachability == UnityEngine.NetworkReachability.ReachableViaLocalAreaNetwork;
                    UnityEngine.Events.UnityAction BeginLoad = () => {
                        BackGroundDownload.instance.alwaysDownLoad = true;
                        BackGroundDownload.instance.loadingCount   = 4;
                        BackGroundDownload.instance.Begin();
                        MessageBox.Destroy();
                    };
                    if (is_wifi)
                    {
                        BeginLoad();
                    }
                    else
                    {
                        var tips = Localization.GetFormat("main_download_from_webserver", string.Format("{0:.00}", change / 1048576));
                        MessageBox.Show(tips, "", "", BeginLoad);  //提示手动下载
                    }
                }
            }
            else     //加载失败重新加载
            {
                yield return(null);

                var tips = Localization.Get("main_web_server_error");
                MessageBox.Show(tips, "", "",
                                () => {
                    StartCoroutine(LoadRomoteFileList(remoteVer));
                }
                                );
            }
        }