示例#1
0
        protected IEnumerator UncompressPatches()
        {
            m_VersionCheckState = VersionCheckState.UncompressPatch;

            for (int i = m_HasDownloadDoneCount; i < m_PatchKeyList.Count; ++i)
            {
                var result           = 0;
                var downloadProgress = 0f;
                var localPath        = Path.Combine(UGCoreConfig.GetExternalDownloadFolder() + "/Patches", m_PatchKeyList[i]);

                LoadingUI.Instance.ShowLoadingTip(string.Format(LoadingLanguageData.Instance.GetString(16), (i + 1), m_PatchKeyList.Count, 0));
                LoadingUI.Instance.PushLoadTaskProgressDelta(1);
                LoadingUI.Instance.SetLoadingBarProgress(0);

                ZipUtility.UnzipDirectoryAsync(localPath, UGCoreConfig.GetExternalResourceFolder(),
                                               (progress) =>
                {
                    downloadProgress = progress;
                },
                                               () =>
                {
                    ++m_HasDownloadDoneCount;
                    result = 1;
                },
                                               () =>
                {
                    result = 2;
                });

                while (result == 0)
                {
                    LoadingUI.Instance.ShowLoadingTip(string.Format(LoadingLanguageData.Instance.GetString(16), (i + 1),
                                                                    m_PatchKeyList.Count, (int)downloadProgress));
                    LoadingUI.Instance.SetLoadingBarProgress(downloadProgress * 0.01f);
                    yield return(null);
                }

                if (result == 1)
                {
                    LoadingUI.Instance.ShowLoadingTip(string.Format(LoadingLanguageData.Instance.GetString(16), (i + 1),
                                                                    m_PatchKeyList.Count, 100));
                    LoadingUI.Instance.SetLoadingBarProgress(1);
                    LoadingUI.Instance.PopLoadTaskProgressDelta();
                }
                else if (result == 2)
                {
                    m_CoroutineWorkflow.AddFirst("ShowUncompressPatchesError", ShowUncompressPatchesError);
                    yield break;
                }
                yield return(null);
            }

            //保存资源版本号
            GameRuntimeInfo.ResourceVersion = GameRuntimeInfo.RemoteControlConfig.ResourceVersion;
            SaveVersionInfo(GameRuntimeInfo.ProgramVersion, GameRuntimeInfo.ResourceVersion, false);
        }