浏览代码

启动流程优化

guodong 3 年之前
父节点
当前提交
81231f5552

+ 5 - 25
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -87,31 +87,13 @@ namespace GFGGame
 
         public static async ETTask PreEnterGameAsync()
         {
-            //RoleInfo roleInfo = null;
-            GetSuitItemController.enable = false;
-            //roleInfo = result.roleInfo;
-            //bool rerult = AntiAddictionController.CheckAntiAddiction(roleInfo.onlineTimeSecs, roleInfo.onlineDurationSecs, roleInfo.onlineDurationSecsDay);
-            //if (rerult)
-            //{
-            //    return;
-            //}
-            //ServerDataManager.SetServerTime(roleInfo.serverTime);
-            RoleDataManager.InitServerData();
-            //ItemDataManager.InitServerData(result.roleItemList);
-            //CustomSuitDataManager.InitServerData(roleInfo.suitIndex, result.roleSuitList);
-            //StoryDataManager.InitServerData(roleInfo);
-            //GuideDataManager.InitServerData(result.roleGuideList);
-            //CardDataManager.InitServerData(result.roleCardList);
-            //SkillDataManager.Instance.InitServerData(result.roleSkillList);
-            //SkillDataManager.Instance.SetDicPassivitySkillCfg();
-            GetSuitItemController.enable = true;
             RoleDataHandler.StartUpdate();
 
             GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
             GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main"));
 
 
-            InstanceZonesSProxy.GetInstanceZonesInfos().Coroutine();
+            await InstanceZonesSProxy.GetInstanceZonesInfos();
             await StorageSProxy.ReqGetClientValues();
 
             int skipGuide = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_SKIP_GUIDE);
@@ -142,12 +124,13 @@ namespace GFGGame
 
         public static void QuitToLoginView(bool logout)
         {
-            GetSuitItemController.enable = false;
             GameGlobal.isVisitor = false;
             GameGlobal.antiAddiction = true;
             GameGlobal.userId = 0;
             GameGlobal.userAge = 0;
             GameGlobal.skipGuide = false;
+            GameGlobal.myUnit.Dispose();
+            GameGlobal.myUnit = null;
             RoleDataHandler.StopUpdate();
             CardDataManager.Clear();
             DecomposeDataManager.Instance.Clear();
@@ -184,7 +167,7 @@ namespace GFGGame
 
         private static void EnterGame()
         {
-            ViewManager.Hide<LoginView>();
+            ViewManager.Hide<LoginView>(); 
             GameGlobal.isEnterGame = true;
             if (MainStoryDataManager.CheckOpenMainUI() || GameGlobal.skipGuide)
             {
@@ -203,14 +186,11 @@ namespace GFGGame
                     ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, MainStoryDataManager.currentChapterCfgId, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW });
                 }
             }
-            Timers.inst.CallLater(AfterEnterGame);
+            Timers.inst.Add(1f, 1, AfterEnterGame);
         }
 
         private static async void AfterEnterGame(object param)
         {
-            //GameProxy.ReqGetStoryScoreList();
-            //GameProxy.ReqGetStoryStarList();
-
             ItemHelper.GetItemAttributeInfos().Coroutine();
             SuitFosterProxy.SendGetSuitInfos().Coroutine();
             MainStorySProxy.GetStoryInfos().Coroutine();

+ 4 - 9
GameClient/Assets/Game/HotUpdate/Controller/LoginController.cs

@@ -213,16 +213,11 @@ namespace GFGGame
                 ErrorCodeController.Handler(errorCode);
                 return;
             }
-
-            var roleInfosComponent = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>();
-            if (roleInfosComponent.RoleInfos != null && roleInfosComponent.RoleInfos.Count > 0)
-            {
-                var roleInfo = roleInfosComponent.RoleInfos[0];
-                roleInfosComponent.CurrentRoleId = roleInfo.Id;
-                await ReqEnterGame();
-            }
-
             ViewManager.Hide(ViewName.CREATE_ROLE_VIEW);
+            var roleInfosComponent = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>();
+            var roleInfo = roleInfosComponent.RoleInfos[0];
+            roleInfosComponent.CurrentRoleId = roleInfo.Id;
+            await ReqEnterGame();
         }
 
         public static async ETTask ReqEnterGame()

+ 3 - 10
GameClient/Assets/Game/HotUpdate/Data/ItemDataManager.cs

@@ -1,10 +1,6 @@
-using System;
 using System.Collections.Generic;
-using System.Reflection;
 using ET;
-using FairyGUI;
 using UnityEngine;
-using static UnityEditor.Progress;
 
 namespace GFGGame
 {
@@ -47,17 +43,14 @@ namespace GFGGame
                 }
 
                 FunctionOpenCfg functionOpenCfg = FunctionOpenCfgArray.Instance.GetCfg(typeof(SuitListView).Name);
-                if (itemCfg.rarity == ConstDressRarity.Rarity_TIANYI && StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + functionOpenCfg.index) == 0)
+                if (GameGlobal.myUnit != null//游戏角色初始数据不处理
+                    && itemCfg.rarity == ConstDressRarity.Rarity_TIANYI 
+                    && StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + functionOpenCfg.index) == 0)
                 {
                     
                     FunctionOpenDataManager.Instance.CheckHasSpecialFunOpen();
                 }
             }
-
-            // if (itemCfg.itemType == ConstItemType.DRESS_UP && !DressUpMenuItemDataManager.CheckIsSceneType(itemID))
-            // {
-            //     DecomposeDataManager.Instance.Add(itemID);
-            // }
             PhotographDataManager.Instance.Add(itemID);
             EventAgent.DispatchEvent(ConstMessage.ITEM_CHANGED, itemID);
         }

+ 0 - 9
GameClient/Assets/Game/HotUpdate/Data/RoleDataManager.cs

@@ -91,16 +91,7 @@ namespace GFGGame
 
         public static void InitServerData()
         {
-            //roleId = roleInfo.id;
             roleName = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRoleName();
-            //rechargeTotal = roleInfo.rechargeTotal;
-            //rechargeTotalMon = roleInfo.rechargeTotalMon;
-            //_gold = roleInfo.gold;
-            //_exp = roleInfo.exp;
-            //_lvl = roleInfo.lvl;
-            //_diaP = roleInfo.diaP;
-            //_diaR = roleInfo.diaR;
-
         }
 
         private static int oldLvValue;

+ 2 - 0
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Unit/UnitFactory.cs

@@ -29,6 +29,8 @@ namespace ET
             ItemDataManager.InitServerData(unitInfo.Items);
             //自定义套装
             CustomSuitDataManager.InitServerData(unitInfo.CustomSuits);
+            //角色信息
+            RoleDataManager.InitServerData();
             return unit;
         }
     }

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/Common/Controller/GetSuitItemController.cs

@@ -4,12 +4,12 @@ namespace GFGGame
 {
     public class GetSuitItemController
     {
-        public static bool enable = false;
+        public static bool enable = true;
         private static List<int> _waitingToShowList = new List<int>();
 
         public static void AddItemId(int itemId)
         {
-            if(!enable)
+            if(!enable || GameGlobal.myUnit == null)
             {
                 return;
             }

+ 8 - 4
GameClient/Assets/Game/Launcher/FairyGUI/FGUILauncher.cs

@@ -1,7 +1,4 @@
-using System.Collections;
-using UnityEngine;
-using GFGGame.Launcher;
-using FairyGUI;
+using FairyGUI;
 
 namespace GFGGame
 {
@@ -10,6 +7,13 @@ namespace GFGGame
 
         public static void Init()
         {
+#if (UNITY_5 || UNITY_5_3_OR_NEWER)
+            //Use the font names directly
+            UIConfig.defaultFont = "Microsoft YaHei";
+#else
+        //Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
+        // UIExcelConfig.defaultFont = "afont";
+#endif
             //对于FGUI来说,其内部在执行 `UIPackage.RemovePackage` 时会进行`ab.Unload(true)`操作,应该是个很贴心的设计,但我们xasset需要管理资源的引用计数,所以不需要这个贴心的功能,故:
             UIPackage.unloadBundleByFGUI = false;
             //设置CustomLoader

+ 45 - 6
GameClient/Assets/Game/Launcher/GameLauncher.cs

@@ -2,13 +2,12 @@ using UnityEngine;
 using GFGGame;
 using ET;
 using System.Threading;
+using GFGGame.Launcher;
 
 public class GameLauncher : MonoBehaviour
 {
     private void Awake()
     {
-        Screen.sleepTimeout = SleepTimeout.NeverSleep;
-        Application.runInBackground = true;
         //ET
         System.AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
         {
@@ -31,13 +30,53 @@ public class GameLauncher : MonoBehaviour
     // Start is called before the first frame update
     void Start()
     {
-        LauncherConfig.Init();
-        Debug.LogFormat("Application.version {0}", Application.version);
+        Screen.sleepTimeout = SleepTimeout.NeverSleep;
+        Application.runInBackground = true;
+        LauncherConfig.InitScriptCompilation();
         FGUILauncher.Init();
         LauncherView.Instance.Open();
-        LauncherView.Instance.SetDesc("正在初始化...");
-        LauncherConfig.GetLauncherCfg();
+        InitLauncherCfg();
+    }
+
+    /// <summary>
+    /// 初始化启动器配置
+    /// </summary>
+    public void InitLauncherCfg()
+    {
+        LauncherView.Instance.SetDesc("正在初始化..");
+        var url = LauncherConfig.cfgUrl.Replace("{cfgName}", LauncherConfig.cfgName);
+        HttpTool.Instance.Get(url, (string json) =>
+        {
+            LauncherConfig.InitPlatform(json);
+            LauncherView.Instance.SetDesc("正在初始化...");
+            //第一个节点必须放在平台配置加载之后
+            LogServerHelperHttp.SendNodeLog((int)LogNode.OnStart);
+            CheckApkVersion();
+        });
     }
 
+    private void CheckApkVersion()
+    {
+        LauncherView.Instance.SetDesc("正在校验应用版本...");
+        var versionTarget = LauncherConfig.apkVersion;
+        var version = Application.version;
+        if (VersionUtil.compare(version, versionTarget))
+        {
+            DownloadApk();
+        }
+        else
+        {
+            VersionController.Instance.Init();
+        }
+    }
+
+    private void DownloadApk()
+    {
+        Alert.Show("需要安装新的安装包,请联系研发获取。")
+                .SetLeftButton(true, "知道了", (data) => {
+
+                    Application.Quit();
+                });
+    }
 
 }

+ 17 - 27
GameClient/Assets/Game/Launcher/LauncherConfig.cs

@@ -8,6 +8,8 @@ namespace GFGGame
         public enum EnumNetType { DEV, LOCAL, TEMP }
         public static EnumNetType netType = EnumNetType.LOCAL;
         public static string cfgName;
+        public static bool ILRuntimeMode;
+
         public const int HTTP_GET_TIME_OUT = 3;
         public const int HTTP_POST_TIME_OUT = 15;
         public static string SOUND_KEY = "sound";
@@ -17,11 +19,13 @@ namespace GFGGame
         public static string CDN_ROOT;
         public static string loginApiUrl;
         public static string gameApiUrl;
+        public static string cfgUrl;
         //平台id
-        public static string cfgUrl = "http://gfg1.obs.cn-north-4.myhuaweicloud.com/14/platform/{cfgName}.json";
         public static int platformId = 1;
         public static string logKey;
         public static string logApiUrl;
+        public static string apkVersion;
+
         public static string resKey
         {
             get
@@ -34,10 +38,7 @@ namespace GFGGame
             }
         }
 
-        //public static string CDN_ROOT = "http://10.108.64.127/";
-        public static bool ILRuntimeMode;
-
-        public static void Init()
+        public static void InitScriptCompilation()
         {
 #if PT_DEV
             //外网dev版本
@@ -50,33 +51,20 @@ namespace GFGGame
             netType = EnumNetType.LOCAL;
             cfgName = "cfg_local";
 #endif
-        }
 
-        /// <summary>
-        /// 获取启动器配置
-        /// </summary>
-        public static void GetLauncherCfg()
-        {
-            var url = cfgUrl.Replace("{cfgName}", cfgName);
-            HttpTool.Instance.Get(url, (string data) =>
-            {
-                ResultHandler(data);
-            });
+            cfgUrl = "http://gfg1.obs.cn-north-4.myhuaweicloud.com/14/platform/{cfgName}.json";
         }
 
-
-        private static void ResultHandler(string data)
+        public static void InitPlatform(string json)
         {
-            var result = JsonMapper.ToObject<Result>(data);
-            CDN_ROOT = result.cdnRoot;
+            ET.Log.Debug($"ptcfg \n{json}");
+            var result = JsonMapper.ToObject<Result>(json);
+            LauncherConfig.CDN_ROOT = result.cdnRoot;
             //CDN_ROOT = "http://10.108.64.127/";
-            loginApiUrl = result.loginApiUrl;
-            logApiUrl = result.logApiUrl;
-            logKey = result.logKey;
-            ET.Log.Debug($"ptcfg \n{data}");
-            LogServerHelperHttp.SendNodeLog((int)LogNode.OnStart);
-            LauncherView.Instance.SetDesc("获取版本信息...");
-            VersionController.Instance.Init();
+            LauncherConfig.loginApiUrl = result.loginApiUrl;
+            LauncherConfig.logApiUrl = result.logApiUrl;
+            LauncherConfig.logKey = result.logKey;
+            LauncherConfig.apkVersion = result.apkVersion;
         }
 
         private struct Result
@@ -85,6 +73,8 @@ namespace GFGGame
             public string loginApiUrl;
             public string logApiUrl;
             public string logKey;
+            public string apkVersion;
         }
+
     }
 }

+ 25 - 48
GameClient/Assets/Game/Launcher/Version/VersionController.cs

@@ -2,8 +2,6 @@
 using VEngine;
 using System.Collections;
 using UnityEngine;
-using System.Reflection;
-using System;
 
 namespace GFGGame
 {
@@ -20,8 +18,8 @@ namespace GFGGame
 
         public IEnumerator InitVersion()
         {
+            LauncherView.Instance.SetDesc("正在校验资源版本...");
             EncryptHelper.resKey = LauncherConfig.resKey;
-            LogServerHelperHttp.SendNodeLog((int)LogNode.StartCheckVersion);
             Versions.DownloadURL = LauncherConfig.CDN_ROOT;
             var operation = Versions.InitializeAsync(LauncherConfig.CDN_ROOT);
             yield return operation;
@@ -32,24 +30,10 @@ namespace GFGGame
             //VEngine.Logger.I("PlayerDataPath: {0}", Versions.PlayerDataPath);
             //VEngine.Logger.I("DownloadDataPath: {0}", Versions.DownloadDataPath);
             //VEngine.Logger.I("DownloadURL: {0}", Versions.DownloadURL);
-            StartUpdateManifest();
+            StartCheckManifestVersion();
         }
 
-        private void CheckApkVersion()
-        {
-            var versionTarget = Versions.Manifest.appVersion;
-            var version = Application.version;
-            if(VersionUtil.compare(version, versionTarget))
-            {
-                DownloadApk();
-            }
-            else
-            {
-                DownloadRes();
-            }
-        }
-
-        private void StartUpdateManifest()
+        private void StartCheckManifestVersion()
         {
             StartCoroutine(CheckManifestVersion());
         }
@@ -58,6 +42,7 @@ namespace GFGGame
         {
             if (!Versions.OfflineMode)
             {
+                LogServerHelperHttp.SendNodeLog((int)LogNode.StartCheckVersion);
                 // TODO:生产环境这里的清单名字应该使用带 hash 的版本
                 updateVersions = Versions.UpdateAsync(nameof(Manifest));
                 while(!updateVersions.isDone)
@@ -66,41 +51,29 @@ namespace GFGGame
                     {
                         
                         var max = updateVersions.asset.assetVersion.size;
-                        LauncherView.Instance.SetDesc($"获取版本文件...", $"{Utility.FormatBytes(max)}");
+                        LauncherView.Instance.SetDesc($"正在校验资源版本...", $"{Utility.FormatBytes(max)}");
                         LauncherView.Instance.SetProgress((int)(updateVersions.asset.progress * 100));
                     }
                     yield return updateVersions;
                 };
                 if (updateVersions.status == OperationStatus.Failed)
                 {
-                    yield return Alert.Show("更新版本信息失败,请检测网络链接后重试。")
-                        .SetLeftButton(true, "重试", (data) => { StartUpdateManifest(); });
-                    yield break;
+                    Alert.Show("更新版本信息失败,请检测网络链接后重试。")
+                        .SetLeftButton(true, "重试", (data) => { StartCheckManifestVersion(); });
+                }
+                else
+                {
+                    yield return GetDownloadSize();
                 }
-                CheckApkVersion();
-                yield break;
             }
-            OnComplete();
-        }
-
-        private void DownloadApk()
-        {
-            Alert.Show("需要安装新的安装包,请联系研发获取。")
-                    .SetLeftButton(true, "知道了", (data) => {
-
-                        Application.Quit();
-                    });
-        }
-
-        private void DownloadRes()
-        {
-            StartCoroutine(GetDownloadSize());
+            else
+            {
+                OnComplete();
+            }
         }
 
         private IEnumerator GetDownloadSize()
         {
-            LogServerHelperHttp.SendNodeLog((int)LogNode.StartDownload);
-            Debug.Log("VersionController GetDownloadSize");
             var getDownloadSize = Versions.GetDownloadSizeAsync(updateVersions);
             var totalCount = getDownloadSize.bundles.Count;
             while(!getDownloadSize.isDone)
@@ -119,12 +92,15 @@ namespace GFGGame
                     });
                 yield break;
             }
-
-            OnComplete();
+            else
+            {
+                OnComplete();
+            }
         }
 
         private void StartDownload(GetDownloadSize getDownloadSize)
         {
+            LogServerHelperHttp.SendNodeLog((int)LogNode.StartDownload);
             StartCoroutine(Downloading(getDownloadSize));
         }
 
@@ -143,14 +119,15 @@ namespace GFGGame
             yield return downloadAsync;
             if (downloadAsync.status == OperationStatus.Failed)
             {
-                yield return Alert.Show("下载失败!请检查网络状态后重试。")
+                Alert.Show("下载失败!请检查网络状态后重试。")
                     .SetLeftButton(true, "重试", (data) => { 
                         StartDownload(getDownloadSize); 
                     });
-                yield break;
             }
-
-            OnComplete();
+            else
+            {
+                OnComplete();
+            }
         }
 
         private void OnComplete()

+ 0 - 7
GameClient/Assets/Game/Launcher/Views/LauncherView.cs

@@ -149,13 +149,6 @@ namespace GFGGame
             {
                 return;
             }
-#if (UNITY_5 || UNITY_5_3_OR_NEWER)
-            //Use the font names directly
-            UIConfig.defaultFont = "Microsoft YaHei";
-#else
-        //Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
-        // UIExcelConfig.defaultFont = "afont";
-#endif
             _ui.m_progressBar1.value = 0;
             _ui.m_txtDescLeft.text = "";
             _ui.m_txtDescRight.text = "";