меню паузы, механика записок и лифта
This commit is contained in:
1 parent
cbda26dfc0
commit
cdd1055fd8
55 files changed
+3860
-1087
No files matched your search
@@ -0,0 +1,81 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Отображает текущий статус найденных цифр кода лифта на игровом экране (HUD).
|
||||
/// Например: "КОД ЛИФТА: [ 7 ] [ ? ] [ 1 ] [ ? ]"
|
||||
/// </summary>
|
||||
public class CodeHUDTracker : MonoBehaviour
|
||||
{
|
||||
private static CodeHUDTracker _instance;
|
||||
public static CodeHUDTracker Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = Object.FindAnyObjectByType<CodeHUDTracker>(FindObjectsInactive.Include);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
[Header("Слоты для цифр")]
|
||||
[SerializeField] private Text[] digitSlotTexts = new Text[4];
|
||||
[SerializeField] private Image[] digitSlotBorders = new Image[4];
|
||||
|
||||
[Header("Цвета")]
|
||||
public Color discoveredTextColor = new Color(1.0f, 0.85f, 0.1f, 1.0f); // Ярко-золотой
|
||||
public Color undiscoveredTextColor = new Color(0.45f, 0.45f, 0.45f, 0.7f); // Серый
|
||||
public Color discoveredBorderColor = new Color(1.0f, 0.85f, 0.1f, 0.8f);
|
||||
public Color undiscoveredBorderColor = new Color(0.3f, 0.3f, 0.3f, 0.4f);
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (LevelCodeManager.Instance != null)
|
||||
{
|
||||
LevelCodeManager.Instance.OnDigitDiscovered += HandleDigitDiscovered;
|
||||
}
|
||||
RefreshDisplay();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (LevelCodeManager.Instance != null)
|
||||
{
|
||||
LevelCodeManager.Instance.OnDigitDiscovered -= HandleDigitDiscovered;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDigitDiscovered(int pos, int val)
|
||||
{
|
||||
RefreshDisplay();
|
||||
}
|
||||
|
||||
public void RefreshDisplay()
|
||||
{
|
||||
if (LevelCodeManager.Instance == null) return;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
bool isDiscovered = LevelCodeManager.Instance.IsDigitDiscovered(i);
|
||||
int digit = LevelCodeManager.Instance.GetDigit(i);
|
||||
|
||||
if (digitSlotTexts != null && i < digitSlotTexts.Length && digitSlotTexts[i] != null)
|
||||
{
|
||||
digitSlotTexts[i].text = isDiscovered ? digit.ToString() : "?";
|
||||
digitSlotTexts[i].color = isDiscovered ? discoveredTextColor : undiscoveredTextColor;
|
||||
}
|
||||
|
||||
if (digitSlotBorders != null && i < digitSlotBorders.Length && digitSlotBorders[i] != null)
|
||||
{
|
||||
digitSlotBorders[i].color = isDiscovered ? discoveredBorderColor : undiscoveredBorderColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user