From d41d484f64f14e7ffcaf5f1de3963aa91e70a917 Mon Sep 17 00:00:00 2001
From: Fikri-IF <ihsanfikri00@gmail.com>
Date: Sun, 16 Apr 2023 15:53:29 +0700
Subject: [PATCH] shopkeeper saved load

---
 Assets/Scripts/Managers/ShopkeeperManager.cs | 13 +++++++++++--
 Assets/Scripts/Quest/QuestDetail.cs          | 12 ++++++------
 Assets/Scripts/Save/GameData.cs              |  4 ++++
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Assets/Scripts/Managers/ShopkeeperManager.cs b/Assets/Scripts/Managers/ShopkeeperManager.cs
index 570d9dcb..401b3bf2 100644
--- a/Assets/Scripts/Managers/ShopkeeperManager.cs
+++ b/Assets/Scripts/Managers/ShopkeeperManager.cs
@@ -2,7 +2,7 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
-public class ShopkeeperManager : MonoBehaviour
+public class ShopkeeperManager : MonoBehaviour, IDataPersistence
 {
     Animator anim;
     int w1=0;
@@ -111,5 +111,14 @@ public class ShopkeeperManager : MonoBehaviour
     	mapping[p].text = "" + inventory[p];
     	Debug.Log("DECREASEPET "+inventory[p]);
     }
-    
+    
+    public void LoadData(GameData data)
+    {
+        this.inventory = data.inventory;
+    }
+
+    public void SaveData(ref GameData data)
+    {
+        data.inventory = this.inventory;
+    }
 }
diff --git a/Assets/Scripts/Quest/QuestDetail.cs b/Assets/Scripts/Quest/QuestDetail.cs
index 5fb8a8e2..66f98b82 100644
--- a/Assets/Scripts/Quest/QuestDetail.cs
+++ b/Assets/Scripts/Quest/QuestDetail.cs
@@ -145,9 +145,9 @@ public class QuestDetail : MonoBehaviour, IDataPersistence
         if (onQuest == false && questLevel == 6)
         {
             QuestDescription.message = "\nYou Got a new Quest\n\nkill 4 hellephant";
-            hellephantKillNeeded = 4;
-            zombearKillNeeded = 0;
-            zombunnyKillNeeded = 0;
+            hellephantKillNeeded = 0;
+            zombearKillNeeded = 7;
+            zombunnyKillNeeded = 7;
 
             Time.timeScale = 0;
             OpenPanel();
@@ -161,9 +161,9 @@ public class QuestDetail : MonoBehaviour, IDataPersistence
         if (onQuest == false && questLevel == 8)
         {
             QuestDescription.message = "\nYou Got a new Quest\n\nkill 4 zombear\nkill 4 zombunny\nkill 4 hellephant";
-            zombearKillNeeded = 4;
-            zombunnyKillNeeded = 4;
-            hellephantKillNeeded = 4;
+            zombearKillNeeded = 0;
+            zombunnyKillNeeded = 0;
+            hellephantKillNeeded = 15;
 
             Time.timeScale = 0;
             OpenPanel();
diff --git a/Assets/Scripts/Save/GameData.cs b/Assets/Scripts/Save/GameData.cs
index 683e63a4..1c1f1b15 100644
--- a/Assets/Scripts/Save/GameData.cs
+++ b/Assets/Scripts/Save/GameData.cs
@@ -20,6 +20,10 @@ public class GameData
     public List<bool> weaponBought = new List<bool>();
     // --------------
 
+    // Shop Manager
+    public Dictionary<string, int> inventory = new Dictionary<string, int>(){{"w1",0},{"w2",0},{"w3",0},{"p1",0},{"p2",0},{"p3",0}};
+    // -------------
+
 
     // the values defined in this constructor will be the default values
     // the game starts with when theres no data to load
-- 
GitLab