コード例 #1
0
    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);
        });
    }
コード例 #2
0
    // 下载首包
    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);
        });
    }