меню паузы, механика записок и лифта
This commit is contained in:
1 parent
cbda26dfc0
commit
cdd1055fd8
55 files changed
+3860
-1087
No files matched your search
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Экран завершения первого уровня при успешном вводе кода лифта.
|
||||
/// </summary>
|
||||
public class LevelSuccessUI : MonoBehaviour
|
||||
{
|
||||
private static LevelSuccessUI _instance;
|
||||
public static LevelSuccessUI Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = Object.FindAnyObjectByType<LevelSuccessUI>(FindObjectsInactive.Include);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
[Header("Корневая панель")]
|
||||
[SerializeField] private GameObject successPanelRoot;
|
||||
|
||||
public bool IsOpen => successPanelRoot != null && successPanelRoot.activeInHierarchy;
|
||||
|
||||
[Header("Кнопки")]
|
||||
[SerializeField] private Button nextLevelButton;
|
||||
[SerializeField] private Button mainMenuButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
if (successPanelRoot == null)
|
||||
successPanelRoot = gameObject;
|
||||
|
||||
if (nextLevelButton != null)
|
||||
{
|
||||
nextLevelButton.onClick.RemoveAllListeners();
|
||||
nextLevelButton.onClick.AddListener(OnNextLevelClicked);
|
||||
}
|
||||
|
||||
if (mainMenuButton != null)
|
||||
{
|
||||
mainMenuButton.onClick.RemoveAllListeners();
|
||||
mainMenuButton.onClick.AddListener(OnMainMenuClicked);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowSuccessScreen()
|
||||
{
|
||||
if (!gameObject.activeSelf) gameObject.SetActive(true);
|
||||
if (successPanelRoot != null)
|
||||
successPanelRoot.SetActive(true);
|
||||
|
||||
Time.timeScale = 0f;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
|
||||
GameAudioSynthesizer.PlaySuccessChime();
|
||||
}
|
||||
|
||||
private void OnNextLevelClicked()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||
}
|
||||
|
||||
private void OnMainMenuClicked()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
SceneManager.LoadScene("MainMenu");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user