zhaoyang 3 éve
szülő
commit
1745b33d31

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

@@ -3,6 +3,7 @@ using GFGGame;
 using ET;
 using System.Threading;
 using GFGGame.Launcher;
+using FairyGUI;
 
 public class GameLauncher : MonoBehaviour
 {
@@ -36,8 +37,14 @@ public class GameLauncher : MonoBehaviour
         Application.runInBackground = true;
         LauncherConfig.InitScriptCompilation();
         FGUILauncher.Init();
-        LauncherView.Instance.Open();
-        InitLauncherCfg();
+        HealthAdviceView.Instance.Open();
+        int time = LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL ? 3 : 10;
+        Timers.inst.Add(time, 1, (object param) =>
+        {
+            HealthAdviceView.Instance.Close();
+            LauncherView.Instance.Open();
+            InitLauncherCfg();
+        });
     }
 
     /// <summary>
@@ -47,7 +54,7 @@ public class GameLauncher : MonoBehaviour
     {
         LauncherView.Instance.SetDesc("正在初始化..");
         var url = LauncherConfig.cfgUrl.Replace("{cfgName}", LauncherConfig.cfgName);
-        url = url + "?t=" +  TimeHelper.ClientNow();
+        url = url + "?t=" + TimeHelper.ClientNow();
         HttpTool.Instance.Get(url, (string json) =>
         {
             LauncherConfig.InitPlatform(json);
@@ -60,10 +67,11 @@ public class GameLauncher : MonoBehaviour
 
     public void CheckGameStatus()
     {
-        if(LauncherConfig.serverStatus == 1)
+        if (LauncherConfig.serverStatus == 1)
         {
             Alert.Show("游戏正在维护中,请稍后再试。")
-                .SetLeftButton(true, "知道了", (data) => {
+                .SetLeftButton(true, "知道了", (data) =>
+                {
 
                     Application.Quit();
                 });
@@ -92,7 +100,8 @@ public class GameLauncher : MonoBehaviour
     private void DownloadApk()
     {
         Alert.Show("需要安装新的安装包,请联系研发获取。")
-                .SetLeftButton(true, "知道了", (data) => {
+                .SetLeftButton(true, "知道了", (data) =>
+                {
 
                     Application.Quit();
                 });

+ 92 - 0
GameClient/Assets/Game/Launcher/Views/HealthAdviceView.cs

@@ -0,0 +1,92 @@
+using FairyGUI;
+using UI.Launcher;
+using UnityEngine;
+
+namespace GFGGame
+{
+    public class HealthAdviceView
+    {
+        private static HealthAdviceView m_Instance = null;
+        /// <summary>
+        /// 单例
+        /// </summary>
+        public static HealthAdviceView Instance
+        {
+            get
+            {
+                if (m_Instance == null)
+                {
+                    m_Instance = new HealthAdviceView();
+                }
+                return m_Instance;
+            }
+        }
+
+        private UI_HealthAdviceUI _ui;
+
+        /// <summary>
+        /// 每1%耗时,单位秒
+        /// </summary>
+        private const float SPEED = 0.01f;
+        /// <summary>
+        /// 界面是否打开状态
+        /// </summary>
+        private bool isOpen = false;
+        /// <summary>
+        /// FairyGUI包名
+        /// </summary>
+        private string _packageName;
+
+        #region private
+        private void Dispose()
+        {
+            UIPackage.RemovePackage("UI/" + _packageName);
+            _ui.Dispose(true);
+            _ui = null;
+        }
+        #endregion
+
+        public HealthAdviceView()
+        {
+            _packageName = UI_HealthAdviceUI.PACKAGE_NAME;
+            UIPackage.AddPackage("UI/" + _packageName + "/" + _packageName);
+            _ui = UI_HealthAdviceUI.Create();
+            _ui.target.MakeFullScreen();
+            _ui.target.AddRelation(GRoot.inst, RelationType.Size);
+
+        }
+
+        /// <summary>
+        /// 打开界面
+        /// </summary>
+        public void Open()
+        {
+            if (isOpen)
+            {
+                return;
+            }
+
+            GRoot.inst.AddChild(_ui.target);
+            isOpen = true;
+
+        }
+
+        /// <summary>
+        /// 关闭界面
+        /// </summary>
+        /// <param name="toDestroy"></param>
+        public void Close(bool toDestroy = false)
+        {
+            if (!isOpen)
+            {
+                return;
+            }
+            isOpen = false;
+            _ui.target.RemoveFromParent();
+            if (toDestroy)
+            {
+                Dispose();
+            }
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/Launcher/Views/HealthAdviceView.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 217b1a047bfade34289c7efe2de48c6b
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: