From 0d10b3347e008e73681d3671cd0f76ddacfec3bb Mon Sep 17 00:00:00 2001
From: maikeljh <mjh191003@gmail.com>
Date: Wed, 8 May 2024 05:00:59 +0700
Subject: [PATCH] [Fix] Coin Reward Shop Manager

---
 Assets/Scripts/ShopKeeper/ShopManager.cs | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/Assets/Scripts/ShopKeeper/ShopManager.cs b/Assets/Scripts/ShopKeeper/ShopManager.cs
index 6749b24..c3d30e1 100644
--- a/Assets/Scripts/ShopKeeper/ShopManager.cs
+++ b/Assets/Scripts/ShopKeeper/ShopManager.cs
@@ -7,8 +7,9 @@ using Nightmare;
 
 public class ShopManager : MonoBehaviour, IDataPersistence
 {
-    public float coins = 0;
+    public float coins = 50;
     public float increment = 50;
+    public int currentReward = 1;
     public TMP_Text coinUI;
     public ShopItemSO[] shopItemsSO;
     public GameObject[] shopPanelsGO;
@@ -19,7 +20,7 @@ public class ShopManager : MonoBehaviour, IDataPersistence
     // Start is called before the first frame update
     void Start()
     {
-        coins = 0;
+        coins = 50;
         UpdateCoinsUI();
 
         for (int i = 0; i < shopItemsSO.Length; i++)
@@ -95,11 +96,16 @@ public class ShopManager : MonoBehaviour, IDataPersistence
 
     void OnEnable()
     {
-        coins += increment;
-        increment += 50;
+        if (LevelManager.Instance.currentQuest >= currentReward)
+        {
+            coins += increment;
+            increment += 50;
 
-        UpdateCoinsUI();
-        CheckPurchaseable();
+            UpdateCoinsUI();
+            CheckPurchaseable();
+
+            currentReward = LevelManager.Instance.currentQuest + 1;
+        }
     }
 
     void UpdateCoinsUI()
-- 
GitLab