Ejemplo n.º 1
0
 //加载配置文件
 public bool LoadConfigFile()
 {
     FilePackLocal   = new XML_FilePack(ResPath.LocalPath + ResPath.CurrentPathName);
     PackMD5Local    = new XML_PackMD5(ResPath.LocalPath + ResPath.CurrentPathName);
     PackDependLocal = new XML_PackDepend(ResPath.LocalPath + ResPath.CurrentPathName);
     return(true);
 }
Ejemplo n.º 2
0
    //清除更新残留数据
    public void ClearUpdateData()
    {
        if (PackMD5Remote != null)
        {
            PackMD5Remote.Clear();
            PackMD5Remote = null;
        }
        if (PackMD5Local != null)
        {
            PackMD5Local.Clear();
            PackMD5Local = null;
        }
        if (FilePackRemote != null)
        {
            FilePackRemote.Clear();
            FilePackRemote = null;
        }
        if (FilePackLocal != null)
        {
            FilePackLocal.Clear();
            FilePackLocal = null;
        }
        if (PackDependRemote != null)
        {
            PackDependRemote.Clear();
            PackDependRemote = null;
        }
        if (PackDependLocal != null)
        {
            PackDependLocal.Clear();
            PackDependLocal = null;
        }

        if (UpdateList != null)
        {
            UpdateList.Clear();
            UpdateList = null;
        }
        if (SuccList != null)
        {
            SuccList.Clear();
            SuccList = null;
        }
        if (FailList != null)
        {
            FailList.Clear();
            FailList = null;
        }
    }
Ejemplo n.º 3
0
    //协程 下载PackMD5.xml
    IEnumerator Coroutine_DownloadPackMD5()
    {
        string url  = ResPath.GetServerURL(ResPath.PackMD5FileName);
        WWW    down = new WWW(url);

        while (!down.isDone)
        {
            yield return(down);
        }
        if (down.isDone && down.error == null)
        {//保存
            ResUtil.SaveFile(down.bytes, ResPath.LocalTempCachePath, ResPath.PackMD5FileName);
        }
        else
        {
            Debug.LogWarning("WWW failed, url:" + url + ", isDone:" + down.isDone + ", error:" + down.error);
        }
        PackMD5Remote = new XML_PackMD5(ResPath.LocalTempCachePath);
        PackMD5Local  = new XML_PackMD5(ResPath.LocalPath + ResPath.CurrentPathName);
        --DownXmlCount;
    }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
0
    //获取更新列表 xmlA是服务器版本,xmlB是本地版本
    static public List <Info> GetUpdateList(XML_PackMD5 xmlA, XML_PackMD5 xmlB, out long length)
    {
        List <Info> updateList = new List <Info>();

        length = 0;
        foreach (var infoA in xmlA.InfoList)
        {
            Info infoB = xmlB.InfoList.Find(item => item.PackName == infoA.PackName);
            if (infoB != null)
            {
                if (0 != string.Compare(infoA.MD5, infoB.MD5))
                {//md5码不一致
                    updateList.Add(infoA);
                    length += long.Parse(infoA.FileSize);
                }
            }
            else
            {//本地不存在
                updateList.Add(infoA);
                length += long.Parse(infoA.FileSize);
            }
        }
        return(updateList);
    }