49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System;
|
|
using TemplateUnity.Core;
|
|
using UnityEngine;
|
|
|
|
namespace TemplateUnity.MainMenu
|
|
{
|
|
public class MainMenuManager: MonoBehaviour
|
|
{
|
|
public static MainMenuManager Instance { get; private set; }
|
|
|
|
public event EventHandler onMainSectionReveal;
|
|
public event EventHandler onSaveSectionReveal;
|
|
public event EventHandler onOptionsSectionReveal;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance)
|
|
{
|
|
Debug.LogWarning($"{typeof(MainMenuManager)} already instantiated! {transform}");
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
UIMainSection.Instance.onNewGameTrigger += UIMainSection_OnNewGame;
|
|
UIMainSection.Instance.onContinueTrigger += (_, _) => onSaveSectionReveal?.Invoke(this, EventArgs.Empty);
|
|
UIMainSection.Instance.onOptionsTrigger += (_, _) => onOptionsSectionReveal?.Invoke(this, EventArgs.Empty);
|
|
UIMainSection.Instance.onQuitTrigger += UIMainSection_OnQuit;
|
|
|
|
UIOptionSection.Instance.onExitTrigger += (_, _) => onMainSectionReveal?.Invoke(this, EventArgs.Empty);
|
|
|
|
onMainSectionReveal?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
|
|
private void UIMainSection_OnNewGame(object sender, EventArgs e)
|
|
{
|
|
SceneLoader.LoadScene(SceneLoader.SceneName.TestScene);
|
|
}
|
|
|
|
private void UIMainSection_OnQuit(object sender, EventArgs e)
|
|
{
|
|
Application.Quit();
|
|
}
|
|
}
|
|
} |