private IEnumerator ReadUnpackMd5File() { #if XML string checkFilePath = m_downLoadPath + "/UnpackMd5_" + CurVersion + "_" + CurrentPatches.Version + ".xml"; Debug.Log("checkFilePath :" + checkFilePath); yield return(ReadUnpackMd5Inifo(m_currentPatches.Files[0].Url, checkFilePath)); m_zipMd5Data = BinarySerializeOpt.XmlDeserialize(checkFilePath, typeof(ZipMd5Data)) as ZipMd5Data; #elif JSON m_zipMd5Data = new UnpackMd5InfoDataModule(); foreach (Patches patches in m_needUpdatePatchesInfos) { string checkFilePath = m_downLoadPath + "/UnpackMd5_" + CurVersion + "_" + patches.Version + ".json"; Debug.Log("checkFilePath :" + checkFilePath); //if (patches.Files[0].Name.StartsWith("UnpackMd5_")) //{ yield return(ReadUnpackMd5Inifo(patches.Files[0].Url, checkFilePath)); StreamReader sr = new StreamReader(checkFilePath); var content = sr.ReadToEnd(); var zipMd5DataCache = new UnpackMd5InfoDataModule(JsonMapper.ToObject(content)); m_zipMd5Data.ZipMd5List = m_zipMd5Data.ZipMd5List.Concat(zipMd5DataCache.ZipMd5List).ToList(); sr.Close(); //} } #endif yield return(null); }
/// <summary> /// 计算下载的资源 /// </summary> private IEnumerator ComputeDownload(bool checkZip) { Debug.Log((object)"计算下载的文件"); m_downLoadList.Clear(); m_downLoadDic.Clear(); m_downLoadMD5Dic.Clear(); m_versionCheckProgress = 0.0f; #if XML if (m_gameVersion != null && m_gameVersion.Patches != null && m_gameVersion.Patches.Length > 0U) { m_currentPatches = m_gameVersion.Patches[m_gameVersion.Patches.Length - 1]; int fileCount = m_currentPatches.Files.Count; float delta = 1f / fileCount; m_zipMd5Data = new ZipMd5Data(); m_zipMd5Data.ZipMd5List = new List <ZipMd5>(); m_zipMd5Data.ZipMd5List.Clear(); if (checkZip) { yield return(ReadUnpackMd5File()); } if (m_currentPatches.Files != null && fileCount > 0) { int index = 0; Debug.Log(string.Format("当前更新包需要检查{0}个文件包", m_currentPatches.Files.Count)); foreach (Patch file in m_currentPatches.Files) { Patch patch = file; Debug.Log(patch.Name); AddDownLoadList(patch, checkZip, GetZipPatchFileMd5(patch)); OnAddDownLoadListProgressUpdate((index + 1) * delta); yield return(WaitProgressAdd(0.02f)); ++index; patch = null; } } } #elif JSON if (null != m_currentBranch && null != m_currentBranch.Patches && m_currentBranch.Patches.Count > 0) { m_needUpdatePatchesInfos = m_currentBranch.Patches.Skip(m_localVersionIndex).ToList(); m_needUpdatePatchesInfos = m_needUpdatePatchesInfos.OrderBy(i => i.Version).ToList(); //var needUpdatePatchesInfos = m_currentBranch.PatchInfos.GetRange(m_localVersionIndex, // m_currentBranch.PatchInfos.Count); for (int i = m_needUpdatePatchesInfos.Count - 1; i >= 1; i--) { foreach (var latestVersionFile in m_needUpdatePatchesInfos[i].Files) { for (int j = i - 1; j >= 0; j--) { var matchedItem = m_needUpdatePatchesInfos[j].Files.FirstOrDefault(item => item.Name == latestVersionFile.Name && item.Platform == latestVersionFile.Platform); var removeComplete = m_needUpdatePatchesInfos[j].Files.Remove(matchedItem); if (removeComplete) { Debug.Log(string.Format("Found a asset with the same name ({0}) in an older version. [REMOVE] :{1}", latestVersionFile.Name, removeComplete.ToString())); } } } } int fileCount = m_needUpdatePatchesInfos.Sum(i => i.Files.Count); float delta = 1f / fileCount; if (checkZip) { yield return(ReadUnpackMd5File()); } if (null != m_needUpdatePatchesInfos) { var index = 0; Debug.Log(string.Format("<color=green>当前更新包需要检查{0}个文件包</color>", fileCount)); foreach (var patchesInfo in m_needUpdatePatchesInfos) { foreach (var file in patchesInfo.Files) { Debug.Log("Create download task, File name :" + file.Name); AddDownLoadList(file, checkZip, GetZipPatchFileMd5(file)); OnAddDownLoadListProgressUpdate((index + 1) * delta); yield return(WaitProgressAdd(0.02f)); ++index; } } } } #endif }