86 lines
1.8 KiB
C#
86 lines
1.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class ManagerGame : MonoBehaviour
|
|
{
|
|
public static ManagerGame instance;
|
|
|
|
public int selectedChapter = 1;
|
|
|
|
public bool isNewGame = false;
|
|
public bool isContinue = false; // 🔥 TAMBAHAN
|
|
|
|
public bool isDirectChapter = false; // 🔥 ini penting
|
|
|
|
void Awake()
|
|
{
|
|
if (instance != null && instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
// ================= MAIN MENU =================
|
|
|
|
public void NewGame()
|
|
{
|
|
// 🔥 RESET TOTAL PROGRESS
|
|
VN_SaveSystem.DeleteAllSave();
|
|
|
|
PlayerPrefs.DeleteKey("TOTAL_POINTS");
|
|
PlayerPrefs.DeleteKey("GLOBAL_POINTS_BAB2");
|
|
PlayerPrefs.Save();
|
|
|
|
isNewGame = true;
|
|
isContinue = false; // 🔥 reset flag
|
|
|
|
Debug.Log("NEW GAME: TOTAL POINTS DIRESET");
|
|
|
|
SceneManager.LoadScene("StorySelect");
|
|
}
|
|
|
|
public void ContinueGame()
|
|
{
|
|
Debug.Log("CONTINUE GAME");
|
|
Debug.Log("CONTINUE CLICKED");
|
|
|
|
isNewGame = false;
|
|
isContinue = true;
|
|
isDirectChapter = false; // 🔥 WAJIB TAMBAHAN
|
|
|
|
SceneManager.LoadScene("StorySelect");
|
|
}
|
|
|
|
public void ResetGame()
|
|
{
|
|
VN_SaveSystem.DeleteAllSave();
|
|
|
|
PlayerPrefs.DeleteAll(); // 🔥 reset full (opsional tapi aman)
|
|
PlayerPrefs.Save();
|
|
|
|
Debug.Log("SEMUA DATA DIHAPUS TOTAL");
|
|
}
|
|
|
|
// ================= CHAPTER =================
|
|
|
|
public void SelectChapter(int chapter)
|
|
{
|
|
selectedChapter = chapter;
|
|
|
|
isDirectChapter = true; // 🔥 tandai langsung pilih bab
|
|
isNewGame = false;
|
|
|
|
SceneManager.LoadScene("Bab_" + chapter);
|
|
}
|
|
public void BackToMainMenu()
|
|
{
|
|
Debug.Log("BACK KE MAIN MENU (via ManagerGame)");
|
|
Debug.Log("INSTANCE NAME = " + instance.name);
|
|
|
|
SceneManager.LoadScene("MainMenu");
|
|
}
|
|
} |