Ejemplo n.º 1
0
    /// <summary>
    /// 开始进行差异更新,下载当前最新版本的差异文件
    /// </summary>
    IEnumerator  StartDownDiffList(string version, int resId)
    {
        WWW remoteVersion = new WWW(AppConst.RemoteUpdatePath + resId + "/versionInfo.xml");

        yield return(remoteVersion);

        if (remoteVersion.isDone)
        {
            if (string.IsNullOrEmpty(remoteVersion.error))
            {
                remoteVersionVo = new VersionVo(remoteVersion.text, true);
                VersionVo curretnVo = GetCurrentVo();
                remoteVersionVo.InitDifferDict(); //初始化所有版本的更新内容
                Dictionary <string, VFStruct> updateDict = remoteVersionVo.GetDiffFromBeginVer(curretnVo.ResVersion);
                List <VFStruct> vfList = new List <VFStruct>();
                foreach (KeyValuePair <string, VFStruct> dict in updateDict)
                {
                    vfList.Add(dict.Value);
                }
                totalSize = remoteVersionVo.CalculateVFLSize(vfList);
                List <string> downedLs = GetDownedList(); //获取已经下载了的文件列表
                //开始下载文件
                for (int i = 0; i < vfList.Count; i++)
                {
                    if (downedLs.Contains(vfList[i].file))
                    {
                        Debug.Log("文件已下载:" + vfList[i].file);
                        DownFileFinish(vfList[i]);
                        continue;
                    }
                    else
                    {
                        StartDownFile(vfList[i]);
                        while (!IsDownFinish(vfList[i].file))
                        {
                            OnDownFinisCallByWWW(vfList[i]);
                            yield return(new WaitForEndOfFrame());
                        }
                    }
                }
                ResDownFinish(true);
            }
            else
            {
                Debug.LogError("下载更新列表失败:" + remoteVersion.error);
                ResDownFinish(false);
            }
        }
    }
Ejemplo n.º 2
0
    private int tmpDownedCount = 0; //分帧计数器
    /// <summary>
    /// 开始进行差异更新,下载当前最新版本的差异文件
    /// </summary>
    IEnumerator StartDownDiffList()
    {
        WWW remoteVersion = new WWW(ApkInfoVo.GetRemoteVersionXmlPath);

        yield return(remoteVersion);

        if (remoteVersion.isDone)
        {
            if (string.IsNullOrEmpty(remoteVersion.error))
            {
                remoteVersionVo = new VersionVo(remoteVersion.text, true);
                remoteVersionVo.InitDifferDict(); //初始化所有版本的更新内容
                Dictionary <string, VFStruct> updateDict = remoteVersionVo.GetDiffFromBeginVer(currentVo.ResVersion);
                List <VFStruct> vfList = new List <VFStruct>();
                foreach (KeyValuePair <string, VFStruct> dict in updateDict)
                {
                    vfList.Add(dict.Value);
                }
                totalSize = remoteVersionVo.CalculateVFLSize(vfList);

                if (Application.internetReachability != NetworkReachability.ReachableViaCarrierDataNetwork) //如果是移动数据网络,则需要提示玩家
                {
                    Waiting(OnDownConfirm, "当前是移动数据网络,资源包大小为" + GetFormatFileSize(totalSize) + ",是否继续进行下载?");
                }
                else
                {
                    OnDownConfirm();
                }
            }
            else
            {
                if (Application.internetReachability == NetworkReachability.NotReachable)
                {
                    Waiting(CompareVersion, "网络连接失败,请检查网络");
                }
            }
        }
    }