Exemple #1
0
        private void InitCDNAssetBundleInfo()
        {
            string url = string.Format("{0}VersionFile.bytes", GameEntry.Data.SysDataManager.CurrChannelConfig.RealSourceUrl);

            GameEntry.Log(LogCategory.Resource, url);
            GameEntry.Http.SendData(url, OnInitCDNAssetBundleInfo, isGetData: true);
        }
Exemple #2
0
        /// <summary>
        /// 将只读取区版本文件初始化到可写区
        /// </summary>
        private void InitVersionFileStreamingAssetBundleToLocal()
        {
            GameEntry.Log(LogCategory.Resource, "InitVersionFileStreamingAssetBundleToLocal");

            m_LocalAssetsVersionDic = new Dictionary <string, AssetBundleInfoEntity>();

            var enumerator = m_LocalAssetsVersionDic.GetEnumerator();

            while (enumerator.MoveNext())
            {
                AssetBundleInfoEntity entity = enumerator.Current.Value;
                m_LocalAssetsVersionDic[enumerator.Current.Key] = new AssetBundleInfoEntity()
                {
                    AssetBundleName = entity.AssetBundleName,
                    MD5             = entity.MD5,
                    Size            = entity.Size,
                    IsFirstData     = entity.IsFirstData,
                    IsEncrypt       = entity.IsEncrypt
                };
            }

            //保存版本文件
            LocalAssetsManager.SaveVersionFile(m_LocalAssetsVersionDic);

            //保存版本号
            m_LocalAssetsVersion = m_StreamingAssetsVersion;
            LocalAssetsManager.SetResourceVersion(m_LocalAssetsVersion);
        }
Exemple #3
0
 /// <summary>
 /// 检查更新
 /// </summary>
 private void CheckVersionChange()
 {
     GameEntry.Log(LogCategory.Resource, "CheckVersionChange");
     if (LocalAssetsManager.GetVersionFileExists())
     {
         //判断只读区资源版本号和cdn资源版本号是否一致
         if (!string.IsNullOrEmpty(m_LocalAssetsVersion) && m_LocalAssetsVersion.Equals(m_CDNVersion))
         {
             GameEntry.Log(LogCategory.Resource, "只读区资源版本号和cdn资源版本号一致");
             //一致进入预加载流程
             GameEntry.Procedure.ChangeState(ProcedureState.Preload);
         }
         else
         {
             GameEntry.Log(LogCategory.Resource, "只读区资源版本号和cdn资源版本号不一致");
             //TODO: 不一致 开始检查更新
             BeginCheckVersionChange();
             //最后进入到预加载流程
         }
     }
     else
     {
         //TODO: 下载初始资源
         GameEntry.Log(LogCategory.Resource, "下载初始资源");
         DownloadInitResourse();
     }
 }
Exemple #4
0
        public void OnUpdate()
        {
            if (Time.time > m_ReleaseClassObjectNextRunTime + ReleaseClassObjectInterval)
            {
                m_ReleaseClassObjectNextRunTime = Time.time;
                PoolManager.ReleaseClassObjectPool();
                GameEntry.Log(LogCategory.Normal, "释放类对象池");
            }
            if (Time.time > m_ReleaseAssetBundleNextRunTime + ReleaseResourceInterval)
            {
                m_ReleaseAssetBundleNextRunTime = Time.time;
#if !DISABLE_ASSETBUNDLE
                PoolManager.ReleaseAssetBundlePool();
                GameEntry.Log(LogCategory.Normal, "释放AssetBundle池 时间间隔" + ReleaseResourceInterval);
#endif
            }
            if (Time.time > m_ReleaseAssetNextRunTime + ReleaseAssetInterval)
            {
                m_ReleaseAssetNextRunTime = Time.time;
#if !DISABLE_ASSETBUNDLE
                PoolManager.ReleaseAssetPool();
                GameEntry.Log(LogCategory.Normal, "释放Asset池");
#endif
                if (LuaManager.luaEnv == null)
                {
                    Debug.Log("lua启动失败");
                }
                else
                {
                    LuaManager.luaEnv.FullGc(); //回收lua中可回收的东西
                }
                Resources.UnloadUnusedAssets(); //删除无用的资源
            }
        }
Exemple #5
0
        public override void OnLeave()
        {
            base.OnLeave();
            GameEntry.Log(LogCategory.Procedure, "OnLeave ProcedurePreload");
            GameEntry.Event.CommonEvent.RemoveEventListener(SysEventId.LoadDataTableComplete, OnLoadDataTableComplete);
            GameEntry.Event.CommonEvent.RemoveEventListener(SysEventId.LoadOneDataTableComplete, OnLoadOneDataTableComplete);

            GameEntry.Event.CommonEvent.RemoveEventListener(SysEventId.LoadLuaDataTableComplete, OnLoadLuaDataTableComplete);
        }
Exemple #6
0
        /// <summary>
        /// 加载资源信息回调
        /// </summary>
        /// <param name="args"></param>

        private void OnLoadAssetInfoFromCDN(HttpCallBackArgs args)
        {
            if (!args.HasError)
            {
                InitAssetInfo(args.Data);
            }
            else
            {
                GameEntry.Log(LogCategory.Resource, args.Value);
            }
        }
Exemple #7
0
        public override void OnEnter()
        {
            base.OnEnter();

            GameEntry.Log(LogCategory.Procedure, "OnEnter ProcedureLogOn");
            //속潼되쩌끝쒼
            GameEntry.UI.OpenUIForm(UIFormId.LogOn);
            //GameEntry.Scene.LoadScene(11, true, onComplete: () =>
            //   {
            //       //속潼되쩌ui
            //       GameEntry.Event.CommonEvent.Dispatch(SysEventId.CloseCheckVersionUI);
            //   });
            GameEntry.Event.CommonEvent.Dispatch(SysEventId.CloseCheckVersionUI);
        }
Exemple #8
0
        /// <summary>
        /// 初始化CDN资源包信息回调
        /// </summary>
        /// <param name="args"></param>
        private void OnInitCDNAssetBundleInfo(HttpCallBackArgs args)
        {
            if (!args.HasError)
            {
                m_CDNVersionDic = GetAssetBundleVersionList(args.Data, ref m_CDNVersion);
                GameEntry.Log(LogCategory.Resource, "初始化cdn资源包信息OnInitCDNAssetBundleInfo");

                CheckVersionFileExistsInLocal();
            }
            else
            {
                GameEntry.Log(LogCategory.Resource, args.Value);
            }
        }
Exemple #9
0
        private void LoadShader()
        {
#if DISABLE_ASSETBUNDLE
            m_TargerProgress = 100;
#else
            GameEntry.Resource.ResourceLoaderManager.LoadAssetBundle(ConstDefine.CusShadersAssetBundlePath, onComplete: (AssetBundle bundle) =>
            {
                bundle.LoadAllAssets();

                for (int i = 0; i < 5; i++)
                {
                    Shader.WarmupAllShaders();
                }
                GameEntry.Log(LogCategory.Normal, "加载资源包中自定义的shader完毕");
                m_TargerProgress = 100;
            });
#endif
        }
Exemple #10
0
        private void OnWebAccountInit(HttpCallBackArgs args)
        {
            if (!args.HasError)
            {
                JsonData data = JsonMapper.ToObject(args.Value);
                //Debug.Log(data);
                JsonData config = JsonMapper.ToObject(data["Value"].ToString());
                //Debug.Log(data["Value"]);
                GameEntry.Data.SysDataManager.CurrChannelConfig.ServerTime    = long.Parse(config["ServerTime"].ToString());
                GameEntry.Data.SysDataManager.CurrChannelConfig.SourceVersion = config["SourceVersion"].ToString();
                GameEntry.Data.SysDataManager.CurrChannelConfig.SourceUrl     = config["SourceUrl"].ToString();
                GameEntry.Data.SysDataManager.CurrChannelConfig.RechargeUrl   = config["RechargeUrl"].ToString();
                GameEntry.Data.SysDataManager.CurrChannelConfig.TDAppId       = config["TDAppId"].ToString();
                GameEntry.Data.SysDataManager.CurrChannelConfig.IsOpenTD      = int.Parse(config["IsOpenTD"].ToString()) == 1;

                GameEntry.Log(LogCategory.Resource, "RealSourceUrl:" + GameEntry.Data.SysDataManager.CurrChannelConfig.RealSourceUrl);
                //切换到检测版本流程
                GameEntry.Procedure.ChangeState(ProcedureState.CheckVersion);
            }
        }
Exemple #11
0
        /// <summary>
        /// 加载所有表完毕
        /// </summary>
        /// <param name="userData"></param>
        private void OnLoadDataTableComplete(object userData)
        {
            GameEntry.Log(LogCategory.Normal, "加载所有c#表完毕");

            //List<JobEntity> lit = GameEntry.DataTable.DataTableManager.JobDBModel.GetList();
            //for (int i = 0; i < lit.Count; i++)
            //{
            //    Debug.Log(lit[i].AttackNumber);
            //}

            JobEntity lit = GameEntry.DataTable.DataTableManager.JobDBModel.Get(1);

            Debug.Log(lit.HP);
            GameEntry.Lua.LoadDataTable("Job", (MMO_MemoryStream ms) =>
            {
            });

            //初始化lua
            GameEntry.Lua.Init();
        }
Exemple #12
0
        public override void OnEnter()
        {
            base.OnEnter();
            GameEntry.Log(LogCategory.Procedure, "OnEnter ProcedureLaunch");
            //访问账号服务器
            string url = GameEntry.Http.ReadAccountUrl + "/api/init";

            Dictionary <string, object> dic = GameEntry.Pool.DequeueClassObject <Dictionary <string, object> > ();

            dic.Clear();

            GameEntry.Data.SysDataManager.CurrChannelConfig.ChannelId    = 0;
            GameEntry.Data.SysDataManager.CurrChannelConfig.InnerVersion = 1001;

            dic["ChannelId"]    = GameEntry.Data.SysDataManager.CurrChannelConfig.ChannelId;
            dic["InnerVersion"] = GameEntry.Data.SysDataManager.CurrChannelConfig.InnerVersion;


            GameEntry.Http.SendData(url, OnWebAccountInit, true, false, dic);
        }
Exemple #13
0
        /// <summary>
        /// 请求服务器
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private IEnumerator Request(UnityWebRequest data)
        {
            yield return(data.SendWebRequest());

            IsBusy = false;
            if (data.isNetworkError || data.isHttpError)
            {
                if (m_CallBack != null)
                {
                    m_CallBackArgs.HasError = true;
                    m_CallBackArgs.Value    = data.error;
                    if (!m_IsGetData)
                    {
                        GameEntry.Log(LogCategory.Proto, "<color=#730FF1>接收消息:</color><color=#730FF1>" + data.url + "</color>");
                        GameEntry.Log(LogCategory.Proto, "<color=#730FF1>==>>" + JsonUtility.ToJson(m_CallBackArgs) + "</color>");
                    }
                    m_CallBack(m_CallBackArgs);
                }
            }
            else
            {
                if (m_CallBack != null)
                {
                    m_CallBackArgs.HasError = false;
                    m_CallBackArgs.Value    = data.downloadHandler.text;

                    if (!m_IsGetData)
                    {
                        GameEntry.Log(LogCategory.Proto, "<color=#730FF1>接收消息:</color><color=#730FF1>" + data.url + "</color>");
                        GameEntry.Log(LogCategory.Proto, "<color=#730FF1>==>>" + JsonUtility.ToJson(m_CallBackArgs) + "</color>");
                    }

                    m_CallBackArgs.Data = data.downloadHandler.data;
                    m_CallBack(m_CallBackArgs);
                }
            }

            data.Dispose();
            data = null;
            GameEntry.Pool.EnqueueClassObject(this);
        }
Exemple #14
0
 /// <summary>
 /// 检查可写区版本文件是否存在
 /// </summary>
 private void CheckVersionFileExistsInLocal()
 {
     GameEntry.Log(LogCategory.Resource, "CheckVersionFileExistsInLocal");
     if (LocalAssetsManager.GetVersionFileExists())
     {
         //可写区版本文件存在
         //加载可写区资源包信息
         InitLocalAssetsBundleInfo();
     }
     else
     {
         //可写区版本文件不存在
         //判断可写区版本文件是否存在
         if (m_IsExistsStreamingAssetBundleInfo)
         {
             //只读取区版本文件存在
             //将只读取区版本文件初始化到可写区
             InitVersionFileStreamingAssetBundleToLocal();
         }
         CheckVersionChange();
     }
 }
Exemple #15
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 #16
0
        /// <summary>
        /// 初始化只读区资源包信息
        /// </summary>
        public void InitStreamingAssetsBundleInfo()
        {
            GameEntry.Log(LogCategory.Resource, "InitStreamingAssetsBundleInfo");

            ReadStreamingAssetBundle("VersionFile.bytes", (byte[] buffer) =>
            {
                if (buffer == null)
                {
                    Debug.Log("只读区为空");
                    InitCDNAssetBundleInfo();
                }
                else
                {
                    m_IsExistsStreamingAssetBundleInfo = true;
                    Debug.Log("获取只读区信息包" + m_StreamingAssetsVersion);

                    m_StreamingAssetsVersionDic = GetAssetBundleVersionList(buffer, ref m_StreamingAssetsVersion);

                    InitCDNAssetBundleInfo();
                }
            });
        }
Exemple #17
0
        public override void OnUpdate()
        {
            base.OnUpdate();

            if (m_CurrProgress < m_TargerProgress)
            {
                m_CurrProgress = m_CurrProgress + Time.deltaTime * 200;//根据实际情况调节进度
                m_PreloadParams.FloatParam1 = m_CurrProgress;
                GameEntry.Event.CommonEvent.Dispatch(SysEventId.PreloadUpdate, m_PreloadParams);
            }
            else if (m_CurrProgress >= 100)
            {
                m_CurrProgress = 100;
                m_PreloadParams.FloatParam1 = m_CurrProgress;
                GameEntry.Event.CommonEvent.Dispatch(SysEventId.PreloadUpdate, m_PreloadParams);

                GameEntry.Log(LogCategory.Normal, "预加载完毕");
                GameEntry.Event.CommonEvent.Dispatch(SysEventId.PreloadComplete);
                GameEntry.Pool.EnqueueClassObject(m_PreloadParams);

                GameEntry.Procedure.ChangeState(ProcedureState.LogOn);
            }
        }
Exemple #18
0
 public override void OnLeave()
 {
     base.OnLeave();
     GameEntry.Log(LogCategory.Procedure, "OnLeave ProcedureLogOn");
 }
Exemple #19
0
 public override void OnDestry()
 {
     base.OnDestry();
     GameEntry.Log(LogCategory.Procedure, "OnDestry ProcedureLaunch");
 }
Exemple #20
0
 private void OnLoadLuaDataTableComplete(object userData)
 {
     GameEntry.Log(LogCategory.Normal, "加载所有的lua表格完成");
     LoadShader();
 }