From e785622cb685fcebca2902ded86613e1dbc3da66 Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Wed, 23 Dec 2020 17:16:53 +0800
Subject: [PATCH] 使用倒计时特效

---
 Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs |  107 +++++++++++++++++------------------------------------
 1 files changed, 35 insertions(+), 72 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs b/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
index f7abde0..f068add 100644
--- a/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
+++ b/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
@@ -15,7 +15,7 @@
 /// </summary>
 public class EndlessUIStart : Singleton<EndlessUIStart>
 {
-    public TextMeshProUGUI countDownTextNew = null;
+    //public TextMeshProUGUI countDownTextNew = null;
 
     public TextMeshProUGUI timeTextNew = null;
 
@@ -198,13 +198,43 @@
             GameConfig.CanDragTower = false;
             Pause();
             HideUIMask();
-            countDownTextNew.text = "";
-            countDownTextNew.gameObject.SetActive(false);
+            //countDownTextNew.text = "";
+            //countDownTextNew.gameObject.SetActive(false);
             GameObject prefab = Resources.Load<GameObject>("UI/Guide/GuidePanel");
             GameObject guideObj = Instantiate(prefab, transform.Find("Panel"));
             guideObj.GetComponent<RectTransform>().offsetMin += tmpOffect;
             AddGuideEvent();
+
         }
+        else
+        {
+            //开始倒计时
+            StartCoroutine(StartCountDown());
+        }
+    }
+    public GameObject countDownPS;
+
+    IEnumerator StartCountDown()
+    {
+        countDownPS.SetActive(true);
+        MMVibrationManager.Haptic(HapticTypes.MediumImpact);
+        yield return new WaitForSeconds(1.0f);
+        MMVibrationManager.Haptic(HapticTypes.MediumImpact);
+        yield return new WaitForSeconds(1.0f);
+        MMVibrationManager.Haptic(HapticTypes.MediumImpact);
+        yield return new WaitForSeconds(1.0f);
+        HideUIMask();
+        //countDownTextNew.text = "";
+        countDownPS.SetActive(false);
+        bGameStart = true;
+        // 开始关卡
+        EndlessLevelManager.instance.StartLevel();
+        timeTextNew.gameObject.SetActive(true);
+
+        JsonDataReadDone();
+        // 开始播放背景音乐.
+        if (bgMusic != null)
+            bgMusic.Play();
     }
 
     public void GameOver()
@@ -679,75 +709,7 @@
             timeTextNew.text = ConvertTime((float)Math.Ceiling(startTime));
         }
 
-        if (!GameConfig.IsNewbie)
-        {
-            if (!bFirstLoaded && !bGameStart)
-            {
-                bFirstLoaded = true;
-                secToDo = 4;
-            }
-
-            if (bFirstLoaded && !bGameStart)
-            {
-                secToDo -= Time.deltaTime;
-                countDownTextNew.gameObject.SetActive(true);
-
-                if (secToDo >= 3)
-                {
-                    countDownTextNew.text = "3";
-                    if (!bVibrate[3])
-                    {
-                        bVibrate[3] = true;
-                        MMVibrationManager.Haptic(HapticTypes.SoftImpact);
-                    }
-                }
-                else if (secToDo >= 2)
-                {
-                    countDownTextNew.text = "2";
-                    if (!bVibrate[2])
-                    {
-                        bVibrate[2] = true;
-                        MMVibrationManager.Haptic(HapticTypes.MediumImpact);
-                    }
-                }
-                else if (secToDo >= 1)
-                {
-                    countDownTextNew.text = "1";
-                    if (!bVibrate[1])
-                    {
-                        bVibrate[1] = true;
-                        MMVibrationManager.Haptic(HapticTypes.HeavyImpact);
-                    }
-                }
-                else if (secToDo < 1)
-                {
-                    countDownTextNew.text = "GO!";
-                    if (!bVibrate[0])
-                    {
-                        bVibrate[0] = true;
-                        MMVibrationManager.Haptic(HapticTypes.HeavyImpact);
-                    }
-                }
-
-                // 开启游戏,且隐藏中间的数字.
-                if (secToDo <= 0)
-                {
-                    HideUIMask();
-                    countDownTextNew.text = "";
-                    countDownTextNew.gameObject.SetActive(false);
-                    bGameStart = true;
-                    // 开始关卡
-                    EndlessLevelManager.instance.StartLevel();
-                    timeTextNew.gameObject.SetActive(true);
-
-                    JsonDataReadDone();
-                    // 开始播放背景音乐.
-                    if (bgMusic != null)
-                        bgMusic.Play();
-                }
-            }
-        }
-        else
+        if (GameConfig.IsNewbie)
         {
             // 新手走的流程
             if (!bFirstLoaded && !bGameStart)
@@ -765,5 +727,6 @@
                     bgMusic.Play();
             }
         }
+
     }
 }

--
Gitblit v1.9.1