From c90cdd78c2bf8bcfa25cec7432a5876f6085ecfb Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期五, 01 二月 2019 11:18:37 +0800
Subject: [PATCH] 3335 切换地图逻辑重构。

---
 System/Loading/LoadingWin.cs |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/System/Loading/LoadingWin.cs b/System/Loading/LoadingWin.cs
index edb0cac..5e6679d 100644
--- a/System/Loading/LoadingWin.cs
+++ b/System/Loading/LoadingWin.cs
@@ -41,6 +41,8 @@
         float refProgress = 0f;
         float expectDuration = 5f;
 
+        float overTimer = 0f;
+
         LoadingType loadingType = LoadingType.Normal;
 
         #region Built-in
@@ -54,6 +56,8 @@
 
         protected override void OnPreOpen()
         {
+            overTimer = 0f;
+            refProgress = 0f;
             var useDefautBackGround = false;
             if (!AssetSource.uiFromEditor)
             {
@@ -195,8 +199,7 @@
                 else
                 {
                     m_ContainerProgress.gameObject.SetActive(true);
-                    m_ProgressSlider.value = refProgress = 0f;
-                    StageManager.Instance.loadingProgressEvent += UpdateLoadingProgress;
+                    m_ProgressSlider.ResetValue(0f);
                 }
             }
 
@@ -208,8 +211,6 @@
 
         protected override void OnPreClose()
         {
-            StageManager.Instance.loadingProgressEvent -= UpdateLoadingProgress;
-
             if (!AssetSource.uiFromEditor)
             {
                 AssetBundleUtility.Instance.UnloadAssetBundle("ui/sprite/loading", true, false);
@@ -222,21 +223,31 @@
         }
         #endregion
 
-
         protected override void LateUpdate()
         {
             base.LateUpdate();
-
             if (loadingType == LoadingType.Normal)
             {
-                refProgress = Mathf.Clamp01(refProgress + Time.deltaTime / expectDuration);
+                if (StageLoad.Instance.progress + 0.1f > refProgress)
+                {
+                    refProgress = Mathf.Clamp01(StageLoad.Instance.progress + 0.1f);
+                }
+
                 m_ProgressSlider.value = refProgress;
             }
-        }
 
-        void UpdateLoadingProgress(float _progress)
-        {
-            m_ProgressSlider.value = refProgress = Mathf.Max(_progress, refProgress);
+            overTimer += Time.deltaTime;
+            if (overTimer > 15f)
+            {
+                overTimer -= 5f;
+
+                var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
+                if (!loginModel.busy && !CrossServerLogin.Instance.busy && !StageLoad.Instance.isLoading)
+                {
+                    WindowCenter.Instance.Close<LoadingWin>();
+                }
+            }
+
         }
 
         private List<int> GetShowFunctions(int _level)

--
Gitblit v1.8.0