108 lines
2.1 KiB
C#
108 lines
2.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class MainMenuController : MonoBehaviour
|
|
{
|
|
public ConfirmPopupUI popupUI;
|
|
|
|
[Header("Settings Panel")]
|
|
public GameObject settingsPanel;
|
|
|
|
private enum ConfirmAction { None, NewGame, ResetGame }
|
|
private ConfirmAction currentAction = ConfirmAction.None;
|
|
|
|
public void NewGame()
|
|
{
|
|
PlayClick();
|
|
|
|
currentAction = ConfirmAction.NewGame;
|
|
|
|
popupUI.Show(
|
|
"WARNING",
|
|
"Jika kamu menekan NEW GAME, semua progress story akan hilang dan kamu akan mulai dari awal.\n\nApakah kamu yakin?"
|
|
);
|
|
}
|
|
|
|
public void ResetGame()
|
|
{
|
|
PlayClick();
|
|
|
|
currentAction = ConfirmAction.ResetGame;
|
|
|
|
popupUI.Show(
|
|
"WARNING",
|
|
"Jika kamu menekan RESET, semua data story akan dihapus dan kamu akan mulai dari awal.\n\nApakah kamu yakin?"
|
|
);
|
|
}
|
|
|
|
public void ContinueGame()
|
|
{
|
|
PlayClick();
|
|
ManagerGame.instance.ContinueGame();
|
|
}
|
|
|
|
public void QuitGame()
|
|
{
|
|
PlayClick();
|
|
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
}
|
|
|
|
// ======================
|
|
// SETTINGS
|
|
// ======================
|
|
|
|
public void OpenSettings()
|
|
{
|
|
PlayClick();
|
|
SceneManager.LoadScene("Setting");
|
|
}
|
|
|
|
// ======================
|
|
// POPUP CONFIRM
|
|
// ======================
|
|
|
|
public void OnYes()
|
|
{
|
|
PlayClick();
|
|
|
|
popupUI.Hide();
|
|
|
|
if (currentAction == ConfirmAction.NewGame)
|
|
{
|
|
ManagerGame.instance.NewGame();
|
|
|
|
// Load scene video prolog
|
|
SceneManager.LoadScene("PrologVideo");
|
|
}
|
|
|
|
else if (currentAction == ConfirmAction.ResetGame)
|
|
{
|
|
ManagerGame.instance.ResetGame();
|
|
}
|
|
|
|
currentAction = ConfirmAction.None;
|
|
}
|
|
|
|
public void OnNo()
|
|
{
|
|
PlayClick();
|
|
|
|
popupUI.Hide();
|
|
currentAction = ConfirmAction.None;
|
|
}
|
|
|
|
// ======================
|
|
// SOUND
|
|
// ======================
|
|
|
|
void PlayClick()
|
|
{
|
|
if (ClickSoundManager.instance != null)
|
|
ClickSoundManager.instance.PlayClickSound();
|
|
}
|
|
} |