Пример #1
0
 private void Init()
 {
     PathSystem.Init();
     if (Application.get_isPlaying() && Application.get_isEditor())
     {
         string text = Application.get_dataPath() + "/StreamingAssets/resources2json.txt";
     }
     Object.DontDestroyOnLoad(base.get_gameObject());
     FileSystem.Init();
     PreloadUIBaseSystem.Init();
     GamePackets.Register();
     base.InvokeRepeating("Tick", 0f, 0.03f);
     Loom.Current.Init();
     this.InitBugly();
     base.get_gameObject().AddComponent <RemoteLogSender>();
     if (GameManager.IsDebug)
     {
         return;
     }
     CamerasMgr.CameraUI.set_enabled(false);
     this.OpenPreloadingUI();
     PreloadingUIView.SetProgressName("正在初始化环境...");
     Screen.set_sleepTimeout(-1);
     Debug.Log("SystemInfo.deviceModel = " + SystemInfoTools.GetDeviceModel());
     this.CurrentUpdateManager = new UpdateManager();
     this.CurrentUpdateManager.Init();
     this.CheckUpdate();
 }
Пример #2
0
 private void DoInstallNext()
 {
     this.CurrentInstallIndex++;
     if (this.CurrentInstallIndex < this.InstallOrder.get_Count())
     {
         this.InstallUpdate = null;
         UpdateManager.PatchFileType type = this.InstallOrder.get_Item(this.CurrentInstallIndex);
         if (this.UpdateInfo.GetDownloadInfo(type) == null)
         {
             this.InstallNext();
         }
         else
         {
             this.InstallCount++;
             string progressName = string.Format("正在解压安装文件,过程中不消耗流量({0}/{1})", this.InstallCount, this.UpdateInfo.DownloadFiles.get_Count());
             PreloadingUIView.SetProgressName(progressName);
             PreloadingUIView.ResetProgress();
             this.InstallByType(type);
         }
     }
     else
     {
         base.ReactSync(UpdateEvent.True);
     }
 }
Пример #3
0
 private void OnValidatePatchEnter(int eventID, FSMState preState, FSMState currentState)
 {
     Debug.Log("正在校验补丁");
     PreloadingUIView.SetProgressName("正在校验更新文件,过程中不消耗流量");
     Loom.Current.RunAsync(delegate
     {
         bool isAllValid = true;
         for (UpdateManager.PatchFileType patchFileType = UpdateManager.PatchFileType.Extend; patchFileType < UpdateManager.PatchFileType.Max; patchFileType++)
         {
             UpdateManager.DownloadFileInfo downloadInfo = this.UpdateInfo.GetDownloadInfo(patchFileType);
             if (downloadInfo != null)
             {
                 string text = MD5Util.EncryptFile(downloadInfo.LocalPath);
                 if (!downloadInfo.TargetBaseInfo.Md5.Equals(text))
                 {
                     isAllValid = false;
                     downloadInfo.TargetFileInfo.Delete();
                     downloadInfo.TargetFileInfo.Refresh();
                 }
             }
         }
         Loom.Current.QueueOnMainThread(delegate
         {
             this.OnValidateFinish(isAllValid);
         });
     });
 }
Пример #4
0
    private void DoDownload()
    {
        List <string> list  = new List <string>();
        List <string> list2 = new List <string>();
        List <string> list3 = new List <string>();
        List <long>   list4 = new List <long>();

        for (UpdateManager.PatchFileType patchFileType = UpdateManager.PatchFileType.Extend; patchFileType < UpdateManager.PatchFileType.Max; patchFileType++)
        {
            UpdateManager.DownloadFileInfo downloadInfo = this.UpdateInfo.GetDownloadInfo(patchFileType);
            if (downloadInfo != null)
            {
                if (!downloadInfo.IfFull())
                {
                    list.Add(downloadInfo.Url);
                    list2.Add(downloadInfo.LocalPath);
                    list3.Add(downloadInfo.TargetBaseInfo.Md5);
                    list4.Add((long)downloadInfo.TargetBaseInfo.FileSize);
                }
            }
        }
        PreloadingUIView.SetProgressName("正在下载更新文件...");
        PreloadingUIView.ResetProgress();
        this.Downloading = true;
        this.CurrentDownloader.Download(list, list2, list3, list4, null, new Action <bool>(this.OnDownloadEnd));
    }
Пример #5
0
        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);
                }
            });
        }
Пример #6
0
        private void OnMergePatchEnter(int eventID, FSMState preState, FSMState currentState)
        {
            PreloadingUIView.SetProgressName("正在解压安装文件...");
            PreloadingUIView.ResetProgress();
            Debug.Log("正在合并apk包");
            string current       = Application.get_dataPath();
            string newApk        = this.GetNewApkPath();
            string patch         = this.GetNewPatchPath();
            string directoryName = Path.GetDirectoryName(newApk);

            DirectoryUtil.CreateIfNotExist(directoryName);
            this.ApkMerging = false;
            Loom.Current.RunAsync(delegate
            {
                FileHelper.DeleteIfExist(newApk);
                this.ApkMerging = true;
                using (FileStream fileStream = File.Open(current, 3, 1, 1))
                {
                    using (FileStream fileStream2 = File.Open(newApk, 2, 2))
                    {
                        BinaryPatchUtility.Apply(fileStream, () => File.Open(patch, 3, 1, 1), fileStream2);
                    }
                }
                this.ReactSync(UpdateEvent2.Next);
            });
        }
Пример #7
0
 private void OnDownloadPatchUpdate(FSMState currentState)
 {
     if (this.Downloading)
     {
         long   currentFilesSize = this.UpdateInfo.GetCurrentFilesSize();
         double num = (double)currentFilesSize / (double)this.UpdateInfo.DownloadAmmount;
         PreloadingUIView.SetProgressInSmooth((float)num);
     }
 }
Пример #8
0
 private void ShowSpeed()
 {
     this.t = TimerHeap.AddTimer(0u, 1000, delegate
     {
         string speed = string.Format("({0})", (Downloader.Instance.Alreadyread / 1024).ToString() + "kb/s");
         PreloadingUIView.SetSpeed(speed);
         Downloader.Instance.Alreadyread = 0;
     });
 }
Пример #9
0
 private void DownloadPackageUpdate(int current, int max, string filePath)
 {
     if (current <= max)
     {
         float  progressInSmooth = (float)current / (float)max;
         string progressName     = string.Format("正在下载更新文件 :{0}/{1}MB", this.GetSizeString((long)current), this.GetSizeString((long)max));
         PreloadingUIView.SetProgressName(progressName);
         PreloadingUIView.SetProgressInSmooth(progressInSmooth);
     }
 }
Пример #10
0
 private void Awake()
 {
     PreloadingUIView.m_instance = this;
     base.AwakeBase(BindingContext.BindingContextMode.MonoBinding, false);
     this.Point1            = base.FindTransform("point1");
     this.m_spProgressBg    = base.FindTransform("Slider").GetComponent <Slider>();
     this.m_lblProgressText = base.FindTransform("ProgressText").GetComponent <Text>();
     this.m_speed           = base.FindTransform("speed").GetComponent <Text>();
     this.m_downTime        = base.FindTransform("downTime").GetComponent <Text>();
 }
Пример #11
0
 private void InstallByApkPatchUpdate()
 {
     if (this.MergeFile != null)
     {
         this.MergeFile.Refresh();
         if (this.MergeFile.get_Exists())
         {
             PreloadingUIView.SetProgressInSmooth((float)this.MergeFile.get_Length() / (float)this.UpdateInfo.CurrentApkInfo.ApkFileInfo.FileSize);
         }
     }
 }
Пример #12
0
 private void OnMergePatchUpdate(FSMState currentState)
 {
     if (this.ApkMerging)
     {
         string   newApkPath = this.GetNewApkPath();
         FileInfo fileInfo   = new FileInfo(newApkPath);
         if (fileInfo.get_Exists())
         {
             PreloadingUIView.SetProgress((float)fileInfo.get_Length() / (float)this.CurrentPatchInfo.ApkFileInfo.FileSize);
         }
     }
 }
Пример #13
0
 private void UpdateProgress()
 {
     if (this.IsProgressChange)
     {
         float num = 0f;
         for (int i = 0; i < this.LoadProgressWeight.Length; i++)
         {
             num += this.LoadProgressWeight[i] * this.LoadProgress[i];
         }
         PreloadingUIView.SetProgressInSmooth(num);
         this.IsProgressChange = false;
     }
 }
Пример #14
0
 private void OnEndEnter(int eventID, FSMState preState, FSMState currentState)
 {
     this.Updating   = false;
     this.UpdateInfo = null;
     if (this.OnUpdateEnd != null)
     {
         this.OnUpdateEnd.Invoke();
     }
     else
     {
         PreloadingUIView.Close();
     }
 }
Пример #15
0
 private void OnCleanPatchEnter(int eventID, FSMState preState, FSMState currentState)
 {
     Debug.Log("清理已下载的文件");
     PreloadingUIView.SetProgressName("正在优化游戏环境...");
     Loom.Current.RunAsync(delegate
     {
         this.ClearApk();
         this.ClearApkPatch();
         this.ClearCorePatch();
         this.ClearExtendPatch();
         base.ReactSync(UpdateEvent.Next);
     });
 }
Пример #16
0
    private void DownloadSeverVersion()
    {
        List <string> list  = new List <string>();
        List <string> list2 = new List <string>();
        string        text  = string.Format(AppConst.ServerUrl, SerializeUtility.GetRuntimePlatformFolderName(Application.get_platform()));

        list.Add(text);
        list2.Add(Path.Combine(GameManager.AssetBundleBuildRoot, "server_version.txt"));
        string progressName = string.Format(GameDataUtils.GetChineseContent(621301, false), new object[0]);

        PreloadingUIView.SetProgressName(progressName);
        PreloadingUIView.SetProgress(0.1f);
        Downloader.Instance.Download(list, list2, null, null, null, new Action <bool>(this.CheckVersion));
    }
Пример #17
0
    public void ToAnalysis(Action <long> _AnalysisCallback = null, bool _isTemp = true)
    {
        this.isTemp           = _isTemp;
        this.AnalysisCallback = _AnalysisCallback;
        Debug.LogError("start analysis indexfile...");
        if (UIManagerControl.Instance.GetUIIfExist("PreloadingUI"))
        {
            PreloadingUIView.SetProgressName(GameDataUtils.GetChineseContent(621302, false));
        }
        Thread thread = new Thread(new ThreadStart(this.AnalysisIndexFile));

        thread.set_IsBackground(false);
        thread.Start();
    }
Пример #18
0
 private void GetIndexFileSize(bool isFinish)
 {
     Debug.Log(">>>>>>>>>>>>>>GetIndexFileSize");
     TimerHeap.DelTimer(this.t);
     PreloadingUIView.SetSpeed(string.Empty);
     if (!isFinish)
     {
         NewContinueUI.OpenAsNormal(GameDataUtils.GetChineseContent(621270, false), GameDataUtils.GetChineseContent(621269, false), new Action(this.DownloadSeverVersion), new Action(ClientApp.QuitApp), GameDataUtils.GetChineseContent(621271, false), GameDataUtils.GetChineseContent(621272, false));
     }
     else
     {
         DownloaderManager.Instance.GetZipFiles(new Action <long>(this.AnalysisFinish), false);
     }
 }
Пример #19
0
    private void ProgressCallback(float downloadedSize, float TotalSize)
    {
        string progressName = string.Concat(new string[]
        {
            GameDataUtils.GetChineseContent(621268, false),
            downloadedSize.ToString("0.00"),
            "MB /",
            this.fileSize.ToString("0.00"),
            " MB"
        });

        PreloadingUIView.SetProgressName(progressName);
        PreloadingUIView.SetProgress(downloadedSize / this.fileSize);
    }
Пример #20
0
    private void ReplaceUpdateFiles()
    {
        int j;

        for (j = 0; j <= this.finishNum; j++)
        {
            string text = this.ExtTemp + j.ToString();
            Debug.LogError("GetFiles ext:*" + text);
            string[] files = Directory.GetFiles(this.dataPath, "*" + text, 1);
            if (files != null)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Replace ",
                    text,
                    "files.Length",
                    files.Length
                }));
            }
            try
            {
                int i;
                for (i = 0; i < files.Length; i++)
                {
                    File.Copy(files[i], files[i].Replace(text, string.Empty), true);
                    File.Delete(files[i]);
                    Loom.Current.QueueOnMainThread(delegate
                    {
                        PreloadingUIView.SetProgress((float)(i + 1) / (float)(files.Length + 1) / (float)this.finishNum * (float)j);
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("ReplaceUpdateFiles Exception has been thrown!");
                Debug.LogError(ex.ToString());
                Loom.Current.QueueOnMainThread(delegate
                {
                    NewContinueUI.OpenAsNormal(GameDataUtils.GetChineseContent(621293, false), GameDataUtils.GetChineseContent(621294, false), new Action(ClientApp.QuitApp), new Action(this.DownloadInstallPackage), GameDataUtils.GetChineseContent(621286, false), GameDataUtils.GetChineseContent(621295, false));
                });
                return;
            }
        }
        Loom.Current.QueueOnMainThread(delegate
        {
            this.ReplaceUpdateFilesFinish();
        });
    }
Пример #21
0
        private void BeginDownloadPatchInfo()
        {
            Debug.Log("下载补丁包信息");
            PreloadingUIView.SetProgressName("正在获取更新信息...");
            string patchInfoPath = this.GetPatchInfoPath();

            FileHelper.DeleteIfExist(patchInfoPath);
            string        apkPatchUrl = GameManager.Instance.GetApkPatchUrl(PathSystem.ApkPatchInfoFileName);
            List <string> list        = new List <string>();

            list.Add(apkPatchUrl);
            List <string> list2 = new List <string>();

            list2.Add(patchInfoPath);
            Downloader.Instance.Download(list, list2, null, null, null, new Action <bool>(this.OnPatchInfoDownloaded));
        }
Пример #22
0
 private void ShowState(int downloadedSize, int fileSize, string tips)
 {
     this.ShowSpeed();
     this.tm = TimerHeap.AddTimer(0u, 1000, delegate
     {
         string progressName = string.Concat(new string[]
         {
             GameDataUtils.GetChineseContent(621303, false),
             ((float)Downloader.Instance.localFileSize / 1024f / 1024f).ToString("0.00"),
             "MB /",
             ((float)fileSize / 1024f / 1024f).ToString("0.00"),
             " MB"
         });
         PreloadingUIView.SetProgressName(progressName);
         PreloadingUIView.SetProgress((float)Downloader.Instance.localFileSize / (float)fileSize);
     });
 }
Пример #23
0
    private void GoReplace(string _temp)
    {
        this.ExtTemp = "." + _temp;
        Debug.LogError(string.Concat(new object[]
        {
            "finishNum:",
            this.finishNum,
            ", _temp:",
            this.ExtTemp
        }));
        string chineseContent = GameDataUtils.GetChineseContent(621299, false);

        PreloadingUIView.SetProgressName(chineseContent);
        Thread thread = new Thread(new ThreadStart(this.ReplaceUpdateFiles));

        thread.set_IsBackground(true);
        thread.Start();
    }
Пример #24
0
        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));
        }
Пример #25
0
 private void FinishCallback(bool isFinish)
 {
     TimerHeap.DelTimer(this.t);
     PreloadingUIView.SetSpeed(string.Empty);
     if (isFinish)
     {
         string chineseContent = GameDataUtils.GetChineseContent(621311, false);
         PreloadingUIView.SetProgressName(chineseContent);
         string[] array = new string[]
         {
             "-1",
             "-1",
             "-1",
             "-1",
             "-1"
         };
         if (this.clientVersions[2] == "0")
         {
             PlayerPrefs.SetInt("FinishedUpdateBaseId", int.Parse(this.clientVersions[2]) + 1);
             array[2] = (int.Parse(this.clientVersions[2]) + 1).ToString();
         }
         else
         {
             PlayerPrefs.SetInt("FinishedUpdatePatchId", int.Parse(this.clientVersions[3]) + 1);
             array[3] = (int.Parse(this.clientVersions[3]) + 1).ToString();
         }
         this.UpdateClientVersionFileCfg(array);
         if (DownloaderManager.Instance.HasFileWaitDownload)
         {
             this.CheckUnZipFile(new Action(this.DoDown));
         }
         else
         {
             this.CheckUnZipFile(new Action(this.DoCheckVersion));
         }
     }
     else
     {
         string progressName = "更新失败";
         PreloadingUIView.SetProgressName(progressName);
         NewContinueUI.OpenAsNormal(GameDataUtils.GetChineseContent(621270, false), GameDataUtils.GetChineseContent(621269, false), new Action(this.OnContinue), new Action(ClientApp.QuitApp), GameDataUtils.GetChineseContent(621271, false), GameDataUtils.GetChineseContent(621272, false));
     }
 }
Пример #26
0
        private void OnCleanApkAndPatchEnter(int eventID, FSMState preState, FSMState currentState)
        {
            Debug.Log("清理已下载的文件");
            string apkDir      = PathSystem.ApkDir;
            string apkPatchDir = PathSystem.ApkPatchDir;

            Loom.Current.RunAsync(delegate
            {
                Loom.Current.QueueOnMainThread(delegate
                {
                    PreloadingUIView.SetProgressName("正在优化游戏环境...");
                });
                this.ClearApk();
                this.ClearPatch();
                Loom.Current.QueueOnMainThread(delegate
                {
                    base.ReactSync(UpdateEvent2.Next);
                });
            });
        }
Пример #27
0
    private void DoGetUpdateInfo()
    {
        PreloadingUIView.SetProgressName("正在获取更新信息...");
        this.Updating = true;
        List <string> list  = new List <string>();
        List <string> list2 = new List <string>();

        if (this.UpdateInfo.IsResUpdate())
        {
            string resPatchUrl = GameManager.Instance.GetResPatchUrl(this.GetResPatchRelPath(UpdateManager.ResPathDir.config, string.Empty));
            list.Add(resPatchUrl);
            list2.Add(this.GetResPatchConfigPath());
        }
        if (this.UpdateInfo.IsApkUpdate())
        {
            list.Add(GameManager.Instance.GetApkPatchUrl(PathSystem.ApkPatchInfoFileName));
            list2.Add(this.GetApkPatchInfoPath());
        }
        this.CurrentDownloader.Download(list, list2, null, null, null, new Action <bool>(this.OnPatchInfoDownloaded));
    }
Пример #28
0
        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;
                }
            }
        }
Пример #29
0
 private void OnEndEnter(int eventID, FSMState preState, FSMState currentState)
 {
     this.Updating = false;
     Debug.Log("更新结束");
     PreloadingUIView.Close();
 }
Пример #30
0
    private void UnZipUpdate()
    {
        float progressInSmooth = (float)UnZipFile.Instance.UnzipFileCount / (float)UnZipFile.Instance.WaitUnZipFiles;

        PreloadingUIView.SetProgressInSmooth(progressInSmooth);
    }