53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Level;
|
|
|
|
public class Menu : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject menuDropdown;
|
|
[SerializeField] private GameObject[] buttonsToInitialize; // Buttons that rely on initialized level to work
|
|
[SerializeField] private GameObject editingButtonsContainer;
|
|
[SerializeField] private GameObject gameplayButtonsContainer;
|
|
[SerializeField] private GameObject startMenu;
|
|
|
|
private void Awake()
|
|
{
|
|
menuDropdown.SetActive(false);
|
|
foreach (GameObject button in buttonsToInitialize)
|
|
{
|
|
button.SetActive(false);
|
|
}
|
|
}
|
|
|
|
|
|
private void Start()
|
|
{
|
|
LevelBuilder.Instance.LevelInitialized += OnLevelInitialized;
|
|
GameManager.Instance.GameStateChanged += OnGameStateChanged;
|
|
}
|
|
|
|
|
|
public void ToggleMenu()
|
|
{
|
|
menuDropdown.SetActive(!menuDropdown.activeSelf);
|
|
}
|
|
|
|
|
|
private void OnLevelInitialized()
|
|
{
|
|
foreach (GameObject button in buttonsToInitialize)
|
|
{
|
|
button.SetActive(true);
|
|
}
|
|
startMenu.SetActive(false);
|
|
}
|
|
|
|
|
|
private void OnGameStateChanged(GameState newState)
|
|
{
|
|
editingButtonsContainer.SetActive(newState == GameState.Editing);
|
|
gameplayButtonsContainer.SetActive(newState == GameState.Gameplay);
|
|
}
|
|
}
|