Esempio n. 1
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="sceneId">场景编号</param>
        /// <param name="showLoadingForm">是否显示Loading</param>
        /// <param name="onComplete">加载完毕</param>
        public void LoadScene(int sceneId, bool showLoadingForm = false, BaseAction onComplete = null)
        {
            if (m_CurrSceneIsLoading)
            {
                GameEntry.LogError("场景{0}正在加载中", m_CurrLoadSceneId);
                return;
            }

            if (m_CurrLoadSceneId == sceneId)
            {
                GameEntry.LogError("正在重复加载场景{0}", sceneId);
                return;
            }

            m_CurrLoadingParam = GameEntry.Pool.DequeueClassObject <BaseParams>();
            m_OnComplete       = onComplete;

            if (showLoadingForm)
            {
                //加载Loading
                GameEntry.UI.OpenUIForm(UIFormId.Loading, onOpen: (UIFormBase form) =>
                {
                    DoLoadScene(sceneId);
                });
            }
            else
            {
                DoLoadScene(sceneId);
            }
        }
Esempio n. 2
0
        public override void OnEnter()
        {
            base.OnEnter();
            GameEntry.Log(LogCategory.Procedure, "OnEnter ProcedurePreload");

            GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadOneDataTableComplete, OnLoadOneDataTableComplete);
            GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadDataTableComplete, OnLoadDataTableComplete);
            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_TargetProgress = 99;
#if !DISABLE_ASSETBUNDLE
            GameEntry.Resource.InitAssetInfo();
#endif
            GameEntry.DataTable.LoadDataTableAsync();
        }
Esempio n. 3
0
        /// <summary>
        /// 下载初始资源
        /// </summary>
        private void DownloadInitResources()
        {
            GameEntry.Event.CommonEvent.Dispatch(SysEventId.CheckVersionBeginDownload);
            m_DownloadingParams = GameEntry.Pool.DequeueClassObject <BaseParams>();
            m_DownloadingParams.Reset();

            m_NeedDownloadList.Clear();

            var enumerator = m_CNDVersionDic.GetEnumerator();

            while (enumerator.MoveNext())
            {
                AssetBundleInfoEntity entity = enumerator.Current.Value;
                if (entity.IsFirstData)
                {
                    m_NeedDownloadList.AddLast(entity.AssetBundleName);
                }
            }

            GameEntry.Download.BeginDownloadMulit(m_NeedDownloadList, OnDownloadMulitUpdate, OnDownloadMulitComplete);
        }
Esempio n. 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> inconformityList = 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_CNDVersionDic.TryGetValue(assetBundleName, out cdnAssetBundleInfo))
                {
                    //可写区有 CDN也有
                    if (!cdnAssetBundleInfo.MD5.Equals(enumerator.Current.Value.MD5, StringComparison.CurrentCultureIgnoreCase))
                    {
                        //如果MD5不一致 加入不一致链表
                        inconformityList.AddLast(assetBundleName);
                    }
                }
                else
                {
                    //可写区有 CDN上没有 加入删除列表
                    delList.AddLast(assetBundleName);
                }
            }

            //循环判断这个文件在只读区的MD5和CDN是否一致 一致的进行删除 不一致的进行重新下载
            LinkedListNode <string> currInconformity = inconformityList.First;
            while (currInconformity != null)
            {
                AssetBundleInfoEntity cdnAssetBundleInfo = null;
                m_CNDVersionDic.TryGetValue(currInconformity.Value, out cdnAssetBundleInfo);

                AssetBundleInfoEntity streamingAssetsAssetBundleInfo = null;
                if (m_StreamingAssetsVersionDic != null)
                {
                    m_StreamingAssetsVersionDic.TryGetValue(currInconformity.Value, out streamingAssetsAssetBundleInfo);
                }

                if (streamingAssetsAssetBundleInfo == null)
                {
                    //如果只读区 没有
                    needDownloadList.AddLast(currInconformity.Value);
                }
                else
                {
                    //判断 是否一致
                    if (cdnAssetBundleInfo.MD5.Equals(streamingAssetsAssetBundleInfo.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_CNDVersionDic.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);
        }