босс
This commit is contained in:
1 parent
76b6566e46
commit
11d290d572
49 files changed
+2562
-587
No files matched your search
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Финальный экран победы при успешном завершении игры на 2-м уровне.
|
||||
/// </summary>
|
||||
public class FinalVictoryUI : MonoBehaviour
|
||||
{
|
||||
private static FinalVictoryUI _instance;
|
||||
public static FinalVictoryUI Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = Object.FindAnyObjectByType<FinalVictoryUI>(FindObjectsInactive.Include);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
[Header("Корневая панель")]
|
||||
[SerializeField] private GameObject victoryPanelRoot;
|
||||
|
||||
public bool IsOpen => victoryPanelRoot != null && victoryPanelRoot.activeInHierarchy;
|
||||
|
||||
[Header("Кнопки")]
|
||||
[SerializeField] private Button restartButton;
|
||||
[SerializeField] private Button mainMenuButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
if (victoryPanelRoot == null)
|
||||
victoryPanelRoot = gameObject;
|
||||
|
||||
if (restartButton != null)
|
||||
{
|
||||
restartButton.onClick.RemoveAllListeners();
|
||||
restartButton.onClick.AddListener(OnRestartGameClicked);
|
||||
}
|
||||
|
||||
if (mainMenuButton != null)
|
||||
{
|
||||
mainMenuButton.onClick.RemoveAllListeners();
|
||||
mainMenuButton.onClick.AddListener(OnMainMenuClicked);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowVictoryScreen()
|
||||
{
|
||||
if (!gameObject.activeSelf) gameObject.SetActive(true);
|
||||
if (victoryPanelRoot != null)
|
||||
victoryPanelRoot.SetActive(true);
|
||||
|
||||
Time.timeScale = 0f;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
|
||||
GameAudioSynthesizer.PlaySuccessChime();
|
||||
}
|
||||
|
||||
private void OnRestartGameClicked()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
SceneManager.LoadScene("SampleScene"); // Начать с 1-го уровня
|
||||
}
|
||||
|
||||
private void OnMainMenuClicked()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
SceneManager.LoadScene("MainMenu");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user