Esempio n. 1
0
        /// <summary>
        /// 资源更新器轮询。
        /// </summary>
        /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
        /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
        public void Update(float elapseSeconds, float realElapseSeconds)
        {
            if (m_ApplyingResourcePackStream != null)
            {
                while (m_ApplyWaitingInfo.Count > 0)
                {
                    ApplyInfo applyInfo = m_ApplyWaitingInfo[0];
                    m_ApplyWaitingInfo.RemoveAt(0);
                    if (ApplyResource(applyInfo))
                    {
                        return;
                    }
                }

                Array.Clear(m_CachedBytes, 0, CachedBytesLength);
                string resourcePackPath = m_ApplyingResourcePackPath;
                m_ApplyingResourcePackPath = null;
                m_ApplyingResourcePackStream.Dispose();
                m_ApplyingResourcePackStream = null;

                m_ResourceComponent.OnResourceApplyComplete(resourcePackPath, !m_FailureFlag, m_UpdateCandidateInfo.Count <= 0);
            }

            if (m_UpdateWaitingInfo.Count > 0)
            {
                if (m_DownloadComponent.FreeAgentCount > 0)
                {
                    UpdateInfo updateInfo = m_UpdateWaitingInfo[0];
                    m_UpdateWaitingInfo.RemoveAt(0);
                    string resourceFullNameWithCrc32 = updateInfo.ResourceName.Variant != null?Utility.Text.Format("{0}.{1}.{2:x8}.{3}", updateInfo.ResourceName.Name, updateInfo.ResourceName.Variant, updateInfo.HashCode, ResourceRation.DefaultExtension) : Utility.Text.Format("{0}.{1:x8}.{2}", updateInfo.ResourceName.Name, updateInfo.HashCode, ResourceRation.DefaultExtension);

                    m_DownloadComponent.AddDownload(updateInfo.ResourcePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceComponent.UpdatePrefixUri, resourceFullNameWithCrc32)), updateInfo);
                    m_UpdatingCount++;
                }

                return;
            }

            if (m_UpdatingResourceGroup != null && m_UpdatingCount <= 0)
            {
                ResourceGroup updatingResourceGroup = m_UpdatingResourceGroup;
                m_UpdatingResourceGroup = null;

                m_ResourceComponent.OnUpdaterResourceUpdateComplete(updatingResourceGroup, !m_FailureFlag, m_UpdateCandidateInfo.Count <= 0);

                return;
            }
        }
    protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner)
    {
        base.OnEnter(procedureOwner);

        // 加载框架Event组件
        downloadComponent = GameEntry.GetComponent <DownloadComponent>();
        eventComponent    = GameEntry.GetComponent <EventComponent>();

        eventComponent.Subscribe(DownloadUpdateEventArgs.EventId, OnDownloadUpdate);
        eventComponent.Subscribe(DownloadSuccessEventArgs.EventId, OnDownloadSuccess);

        string m_srcUrl = "http://cdn-jiaoyu-nldmx-yidong.vas.lutongnet.com/ggly_NLDMX/NLDMX_Mobile/android/GamePrimaryT6L4.ab";
        string path     = Application.persistentDataPath + Path.DirectorySeparatorChar + "test.ab";
        int    id       = downloadComponent.AddDownload(path, m_srcUrl);

        Log.Info("start    " + id);
    }
Esempio n. 3
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 (m_DownloadManager == null)
            {
                throw new Exception("You must set download manager first.");
            }

            m_VersionListLength      = versionListLength;
            m_VersionListHashCode    = versionListHashCode;
            m_VersionListZipLength   = versionListZipLength;
            m_VersionListZipHashCode = versionListZipHashCode;
            string localVersionListFilePath = Utility.Path.GetRegularPath(Path.Combine(m_ResourceManager.ReadWritePath, ResourceRation.RemoteVersionListFileName));
            int    dotPosition = ResourceRation.RemoteVersionListFileName.LastIndexOf('.');
            string latestVersionListFullNameWithCrc32 = Utility.Text.Format("{0}.{2:x8}.{1}", ResourceRation.RemoteVersionListFileName.Substring(0, dotPosition), ResourceRation.RemoteVersionListFileName.Substring(dotPosition + 1), m_VersionListHashCode);

            m_DownloadManager.AddDownload(localVersionListFilePath, Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.UpdatePrefixUri, latestVersionListFullNameWithCrc32)), this);
        }
Esempio n. 4
0
 /// <summary>
 /// 增加下载任务。
 /// </summary>
 /// <param name="downloadPath">下载后存放路径。</param>
 /// <param name="downloadUri">原始下载地址。</param>
 /// <param name="priority">下载任务的优先级。</param>
 /// <param name="userData">用户自定义数据。</param>
 /// <returns>新增下载任务的序列编号。</returns>
 public int AddDownload(string downloadPath, string downloadUri, int priority, object userData)
 {
     return(m_DownloadComponent.AddDownload(downloadPath, downloadUri, priority, userData));
 }
Esempio n. 5
0
 /// <summary>
 /// 增加下载任务(可等待)
 /// </summary>
 public static Task <bool> AwaitAddDownload(this DownloadComponent self, string downloadPath, string downloadUri)
 {
     s_DownloadTcs      = new TaskCompletionSource <bool>();
     s_DownloadSerialId = self.AddDownload(downloadPath, downloadUri);
     return(s_DownloadTcs.Task);
 }