Browse Source

加载界面

guodong 3 years ago
parent
commit
cc1341f134

+ 19 - 16
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -173,28 +173,31 @@ namespace GFGGame
 
         private static void EnterGame()
         {
-            ViewManager.Hide<LoadingView>();
-            // LoadingView.Instance.Close();
-
-            GameGlobal.isEnterGame = true;
-            if (MainStoryDataManager.CheckOpenMainUI() || GameGlobal.skipGuide)
-            {
-                ViewManager.Show(ViewName.MAINUI_VIEW);
-            }
-            else
+            LoadingView.Instance.SetProgress(100, () =>
             {
-                MainStoryDataManager.currentChapterCfgId = 10001;
-                if (GameGlobal.isFirstEntry == true)
+                ViewManager.Hide<LoadingView>();
+                // LoadingView.Instance.Close();
+
+                GameGlobal.isEnterGame = true;
+                if (MainStoryDataManager.CheckOpenMainUI() || GameGlobal.skipGuide)
                 {
-                    GameGlobal.isFirstEntry = false;
-                    StoryController.ShowPriorStoryDialog();
+                    ViewManager.Show(ViewName.MAINUI_VIEW);
                 }
                 else
                 {
-                    ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, MainStoryDataManager.currentChapterCfgId, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW });
+                    MainStoryDataManager.currentChapterCfgId = 10001;
+                    if (GameGlobal.isFirstEntry == true)
+                    {
+                        GameGlobal.isFirstEntry = false;
+                        StoryController.ShowPriorStoryDialog();
+                    }
+                    else
+                    {
+                        ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, MainStoryDataManager.currentChapterCfgId, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW });
+                    }
                 }
-            }
-            Timers.inst.Add(1f, 1, AfterEnterGame);
+                Timers.inst.Add(1f, 1, AfterEnterGame);
+            });
         }
 
         private static async void AfterEnterGame(object param)

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

@@ -216,8 +216,8 @@ namespace GFGGame
             ViewManager.Hide<LoginView>();
             ViewManager.Show<LoadingView>();
             // LoadingView.Instance.Open();
-            LoadingView.Instance.SetProgress(100);
-            // LoadingView.Instance.SetDesc("游戏加载中");
+            LoadingView.Instance.SetProgress(99);
+             LoadingView.Instance.SetDesc("正在进入游戏");
             LogServerHelperHttp.SendNodeLog((int)LogNode.StartEnterGame);
             int errorCode = await LoginHelper.GetRealmKey(GameGlobal.zoneScene);
             if (errorCode != ErrorCode.ERR_Success)

+ 25 - 4
GameClient/Assets/Game/HotUpdate/Views/Loading/LoadingView.cs

@@ -1,5 +1,6 @@
 using FairyGUI;
 using UI.Loading;
+using Unity.Plastic.Antlr3.Runtime;
 using UnityEngine;
 
 namespace GFGGame
@@ -51,7 +52,6 @@ namespace GFGGame
         {
             base.OnShown();//1;//
             SetProgress(0);
-            _ui.m_txtDescLeft.text = "正在进入游戏";
             int index = Random.Range(0, resNames.Length);
             _ui.m_loaBg.url = string.Format("ui://Loading/{0}", resNames[index]);
         }
@@ -62,6 +62,22 @@ namespace GFGGame
         }
 
         /// <summary>
+        /// 设置描述文字
+        /// </summary>
+        /// <param name="desc"></param>
+        public void SetDesc(string desc, string descRight = "")
+        {
+            if (!ViewManager.isViewOpen(typeof(LoadingView).Name))
+            {
+                return;
+            }
+            string str = string.Format("{0}  {1}", desc, descRight);//  + descRight;
+            _ui.m_txtDescLeft.text = str;
+            // _ui.m_txtDescLeft.text = desc ?? "";
+            // _ui.m_txtDescRight.text = descRight ?? "";
+        }
+
+        /// <summary>
         /// 设置进度0-100
         /// </summary>
         /// <param name="progress"></param>
@@ -72,12 +88,17 @@ namespace GFGGame
             {
                 return;
             }
+            double oldValule;
             GTweener twener = GTween.GetTween(_ui.m_progressBar1, TweenPropType.Progress);
             if (twener != null)
             {
-                twener.Kill(true);
+                oldValule = twener.value.d;
+            }
+            else
+            {
+                oldValule = _ui.m_progressBar1.value;
             }
-            if (progress < _ui.m_progressBar1.value)
+            if (progress < oldValule)
             {
                 _ui.m_progressBar1.value = progress;
                 _ui.m_imgAni.x = _ui.m_progressBar1.width * (progress / 100) - 120;
@@ -85,8 +106,8 @@ namespace GFGGame
             }
             else
             {
-                float duration = (float)(progress - _ui.m_progressBar1.value) * SPEED;
 
+                float duration = (float)(progress - oldValule) * SPEED;
                 GTweener gtweener = _ui.m_progressBar1.TweenValue(progress, duration).OnUpdate((GTweener t) =>
                 {
                     _ui.m_imgAni.x = _ui.m_progressBar1.width * (t.value.x / 100) - 120;

+ 8 - 3
GameClient/Assets/Game/Launcher/Views/LauncherView.cs

@@ -113,12 +113,17 @@ namespace GFGGame
             {
                 return;
             }
+            double oldValule;
             GTweener twener = GTween.GetTween(_ui.m_progressBar1, TweenPropType.Progress);
             if (twener != null)
             {
-                twener.Kill(true);
+                oldValule = twener.value.d;
             }
-            if (progress < _ui.m_progressBar1.value)
+            else
+            {
+                oldValule = _ui.m_progressBar1.value;
+            }
+            if (progress < oldValule)
             {
                 _ui.m_progressBar1.value = progress;
                 _ui.m_imgAni.x = _ui.m_progressBar1.width * (progress / 100) - 120;
@@ -126,8 +131,8 @@ namespace GFGGame
             }
             else
             {
-                float duration = (float)(progress - _ui.m_progressBar1.value) * SPEED;
 
+                float duration = (float)(progress - oldValule) * SPEED;
                 GTweener gtweener = _ui.m_progressBar1.TweenValue(progress, duration).OnUpdate((GTweener t) =>
                 {
                     _ui.m_imgAni.x = _ui.m_progressBar1.width * (t.value.x / 100) - 120;