Przeglądaj źródła

商店当前商品购买完成后,要把刷新价格变为0

1243896040 2 tygodni temu
rodzic
commit
3e074ec27a

+ 23 - 4
ActionTowerDefense/Assets/Scripts/UI/ShopUI.cs

@@ -137,15 +137,34 @@ public class ShopUI : MonoBehaviour
 
     public void Refresh()
     {
-        if(GameManager.instance.money - refreshPrice < 0)
+        if(refreshPrice != 0)
         {
-            return;
+            if (GameManager.instance.money - refreshPrice < 0)
+            {
+                return;
+            }
+            GameManager.instance.money -= refreshPrice;
+            refreshNum += 1;
         }
-        GameManager.instance.money -= refreshPrice;
-        refreshNum += 1;
         Init();
     }
 
+    public void FreeRefresh()
+    {
+        for(int i = 0; i < 5; i++)
+        {
+            if (treasuresSaleUI[i].gameObject.activeSelf)
+            {
+                return;
+            }
+            if(i == 4)
+            {
+                refreshPrice = 0;
+                refreshPriceText.text = $"-{refreshPrice}";
+            }
+        }
+    }
+
     public void DrawUIPolygon()
     {
         GameManager gameManager = GameManager.instance;

+ 1 - 0
ActionTowerDefense/Assets/Scripts/UI/TreasuresSaleUI.cs

@@ -204,6 +204,7 @@ public class TreasuresSaleUI : MonoBehaviour
         shopUI.DrawUIPolygon();
         shopUI.AddTreasureInBag();
         gameObject.SetActive(false);
+        shopUI.FreeRefresh();
         buy.ChangeImg(imageID);
         isNull = true;
         islock = false;