mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-08 23:03:43 +00:00
UI ups
This commit is contained in:
91
Assets/Scripts/UI/UIManager.cs
Normal file
91
Assets/Scripts/UI/UIManager.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIManager: MonoBehaviour
|
||||
{
|
||||
public enum UIState
|
||||
{
|
||||
MainMenu = 0,
|
||||
Game = 1,
|
||||
Pause = 2,
|
||||
HowToPlay = 3,
|
||||
StageSelect = 4,
|
||||
ConfirmQuit = 5,
|
||||
}
|
||||
|
||||
public List<UIState> StateStack = new List<UIState>() {UIState.MainMenu};
|
||||
|
||||
public GameObject MainMenu;
|
||||
public GameObject Reticle;
|
||||
public GameObject HowToPlay;
|
||||
public GameObject StageSelect;
|
||||
public GameObject ConfirmQuit;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
MainMenu.SetActive(false);
|
||||
Reticle.SetActive(false);
|
||||
HowToPlay.SetActive(false);
|
||||
StageSelect.SetActive(false);
|
||||
ConfirmQuit.SetActive(false);
|
||||
|
||||
PushState(UIState.MainMenu);
|
||||
}
|
||||
|
||||
public void PushState(UIState state)
|
||||
{
|
||||
if (StateStack.Count > 0)
|
||||
{
|
||||
OnExitState(StateStack[0]);
|
||||
}
|
||||
|
||||
StateStack.Add(state);
|
||||
OnEnterState(state);
|
||||
}
|
||||
|
||||
public void PopState()
|
||||
{
|
||||
if (StateStack.Count > 0)
|
||||
{
|
||||
OnExitState(StateStack[0]);
|
||||
StateStack.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnterState(UIState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case UIState.MainMenu:
|
||||
MainMenu.SetActive(true);
|
||||
break;
|
||||
case UIState.Game:
|
||||
Reticle.SetActive(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExitState(UIState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case UIState.MainMenu:
|
||||
MainMenu.SetActive(false);
|
||||
break;
|
||||
case UIState.Game:
|
||||
Reticle.SetActive(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartStage(int stage)
|
||||
{
|
||||
Scoreboard.Instance.StartStage((StagingManager.StageEnum)stage);
|
||||
PushState(UIState.Game);
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
3
Assets/Scripts/UI/UIManager.cs.meta
Normal file
3
Assets/Scripts/UI/UIManager.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d007036093842af8034f1c5e5c1e7e8
|
||||
timeCreated: 1724110214
|
Reference in New Issue
Block a user