From 6d3bfdaad36f4af65494854e5651f7d37ad81d6b Mon Sep 17 00:00:00 2001
From: liuzhiwei <liuzhiwei@qq.com>
Date: Sat, 12 Dec 2020 18:56:34 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/TowerDefense/UI/HUD/EndlessRandomTower.cs |   72 ++++++++++++++++++++++++++++--------
 1 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/HUD/EndlessRandomTower.cs b/Assets/Scripts/TowerDefense/UI/HUD/EndlessRandomTower.cs
index 82ccfd2..0a58b70 100644
--- a/Assets/Scripts/TowerDefense/UI/HUD/EndlessRandomTower.cs
+++ b/Assets/Scripts/TowerDefense/UI/HUD/EndlessRandomTower.cs
@@ -9,6 +9,7 @@
 using TMPro;
 using KTGMGemClient;
 using DG.Tweening;
+using System.Collections;
 
 public class EndlessRandomTower : Singleton<EndlessRandomTower>
 {
@@ -57,9 +58,32 @@
 
     public ParticleSystem btnPS;
 
+    IEnumerator ReadJson()
+    {
+        while (!GameConfig.JsonReadDone)
+        {
+            yield return 10;
+        }
+
+        countDownLimit = JsonDataCenter.GetById<battle>(23).value;
+        Debug.Log("设置了倒计时:" + countDownLimit);
+        yield break;
+    }
+
     // Start is called before the first frame update
     void Start()
     {
+#if UNITY_ANDROID
+
+#endif
+#if UNITY_IPHONE
+
+#endif
+#if UNITY_EDITOR
+
+#endif
+        StartCoroutine(ReadJson());
+
         if (!EndlessLevelManager.instanceExists)
             Debug.LogError("[UI] No level manager for tower list");
 
@@ -86,12 +110,9 @@
 
     public void UpdateDescDisplay()
     {
-        int minLevel = 0;
+        int minLevel = GameConfig.IsUpgradeTowerLevel ? 1 : 0;
 
-        if (EndlessUIStart.instance.GameStartTime >= JsonDataCenter.DOUBLE_GEM_TIME)
-            minLevel = Mathf.Min(EndlessGameUI.instance.MinLevel, 1);
-
-        NormalDesc.text = $"购买{minLevel + 1}级宝石";
+        NormalDesc.text = $"购买{minLevel + 1}级精灵";
     }
 
     public void ChangeBtnClickNormal()
@@ -261,7 +282,21 @@
     public void SetCountDown(bool isOn, bool isReset = false)
     {
         isCountStartDown = isOn;
-        if (isReset) countDownTime = 0;
+        if (isReset)
+        {
+            countDownTime = 0;
+            if (needClickPS.isPlaying)
+                needClickPS.Stop();
+        }
+    }
+
+    public void SetPS(bool isOn)
+    {
+        if (needClickPS.gameObject.activeSelf != isOn)
+        {
+            needClickPS.gameObject.SetActive(isOn);
+        }
+
     }
     float countDownTime = 0f;
     float countDownLimit = 5f;
@@ -274,7 +309,6 @@
         if (isCountStartDown)
         {
             countDownTime += Time.deltaTime;
-            Debug.Log("倒计时中");
             if (countDownTime > countDownLimit)
             {
 
@@ -299,12 +333,24 @@
 
         if (current >= result && num < 10)//自己的钱多
         {
+            //Debug.Log($"当前金币 :{current}  下一次购买需要金币:{result}  塔的数量:{num}");
             isCountStartDown = false;
             needClickPS.Play();
         }
     }
 
-
+    public void CheckMoney()
+    {
+        int result;
+        int.TryParse(cashText.text.ToString(), out result);
+        int current = EndlessLevelManager.instance.Currency.currentCurrency;
+        if (current < result && needClickPS.isPlaying)//自己的钱多
+        {
+            needClickPS.Stop();
+            isCountStartDown = true;
+            countDownTime = 0;
+        }
+    }
 
     private void CheckCurrencyEnough()
     {
@@ -331,15 +377,9 @@
         if (gameUI.isBuilding)
             gameUI.CancelGhostPlacement();
 
-        if (EndlessUIStart.instance.GameStartTime >= JsonDataCenter.DOUBLE_GEM_TIME)
+        if (level == -1)
         {
-            if (level == -1)
-                level = Mathf.Min(EndlessGameUI.instance.MinLevel, 1);
-        }
-        else
-        {
-            if (level == -1)
-                level = 0;
+            level = GameConfig.IsUpgradeTowerLevel ? 1 : 0;
         }
 
         return gameUI.RandomPlaceTower(tower, posx, posy, level, cost, false, isFirstAppear);

--
Gitblit v1.9.1