Gameplay-Edit
This commit is contained in:
52
Assets/Scripts/UI/Menu.cs
Normal file
52
Assets/Scripts/UI/Menu.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user