67 lines
1.6 KiB
C#
67 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using AibisDream.Kit;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream {
|
|
public class StartMenu : Singleton<StartMenu>
|
|
{
|
|
[SerializeField] private Button startButton;
|
|
[SerializeField] private Button selectLevelButton;
|
|
[SerializeField] private Button quitButton;
|
|
|
|
[SerializeField] private GameObject startTab;
|
|
[SerializeField] private GameObject levelTab;
|
|
[SerializeField] private GameObject buttonPrefab;
|
|
|
|
private void OnEnable()
|
|
{
|
|
startButton.onClick.AddListener(StartGame);
|
|
selectLevelButton.onClick.AddListener(SelectLevel);
|
|
quitButton.onClick.AddListener(QuitGame);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
startButton?.onClick.RemoveListener(StartGame);
|
|
selectLevelButton?.onClick.RemoveListener(SelectLevel);
|
|
quitButton?.onClick.RemoveListener(QuitGame);
|
|
}
|
|
|
|
public void StartGame()
|
|
{
|
|
GameLoopManager.Instance.StartNewGame();
|
|
}
|
|
|
|
public void SelectLevel()
|
|
{
|
|
SwitchToLevelTab();
|
|
}
|
|
|
|
private void SwitchToLevelTab()
|
|
{
|
|
startTab.SetActive(false);
|
|
levelTab.SetActive(true);
|
|
}
|
|
|
|
private void SwitchToStartTab()
|
|
{
|
|
startTab.SetActive(true);
|
|
levelTab.SetActive(false);
|
|
}
|
|
|
|
public void QuitGame()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
|
|
public void HideStartMenu()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|