コード例 #1
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);
        });
    }