예제 #1
0
        /// <summary>
        /// 更新版本资源列表
        /// </summary>
        /// <param name="versionListLength">版本资源列表大小</param>
        /// <param name="versionListHashCode">版本资源列表哈希值</param>
        /// <param name="versionListZipLength">版本资源列表压缩后大小</param>
        /// <param name="versionListZipHashCode">版本资源列表压缩后哈希值</param>
        public void UpdateVersionList(int versionListLength, int versionListHashCode, int versionListZipLength, int versionListZipHashCode)
        {
            if (GameEntry.Download == null)
            {
                throw new Exception("You must set download manager first.");
            }

            m_VersionListLength      = versionListLength;
            m_VersionListHashCode    = versionListHashCode;
            m_VersionListZipLength   = versionListZipLength;
            m_VersionListZipHashCode = versionListZipHashCode;
            string versionListFileName       = PathUtil.GetResourceNameWithSuffix(VersionListFileName);
            string latestVersionListFileName = PathUtil.GetResourceNameWithCrc32AndSuffix(VersionListFileName, m_VersionListHashCode);
            string localVersionListFilePath  = PathUtil.GetCombinePath(m_ResourceManager.ReadWritePath, versionListFileName);
            string latestVersionListFileUri  = PathUtil.GetRemotePath(m_ResourceManager.UpdatePrefixUri, latestVersionListFileName);

            GameEntry.Download.AddDownload(localVersionListFilePath, latestVersionListFileUri, this);
        }
예제 #2
0
 /// <summary>
 /// 资源更新器轮询
 /// </summary>
 /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位</param>
 /// <param name="realElapseSeconds">真实流逝时间,以秒为单位</param>
 public void OnUpdate(float deltaTime, float unscaledDeltaTime)
 {
     if (m_UpdateAllowed)
     {
         if (m_UpdateWaitingInfo.Count > 0)
         {
             if (GameEntry.Download.FreeAgentCount > 0)
             {
                 UpdateInfo updateInfo = m_UpdateWaitingInfo[0];
                 m_UpdateWaitingInfo.RemoveAt(0);
                 GameEntry.Download.AddDownload(updateInfo.ResourcePath, PathUtil.GetRemotePath(m_ResourceManager.UpdatePrefixUri, PathUtil.GetResourceNameWithCrc32AndSuffix(updateInfo.ResourceName, updateInfo.HashCode)), updateInfo);
                 m_UpdatingCount++;
             }
         }
         else if (m_UpdatingCount <= 0)
         {
             m_UpdateAllowed = false;
             PathUtil.RemoveEmptyDirectory(m_ResourceManager.ReadWritePath);
             if (ResourceUpdateAllComplete != null)
             {
                 ResourceUpdateAllComplete(UpdateFailureCount <= 0);
             }
         }
     }
 }