ManajemenInformatika_E31230007/Assets/Scripts/StoryManager/GameProgress.cs

63 lines
1.4 KiB
C#

using UnityEngine;
public static class GameProgress
{
// ================= POINT =================
public static int GetTotalPoints()
{
return PlayerPrefs.GetInt("TOTAL_POINTS", 0);
}
public static void AddPoints(int points)
{
int total = GetTotalPoints();
total += points;
PlayerPrefs.SetInt("TOTAL_POINTS", total);
PlayerPrefs.Save();
Debug.Log("TOTAL POINTS SEKARANG: " + total);
}
// ================= CHAPTER =================
public static void UnlockChapter(int chapter)
{
PlayerPrefs.SetInt("CHAPTER_" + chapter, 1);
PlayerPrefs.Save();
}
public static bool IsChapterUnlocked(int chapter)
{
return PlayerPrefs.GetInt("CHAPTER_" + chapter, 0) == 1;
}
// ================= RESET =================
public static void Reset()
{
PlayerPrefs.DeleteAll();
PlayerPrefs.Save();
PlayerPrefs.SetInt("CHAPTER_1", 1);
PlayerPrefs.SetInt("CHAPTER_2", 0);
PlayerPrefs.SetInt("CHAPTER_3", 0);
PlayerPrefs.SetInt("CHAPTER_4", 0);
PlayerPrefs.SetInt("CHAPTER_5", 0); // ✅ TAMBAHAN
PlayerPrefs.SetInt("TOTAL_POINTS", 0);
PlayerPrefs.Save();
Debug.Log("RESET DATA SELESAI");
}
public static int GetChapterRaw(int chapter)
{
return PlayerPrefs.GetInt("CHAPTER_" + chapter, 0);
}
public static void SetPoints(int points)
{
PlayerPrefs.SetInt("TOTAL_POINTS", points);
PlayerPrefs.Save();
Debug.Log("SET TOTAL POINTS: " + points);
}
}