Esempio n. 1
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="sceneId">场景id</param>
        /// <param name="showLoadingForm">是否显示加载界面</param>
        /// <param name="onComplete">加载完成回调</param>
        public void LoadScene(int sceneId, bool showLoadingForm = false, BaseAction onComplete = null)
        {
            if (m_CurrSceneIsLoading)
            {
                GameEntry.LogError("场景{0}正在加载中", m_CurrLoadSceneId.ToString());
                return;
            }
            if (m_CurrLoadSceneId == sceneId)
            {
                GameEntry.LogError("正在重复加载{0}", sceneId.ToString());
                return;
            }
            m_CurrLoadingParam = GameEntry.Pool.DequeueClassObject <BaseParams>();
            m_OnComplete       = onComplete;

            if (showLoadingForm)
            {
                //加载Loading ui
                GameEntry.UI.OpenUIForm(UIFormId.Loading, onOpen: (UIFormBase form) =>
                {
                    DoLoadScene(sceneId);
                });
            }
            else
            {
                DoLoadScene(sceneId);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 下载多个文件
        /// </summary>
        /// <param name="lstUrl"></param>
        /// <param name="onDownloadMulitUpdate"></param>
        /// <param name="onDownloadMulitComplete"></param>
        public void BeginDownloadMulit(LinkedList <string> lstUrl, BaseAction <int, int, ulong, ulong> onDownloadMulitUpdate, BaseAction onDownloadMulitComplete)
        {
            m_OnDownloadMulitUpdate   = onDownloadMulitUpdate;
            m_OnDownloadMulitComplete = onDownloadMulitComplete;

            m_NeedDownloadList.Clear();
            m_DownloadMulitCurrSizeDic.Clear();

            m_DownloadMulitNeedCount = 0;
            m_DownloadMulitCurrCount = 0;

            m_DownloadMulitTotalSize = 0;
            m_DownloadMulitCurrSize  = 0;

            //m_DownloadMulitNeedCount = lstUrl.Count;
            //m_DownloadMulitCurrCount = 0;

            //1.把需要下载的加入下载列表
            for (LinkedListNode <string> item = lstUrl.First; item != null; item = item.Next)
            {
                string url = item.Value;
                Debug.Log("要下载的资源" + url);
                AssetBundleInfoEntity entity = GameEntry.Resource.ResourceManager.GetAssetBundleInfo(url);
                if (entity != null)
                {
                    m_DownloadMulitTotalSize += entity.Size;
                    m_DownloadMulitNeedCount++;
                    m_NeedDownloadList.AddLast(url);
                    m_DownloadMulitCurrSizeDic[url] = 0;
                }
                else
                {
                    GameEntry.LogError("无效资源包=》" + url);
                }
            }
            //2.下载器数量 最多五个
            int routineCount = Mathf.Min(GameEntry.Download.DownloadRoutineCount, m_NeedDownloadList.Count);

            for (int i = 0; i < routineCount; i++)
            {
                DownloadRoutine routine = GameEntry.Pool.DequeueClassObject <DownloadRoutine>();

                string url = m_NeedDownloadList.First.Value;
                m_NeedDownloadList.RemoveFirst();

                AssetBundleInfoEntity entity = GameEntry.Resource.ResourceManager.GetAssetBundleInfo(url);

                routine.BeginDownload(url, entity, OnDownloadMulitUpdate, OnDownloadMulitComplete);
                m_DownloadRoutineList.AddLast(routine);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 根据资源分类和资源路劲获取资源信息
        /// </summary>
        /// <param name="assetCategory"></param>
        /// <param name="assetFullName"></param>
        /// <returns></returns>
        public AssetEntity GetAssetEntity(AssetCategory assetCategory, string assetFullName)
        {
            Dictionary <string, AssetEntity> dicCategory = null;

            if (m_AssetInfoDic.TryGetValue(assetCategory, out dicCategory))
            {
                AssetEntity entity = null;
                if (dicCategory.TryGetValue(assetFullName, out entity))
                {
                    return(entity);
                }
            }
            GameEntry.LogError("{0}不存在", assetFullName);
            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="url"></param>
        /// <param name="onUpdate"></param>
        /// <param name="onComplete"></param>
        public void BeginDownloadSingle(string url, BaseAction <string, ulong, float> onUpdate = null, BaseAction <string> onComplete = null)
        {
            AssetBundleInfoEntity entity = GameEntry.Resource.ResourceManager.GetAssetBundleInfo(url);

            if (entity == null)
            {
                GameEntry.LogError("无效资源包=》" + url);
                return;
            }

            DownloadRoutine routine = GameEntry.Pool.DequeueClassObject <DownloadRoutine>();

            routine.BeginDownload(url, entity, onUpdate, onComplete: (string fileUrl, DownloadRoutine r) =>
            {
                m_DownloadRoutineList.Remove(r);
                GameEntry.Pool.EnqueueClassObject(routine);
                if (onComplete != null)
                {
                    onComplete(fileUrl);
                }
            });
            m_DownloadRoutineList.AddLast(routine);
        }