guodong 1 жил өмнө
parent
commit
ee124cae33

+ 35 - 0
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -2,6 +2,9 @@ using UnityEngine;
 using ET;
 using static GFGGame.LauncherConfig;
 using System;
+using YooAsset;
+using System.Collections;
+using FairyGUI;
 
 namespace GFGGame
 {
@@ -375,5 +378,37 @@ namespace GFGGame
                         }
                     });
         }
+
+        public static void CheckUpdateVersion()
+        {
+            if (ET.TimeHelper.ClientNowSeconds() - GameGlobal.pauseTime > 180 || LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
+            {
+                Timers.inst.StartCoroutine(CheckVersion(VersionController.DefaultPackage));
+            }
+        }
+
+        private static IEnumerator CheckVersion(string packageName)
+        {
+            var package = YooAssets.GetPackage(packageName);
+            string oldVersion = package.GetPackageVersion();
+            var operation = package.UpdatePackageVersionAsync();
+            yield return operation;
+
+            if (operation.Status == EOperationStatus.Succeed)
+            {
+                VersionController.Instance.PackageVersion = operation.PackageVersion;
+                LogUtil.LogDev($"版本对比: {oldVersion} {operation.PackageVersion}");
+                if (!operation.PackageVersion.Equals(oldVersion))
+                {
+                    AlertSystem.Show("游戏已有更新,您可以立即重启游戏获取最佳游戏体验,也可以稍后重启更新。")
+                        .SetLeftButton(true, "稍后更新")
+                        .SetRightButton(true, "重启游戏", (obj) =>
+                        {
+                            Application.Quit();
+                        });
+                }
+            }
+        }
+
     }
 }

+ 3 - 2
GameClient/Assets/Game/HotUpdate/Controller/LoginController.cs

@@ -261,7 +261,7 @@ namespace GFGGame
             LoadingView.Instance.SetDesc("正在加载数据...");
             LogServerHelper.SendNodeLog((int)LogNode.StartEnterGame);
             await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<ET.WaitType.Wait_SceneChangeFinish>();
-            AlertSystem.hide();
+            AlertSystem.Hide();
             await GameController.PreEnterGameAsync();
             LogServerHelper.SendNodeLog((int)LogNode.OnEnterGame);
         }
@@ -299,8 +299,9 @@ namespace GFGGame
             await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<ET.WaitType.Wait_SceneChangeFinish>();
             EventAgent.DispatchEvent(ConstMessage.NUMERIC_CHANGE, NumericType.All);
             GameController.OnReconnected();
-            AlertSystem.hide();
+            AlertSystem.Hide();
             ViewManager.Hide<ModalStatusView>();
+            GameController.CheckUpdateVersion();
         }
     }
 }

+ 12 - 0
GameClient/Assets/Game/HotUpdate/GameConfig.cs

@@ -24,6 +24,11 @@ namespace GFGGame
         //兑换码
         public static int hCode;
 
+        //0 正常,1 维护中
+        public static int serverStatus;
+        public static string statusPrompt;
+
+
         public static void InitData(string json)
         {
             ET.Log.Debug($"gamecfg \n{json}");
@@ -48,6 +53,11 @@ namespace GFGGame
             {
                 hCode = int.Parse(result.hCode);
             }
+            if (!string.IsNullOrEmpty(result.serverStatus))
+            {
+                serverStatus = int.Parse(result.serverStatus);
+            }
+            statusPrompt = result.statusPrompt;
             GameConfig.logApiReportUrl = LauncherConfig.logApiRootUrl + "ReportGet";
         }
 
@@ -59,6 +69,8 @@ namespace GFGGame
             public string tsStatus;
             public string tsServer;
             public string hCode;
+            public string serverStatus;
+            public string statusPrompt;
         }
     }
 }

+ 3 - 0
GameClient/Assets/Game/HotUpdate/GameGlobal.cs

@@ -49,6 +49,9 @@ namespace GFGGame
         //最大显示充值物品的订单时间差
         public static int maxShowOrderTime = GameConst.DEFAULT_MAX_ORDER_TIME;
 
+        //游戏暂停时间
+        public static long pauseTime;
+
         public static void Init()
         {
             cfgName = LauncherConfig.cfgName + "_in";

+ 1 - 32
GameClient/Assets/Game/HotUpdate/HotUpdateDriver.cs

@@ -51,43 +51,12 @@ namespace GFGGame
             }
         }
 
-        private long pauseTime;
 
         private void OnApplicationPause(bool pause)
         {
             if(pause)
             {
-                pauseTime = ET.TimeHelper.ClientNowSeconds();
-            }
-            else
-            {
-                if(ET.TimeHelper.ClientNowSeconds() - pauseTime > 180 || LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
-                {
-                    StartCoroutine(CheckVersion(VersionController.DefaultPackage));
-                }
-            }
-        }
-
-        private IEnumerator CheckVersion(string packageName)
-        {
-            var package = YooAssets.GetPackage(packageName);
-            string oldVersion = package.GetPackageVersion();
-            var operation = package.UpdatePackageVersionAsync();
-            yield return operation;
-
-            if (operation.Status == EOperationStatus.Succeed)
-            {
-                VersionController.Instance.PackageVersion = operation.PackageVersion;
-                LogUtil.LogDev($"版本对比: {oldVersion} {operation.PackageVersion}");
-                if(!operation.PackageVersion.Equals(oldVersion))
-                {
-                    Alert.Show("游戏已有更新,您可以立即重启游戏获取最佳游戏体验,也可以稍后重启更新。")
-                        .SetLeftButton(true, "稍后更新")
-                        .SetRightButton(true, "重启游戏", (obj)=> 
-                        {
-                            Application.Quit();
-                        });
-                }
+                GameGlobal.pauseTime = ET.TimeHelper.ClientNowSeconds();
             }
         }
 

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Common/Alert/AlertSystem.cs

@@ -33,7 +33,7 @@ namespace GFGGame
             return _alertWindow;
         }
 
-        public static void hide()
+        public static void Hide()
         {
             if (_alertWindow != null)
             {

+ 30 - 22
GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs

@@ -195,33 +195,41 @@ namespace GFGGame
 
         private void TryLogin()
         {
-            if (LauncherConfig.serverStatus == 1)
+            var url = LauncherConfig.cfgUrl.Replace("{cfgName}", GameGlobal.cfgName);
+            url = url + "?t=" + TimeHelper.ClientNow();
+            HttpTool.Instance.Get(url, (string data) =>
             {
-                if (string.IsNullOrEmpty(LauncherConfig.statusPrompt))
+                //重新加载游戏配置
+                GameConfig.InitData(data);
+                if (GameConfig.serverStatus == 1)
                 {
-                    LauncherConfig.statusPrompt = "游戏正在维护中,请稍后再试。";
-                }
-                Alert.Show(LauncherConfig.statusPrompt)
-                    .SetLeftButton(true, "知道了", (data) =>
+                    if (string.IsNullOrEmpty(GameConfig.statusPrompt))
                     {
-                        Application.Quit();
-                    });
-                return;
-            }
-            var serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
-            if (serverInfosComponent.ServerInfoList.Count <= 0)
-            {
-                QDManager.Login();
-            }
-            else
-            {
-                if (!_ui.m_btnAgree.selected)
-                {
-                    PromptController.Instance.ShowFloatTextPrompt("请仔细阅读并同意游戏用户协议、隐私保护指引、儿童隐私政策");
+                        GameConfig.statusPrompt = "游戏正在更新维护中,请稍后再试。";
+                    }
+                    AlertSystem.Show(GameConfig.statusPrompt)
+                        .SetLeftButton(true, "知道了", (data) =>
+                        {
+                            Application.Quit();
+                        });
                     return;
                 }
-                LoginController.GetRoles().Coroutine();
-            }
+
+                var serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
+                if (serverInfosComponent.ServerInfoList.Count <= 0)
+                {
+                    QDManager.Login();
+                }
+                else
+                {
+                    if (!_ui.m_btnAgree.selected)
+                    {
+                        PromptController.Instance.ShowFloatTextPrompt("请仔细阅读并同意游戏用户协议、隐私保护指引、儿童隐私政策");
+                        return;
+                    }
+                    LoginController.GetRoles().Coroutine();
+                }
+            });
         }
 
         private void ResetLoginButton()

+ 1 - 1
GameClient/Assets/Game/Launcher/LauncherConfig.cs

@@ -30,13 +30,13 @@ namespace GFGGame
         public static string apkVersion;
         //0 正常,1 维护中
         public static int serverStatus;
+        public static string statusPrompt;
         //0 关闭所有log界面,1 开启后台log界面, 2 开启弹窗log界面
         public static int onDebug;
         //AB资源版本
         public static string manifest_v;
         //隐私政策文件地址模版
         public static string privacy_v;
-        public static string statusPrompt;
         public static string updateAppPrompt;
         public static string updateResPrompt;
         public static int promptSizeMB;