Beispiel #1
0
    //协程 下载PackDepend.xml
    IEnumerator Coroutine_DownloadPackDepend()
    {
        string url  = ResPath.GetServerURL(ResPath.PackDependFileName);
        WWW    down = new WWW(url);

        while (!down.isDone)
        {
            yield return(down);
        }
        if (down.isDone && down.error == null)
        {//保存
            ResUtil.SaveFile(down.bytes, ResPath.LocalTempCachePath, ResPath.PackDependFileName);
        }
        else
        {
            Debug.LogWarning("WWW failed, url:" + url + ", isDone:" + down.isDone + ", error:" + down.error);
        }
        PackDependRemote = new XML_PackDepend(ResPath.LocalTempCachePath);
        PackDependLocal  = new XML_PackDepend(ResPath.LocalPath + ResPath.CurrentPathName);
        --DownXmlCount;
    }
Beispiel #2
0
    //协程 下载版本
    IEnumerator Coroutine_DownloadVersion(GameResManager.CheckUpdateCallback callback)
    {
        string url     = ResPath.GetServerURL(ResPath.VersionFileName);
        WWW    downVer = new WWW(url);

        while (!downVer.isDone)
        {
            yield return(downVer);
        }
        if (downVer.isDone && downVer.error == null)
        {
            //保存版本文件到临时目录下
            if (ResUtil.SaveFile(downVer.bytes, ResPath.LocalTempCachePath, ResPath.VersionFileName))
            {
                //比较本地版本和server版本
                VersionInfo verLocal  = new VersionInfo(ResPath.LocalPath + ResPath.CurrentPathName + ResPath.VersionFileName);
                VersionInfo verServer = new VersionInfo(ResPath.LocalTempCachePath + ResPath.VersionFileName);

                if (0 > VersionInfo.CompareVersion(verLocal, verServer))
                {//服务器版本较新,更新
                    DownXmlCount = 3;
                    Entry.StartCoroutine(Coroutine_DownloadPackMD5());
                    Entry.StartCoroutine(Coroutine_DownloadFilePack());
                    Entry.StartCoroutine(Coroutine_DownloadPackDepend());
                    while (DownXmlCount > 0)
                    {//下载xml文件中
                        yield return(new WaitForSeconds(1));
                    }
                    UpdateList = XML_PackMD5.GetUpdateList(PackMD5Remote, PackMD5Local, out TotalSize);
                }
            }
        }
        else
        {
            Debug.LogWarning("WWW failed, url:" + url + ", isDone:" + downVer.isDone + ", error:" + downVer.error);
        }
        //回调
        callback(UpdateList != null && UpdateList.Count > 0);
    }