Exemple #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);
            }
        }
Exemple #2
0
        /// <summary>
        /// 下载初始化资源
        /// </summary>
        private void DownloadInitResourse()
        {
            GameEntry.Event.CommonEvent.Dispatch(SysEventId.CheckVersionBeginDownload);
            m_DownloadingParams = GameEntry.Pool.DequeueClassObject <BaseParams>();
            m_NeedDownloadList.Clear();

            var enumerator = m_CDNVersionDic.GetEnumerator();

            while (enumerator.MoveNext())
            {
                AssetBundleInfoEntity entity = enumerator.Current.Value;
                if (entity.IsFirstData)
                {
                    m_NeedDownloadList.AddLast(entity.AssetBundleName);
                }
            }
            GameEntry.Download.BeginDownloadMulit(m_NeedDownloadList, OnDownloadMulitUpdate, OnDownloadMulitComplete);
        }
Exemple #3
0
        public override void OnEnter()
        {
            base.OnEnter();
            GameEntry.Log(LogCategory.Procedure, "OnEnter ProcedurePreload");


            GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadDataTableComplete, OnLoadDataTableComplete);
            GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadOneDataTableComplete, OnLoadOneDataTableComplete);
            GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadLuaDataTableComplete, OnLoadLuaDataTableComplete);

            GameEntry.Log(LogCategory.Normal, "预加载开始");
            m_PreloadParams = GameEntry.Pool.DequeueClassObject <BaseParams>();
            m_PreloadParams.Reset();
            GameEntry.Event.CommonEvent.Dispatch(SysEventId.PreloadBegin);

            m_TargerProgress = 98;
#if !DISABLE_ASSETBUNDLE
            GameEntry.Resource.InitAssetInfo();
#endif

            GameEntry.DataTable.LoadDataTableAsync();
        }
Exemple #4
0
        /// <summary>
        /// 开始检查版本更新
        /// </summary>
        private void BeginCheckVersionChange()
        {
            m_DownloadingParams = GameEntry.Pool.DequeueClassObject <BaseParams>();
            m_DownloadingParams.Reset();

            //需要删除的文件
            LinkedList <string> delList = new LinkedList <string>();

            //可写区资源md5和cdn资源md5不一致
            LinkedList <string> inconformtyList = new LinkedList <string>();

            LinkedList <string> needDownloadList = new LinkedList <string>();

            #region 找出需要删除的文件 删除
            var enumerator = m_LocalAssetsVersionDic.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string assetBundleName = enumerator.Current.Key;

                //去cdn对比
                AssetBundleInfoEntity cdnAssetBundleInfo = null;
                if (m_CDNVersionDic.TryGetValue(assetBundleName, out cdnAssetBundleInfo))
                {
                    //可写区有 cdn也有
                    if (!cdnAssetBundleInfo.MD5.Equals(enumerator.Current.Value.MD5, StringComparison.CurrentCultureIgnoreCase))
                    {
                        //如果md5不一致 加入不一致列表
                        inconformtyList.AddLast(assetBundleName);
                    }
                }
                else
                {
                    //可写区有 cdn上没有 加入删除列表
                    delList.AddLast(assetBundleName);
                }
            }
            //循环判断这个文件在只读区的md5和cdn是否一致 一致的进行删除 不一致的进行重新下载
            LinkedListNode <string> currInconformity = inconformtyList.First;
            while (currInconformity != null)
            {
                AssetBundleInfoEntity cdnAssetBundleInfo = null;
                m_CDNVersionDic.TryGetValue(currInconformity.Value, out cdnAssetBundleInfo);

                AssetBundleInfoEntity streamingAssetAssetBundleInfo = null;
                if (m_StreamingAssetsVersionDic != null)
                {
                    m_StreamingAssetsVersionDic.TryGetValue(currInconformity.Value, out streamingAssetAssetBundleInfo);
                }
                if (streamingAssetAssetBundleInfo == null)
                {
                    //如果只读区 没有
                    needDownloadList.AddLast(currInconformity.Value);
                }
                else
                {
                    //判断 是否一致
                    if (cdnAssetBundleInfo.MD5.Equals(streamingAssetAssetBundleInfo.MD5, StringComparison.CurrentCultureIgnoreCase))
                    {
                        //一致
                        delList.AddLast(currInconformity.Value);
                    }
                    else
                    {
                        //不一致
                        needDownloadList.AddLast(currInconformity.Value);
                    }
                }
                currInconformity = currInconformity.Next;
            }
            #endregion

            #region
            LinkedListNode <string> currDel = delList.First;
            while (currDel != null)
            {
                string filePath = string.Format("{0}/{1}", GameEntry.Resource.LocalFilePath, currDel.Value);

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                LinkedListNode <string> next = currDel.Next;
                delList.Remove(currDel);
                currDel = next;
            }

            #endregion

            #region 检查需要下载的

            enumerator = m_CDNVersionDic.GetEnumerator();
            while (enumerator.MoveNext())
            {
                AssetBundleInfoEntity cdnAssetBundleInfo = enumerator.Current.Value;
                if (cdnAssetBundleInfo.IsFirstData)
                {
                    //检查初始资源
                    if (!m_LocalAssetsVersionDic.ContainsKey(cdnAssetBundleInfo.AssetBundleName))
                    {
                        //如果可写区没有 就去只读区判断一次
                        AssetBundleInfoEntity streamingAssetsAssetBundleInfo = null;
                        if (m_StreamingAssetsVersionDic != null)
                        {
                            m_StreamingAssetsVersionDic.TryGetValue(cdnAssetBundleInfo.AssetBundleName, out streamingAssetsAssetBundleInfo);
                        }
                        if (streamingAssetsAssetBundleInfo == null)
                        {
                            //只读区 不存在
                            needDownloadList.AddLast(cdnAssetBundleInfo.AssetBundleName);
                        }
                        else
                        {
                            //只读区存在 验证md5
                            if (!cdnAssetBundleInfo.MD5.Equals(streamingAssetsAssetBundleInfo.MD5, StringComparison.CurrentCultureIgnoreCase))
                            {
                                //md5不一致
                                needDownloadList.AddLast(cdnAssetBundleInfo.AssetBundleName);
                            }
                        }
                    }
                }
            }

            #endregion
            GameEntry.Event.CommonEvent.Dispatch(SysEventId.CheckVersionBeginDownload);

            //进行下载
            GameEntry.Download.BeginDownloadMulit(needDownloadList, OnDownloadMulitUpdate, OnDownloadMulitComplete);
        }