add project files
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit.UI;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class UIRootController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("appController")]
|
||||
private AppController _appController;
|
||||
|
||||
public UIMainMenu mainMenu;
|
||||
|
||||
public UICoreGame coreGame;
|
||||
|
||||
public UIGameOver gameOver;
|
||||
|
||||
public UIVictory victory;
|
||||
|
||||
public UIHud hud;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitSubMenus();
|
||||
hud.Setup(_appController);
|
||||
_appController.onGameExited.AddListener(OnGameExited);
|
||||
_appController.coreGame.onGameStarted.AddListener(OnCoreGameStarted);
|
||||
_appController.coreGame.onGameOver.AddListener(OnGameOver);
|
||||
_appController.onLevelCleared.AddListener(OnGameWon);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (mainMenu != null)
|
||||
{
|
||||
mainMenu.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSubMenus()
|
||||
{
|
||||
UIMenu[] menus = GetComponentsInChildren<UIMenu>(true);
|
||||
for (int i = 0; i < menus.Length; i++)
|
||||
{
|
||||
menus[i].Setup(_appController);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnGameExited()
|
||||
{
|
||||
if (mainMenu != null)
|
||||
{
|
||||
mainMenu.Show();
|
||||
}
|
||||
GetComponent<UIMenusController>().HideAllExcept(mainMenu);
|
||||
}
|
||||
|
||||
public void OnCoreGameStarted()
|
||||
{
|
||||
if (coreGame != null)
|
||||
{
|
||||
coreGame.Show();
|
||||
}
|
||||
GetComponent<UIMenusController>().HideAllExcept(coreGame);
|
||||
}
|
||||
|
||||
public void OnGameOver()
|
||||
{
|
||||
if (gameOver != null)
|
||||
{
|
||||
gameOver.Show();
|
||||
}
|
||||
GetComponent<UIMenusController>().HideAllExcept(gameOver);
|
||||
}
|
||||
|
||||
public void OnGameWon()
|
||||
{
|
||||
if (victory != null)
|
||||
{
|
||||
victory.Show();
|
||||
}
|
||||
GetComponent<UIMenusController>().HideAllExcept(victory);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user