2026-11-19 23:24:44 +03:00
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
[DisallowMultipleComponent]
|
|
|
|
|
public class RestorationHUD : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static RestorationHUD Instance { get; private set; }
|
|
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
[Header("Расположение на экране (от нижнего центра)")]
|
|
|
|
|
[SerializeField] private Vector2 bottomCenterOffset = new Vector2(0f, 85f);
|
|
|
|
|
[SerializeField] private float fadeSpeed = 14f;
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
private CanvasGroup canvasGroup;
|
2026-11-20 05:08:26 +03:00
|
|
|
private RectTransform cardRoot;
|
2026-11-19 23:24:44 +03:00
|
|
|
private TextMeshProUGUI titleText;
|
|
|
|
|
private TextMeshProUGUI stageBadgeText;
|
|
|
|
|
private Image stageBadgeBg;
|
|
|
|
|
private Image progressFill;
|
|
|
|
|
private TextMeshProUGUI progressPercentText;
|
|
|
|
|
private TextMeshProUGUI hintText;
|
|
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
private bool uiInitialized;
|
2026-11-19 23:24:44 +03:00
|
|
|
private float targetAlpha = 0f;
|
|
|
|
|
private float hideTimer = 0f;
|
|
|
|
|
private float currentFillAmount = 0f;
|
2026-11-20 05:08:26 +03:00
|
|
|
private int lastShownFrame = -1;
|
|
|
|
|
|
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
|
|
|
|
private static void EnsureExistsInScene()
|
|
|
|
|
{
|
|
|
|
|
if (Instance != null || FindAnyObjectByType<RestorationHUD>() != null) return;
|
|
|
|
|
|
|
|
|
|
GameObject canvasObj = new GameObject("RestorationHUD_Canvas");
|
|
|
|
|
Canvas canvas = canvasObj.AddComponent<Canvas>();
|
|
|
|
|
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
|
|
|
|
canvas.sortingOrder = 25;
|
|
|
|
|
|
|
|
|
|
CanvasScaler scaler = canvasObj.AddComponent<CanvasScaler>();
|
|
|
|
|
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
|
|
|
|
scaler.referenceResolution = new Vector2(1920f, 1080f);
|
|
|
|
|
|
|
|
|
|
GameObject hudObj = new GameObject("RestorationHUD");
|
|
|
|
|
hudObj.transform.SetParent(canvasObj.transform, false);
|
|
|
|
|
hudObj.AddComponent<RestorationHUD>();
|
|
|
|
|
}
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
if (Instance == null) Instance = this;
|
|
|
|
|
else if (Instance != this) { Destroy(gameObject); return; }
|
|
|
|
|
|
|
|
|
|
EnsureUIElementsCreated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EnsureUIElementsCreated()
|
|
|
|
|
{
|
2026-11-20 05:08:26 +03:00
|
|
|
// Инициализируем ровно один раз — иначе каждый кадр будет сбрасываться alpha = 0
|
|
|
|
|
if (uiInitialized && titleText != null && canvasGroup != null) return;
|
|
|
|
|
uiInitialized = true;
|
|
|
|
|
|
|
|
|
|
// Если RestorationHUD повешен на объект вне Canvas (например, GameSystems) — создаём свой Canvas
|
|
|
|
|
RectTransform targetParent;
|
|
|
|
|
if (GetComponentInParent<Canvas>() == null)
|
|
|
|
|
{
|
|
|
|
|
GameObject canvasObj = new GameObject("RestorationHUD_Canvas");
|
|
|
|
|
canvasObj.transform.SetParent(transform, false);
|
|
|
|
|
Canvas c = canvasObj.AddComponent<Canvas>();
|
|
|
|
|
c.renderMode = RenderMode.ScreenSpaceOverlay;
|
|
|
|
|
c.sortingOrder = 25;
|
|
|
|
|
|
|
|
|
|
CanvasScaler scaler = canvasObj.AddComponent<CanvasScaler>();
|
|
|
|
|
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
|
|
|
|
scaler.referenceResolution = new Vector2(1920f, 1080f);
|
|
|
|
|
|
|
|
|
|
GameObject cardObj = new GameObject("RestorationCard");
|
|
|
|
|
cardObj.transform.SetParent(canvasObj.transform, false);
|
|
|
|
|
targetParent = cardObj.AddComponent<RectTransform>();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
targetParent = GetComponent<RectTransform>();
|
|
|
|
|
if (targetParent == null) targetParent = gameObject.AddComponent<RectTransform>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cardRoot = targetParent;
|
|
|
|
|
|
|
|
|
|
canvasGroup = cardRoot.GetComponent<CanvasGroup>();
|
|
|
|
|
if (canvasGroup == null) canvasGroup = cardRoot.gameObject.AddComponent<CanvasGroup>();
|
2026-11-19 23:24:44 +03:00
|
|
|
canvasGroup.alpha = 0f;
|
|
|
|
|
canvasGroup.blocksRaycasts = false;
|
|
|
|
|
canvasGroup.interactable = false;
|
2026-11-20 05:08:26 +03:00
|
|
|
canvasGroup.ignoreParentGroups = true;
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
if (titleText == null)
|
2026-11-20 05:08:26 +03:00
|
|
|
BuildModernHUD(cardRoot);
|
|
|
|
|
else
|
|
|
|
|
ApplyPosition(cardRoot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ApplyPosition(RectTransform rt)
|
|
|
|
|
{
|
|
|
|
|
// Нижний центр экрана — выше строки горячих клавиш, не перекрывает центр и подсказки [F]/[E]
|
|
|
|
|
rt.anchorMin = new Vector2(0.5f, 0f);
|
|
|
|
|
rt.anchorMax = new Vector2(0.5f, 0f);
|
|
|
|
|
rt.pivot = new Vector2(0.5f, 0f);
|
|
|
|
|
rt.anchoredPosition = bottomCenterOffset;
|
|
|
|
|
rt.sizeDelta = new Vector2(440f, 128f);
|
2026-11-19 23:24:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BuildModernHUD(RectTransform parent)
|
|
|
|
|
{
|
2026-11-20 05:08:26 +03:00
|
|
|
ApplyPosition(parent);
|
2026-11-19 23:24:44 +03:00
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
Image cardBg = parent.GetComponent<Image>();
|
|
|
|
|
if (cardBg == null) cardBg = parent.gameObject.AddComponent<Image>();
|
|
|
|
|
cardBg.color = Color.white;
|
2026-11-19 23:24:44 +03:00
|
|
|
cardBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(
|
2026-11-20 05:08:26 +03:00
|
|
|
new Color(0.07f, 0.09f, 0.13f, 0.96f),
|
|
|
|
|
new Color(0.32f, 0.40f, 0.52f, 0.85f),
|
2026-11-19 23:24:44 +03:00
|
|
|
1.5f, 16);
|
|
|
|
|
cardBg.type = Image.Type.Sliced;
|
|
|
|
|
cardBg.raycastTarget = false;
|
|
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
// Верхняя строка: Название детали + Бейдж этапа
|
2026-11-19 23:24:44 +03:00
|
|
|
GameObject topRow = new GameObject("TopRow");
|
2026-11-20 05:08:26 +03:00
|
|
|
topRow.transform.SetParent(parent, false);
|
2026-11-19 23:24:44 +03:00
|
|
|
RectTransform trRt = topRow.AddComponent<RectTransform>();
|
|
|
|
|
trRt.anchorMin = new Vector2(0f, 1f);
|
|
|
|
|
trRt.anchorMax = new Vector2(1f, 1f);
|
|
|
|
|
trRt.pivot = new Vector2(0.5f, 1f);
|
|
|
|
|
trRt.anchoredPosition = new Vector2(0f, -12f);
|
|
|
|
|
trRt.sizeDelta = new Vector2(-24f, 26f);
|
|
|
|
|
|
|
|
|
|
GameObject titleObj = new GameObject("TitleText");
|
|
|
|
|
titleObj.transform.SetParent(topRow.transform, false);
|
|
|
|
|
RectTransform titleRt = titleObj.AddComponent<RectTransform>();
|
|
|
|
|
titleRt.anchorMin = new Vector2(0f, 0f);
|
|
|
|
|
titleRt.anchorMax = new Vector2(0.65f, 1f);
|
|
|
|
|
titleRt.pivot = new Vector2(0f, 0.5f);
|
|
|
|
|
titleRt.anchoredPosition = Vector2.zero;
|
|
|
|
|
titleRt.sizeDelta = Vector2.zero;
|
|
|
|
|
|
|
|
|
|
titleText = titleObj.AddComponent<TextMeshProUGUI>();
|
2026-11-20 05:08:26 +03:00
|
|
|
titleText.fontSize = 16f;
|
2026-11-19 23:24:44 +03:00
|
|
|
titleText.fontStyle = FontStyles.Bold;
|
2026-11-20 05:08:26 +03:00
|
|
|
titleText.color = Color.white;
|
2026-11-19 23:24:44 +03:00
|
|
|
titleText.alignment = TextAlignmentOptions.MidlineLeft;
|
2026-11-20 05:08:26 +03:00
|
|
|
titleText.text = "Кузов";
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
GameObject badgeObj = new GameObject("StageBadge");
|
|
|
|
|
badgeObj.transform.SetParent(topRow.transform, false);
|
|
|
|
|
RectTransform badgeRt = badgeObj.AddComponent<RectTransform>();
|
|
|
|
|
badgeRt.anchorMin = new Vector2(0.65f, 0f);
|
|
|
|
|
badgeRt.anchorMax = new Vector2(1f, 1f);
|
|
|
|
|
badgeRt.pivot = new Vector2(1f, 0.5f);
|
|
|
|
|
badgeRt.anchoredPosition = Vector2.zero;
|
|
|
|
|
badgeRt.sizeDelta = Vector2.zero;
|
|
|
|
|
|
|
|
|
|
stageBadgeBg = badgeObj.AddComponent<Image>();
|
2026-11-20 05:08:26 +03:00
|
|
|
stageBadgeBg.color = Color.white;
|
2026-11-19 23:24:44 +03:00
|
|
|
stageBadgeBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(
|
2026-11-20 05:08:26 +03:00
|
|
|
new Color(0.85f, 0.35f, 0.12f, 1f), null, 0f, 8);
|
2026-11-19 23:24:44 +03:00
|
|
|
stageBadgeBg.type = Image.Type.Sliced;
|
|
|
|
|
|
|
|
|
|
GameObject badgeTextObj = new GameObject("BadgeText");
|
|
|
|
|
badgeTextObj.transform.SetParent(badgeObj.transform, false);
|
|
|
|
|
RectTransform btRt = badgeTextObj.AddComponent<RectTransform>();
|
|
|
|
|
btRt.anchorMin = Vector2.zero;
|
|
|
|
|
btRt.anchorMax = Vector2.one;
|
|
|
|
|
btRt.sizeDelta = Vector2.zero;
|
|
|
|
|
|
|
|
|
|
stageBadgeText = badgeTextObj.AddComponent<TextMeshProUGUI>();
|
2026-11-20 05:08:26 +03:00
|
|
|
stageBadgeText.fontSize = 12.5f;
|
2026-11-19 23:24:44 +03:00
|
|
|
stageBadgeText.fontStyle = FontStyles.Bold;
|
|
|
|
|
stageBadgeText.color = Color.white;
|
|
|
|
|
stageBadgeText.alignment = TextAlignmentOptions.Center;
|
|
|
|
|
stageBadgeText.text = "Ржавчина";
|
|
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
// Полоса прогресса
|
2026-11-19 23:24:44 +03:00
|
|
|
GameObject progressTrack = new GameObject("ProgressTrack");
|
2026-11-20 05:08:26 +03:00
|
|
|
progressTrack.transform.SetParent(parent, false);
|
2026-11-19 23:24:44 +03:00
|
|
|
RectTransform ptRt = progressTrack.AddComponent<RectTransform>();
|
|
|
|
|
ptRt.anchorMin = new Vector2(0f, 0.5f);
|
|
|
|
|
ptRt.anchorMax = new Vector2(1f, 0.5f);
|
|
|
|
|
ptRt.pivot = new Vector2(0.5f, 0.5f);
|
2026-11-20 05:08:26 +03:00
|
|
|
ptRt.anchoredPosition = new Vector2(0f, 4f);
|
|
|
|
|
ptRt.sizeDelta = new Vector2(-24f, 18f);
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
Image trackBg = progressTrack.AddComponent<Image>();
|
2026-11-20 05:08:26 +03:00
|
|
|
trackBg.color = Color.white;
|
2026-11-19 23:24:44 +03:00
|
|
|
trackBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(
|
2026-11-20 05:08:26 +03:00
|
|
|
new Color(0.14f, 0.17f, 0.23f, 1f),
|
|
|
|
|
new Color(0.28f, 0.34f, 0.44f, 0.85f), 1f, 8);
|
2026-11-19 23:24:44 +03:00
|
|
|
trackBg.type = Image.Type.Sliced;
|
|
|
|
|
|
|
|
|
|
GameObject fillObj = new GameObject("ProgressFill");
|
|
|
|
|
fillObj.transform.SetParent(progressTrack.transform, false);
|
|
|
|
|
RectTransform fillRt = fillObj.AddComponent<RectTransform>();
|
|
|
|
|
fillRt.anchorMin = Vector2.zero;
|
|
|
|
|
fillRt.anchorMax = Vector2.one;
|
|
|
|
|
fillRt.sizeDelta = new Vector2(-4f, -4f);
|
|
|
|
|
|
|
|
|
|
progressFill = fillObj.AddComponent<Image>();
|
2026-11-20 05:08:26 +03:00
|
|
|
progressFill.sprite = ProceduralUISprites.GetSlicedRoundedRect(Color.white, null, 0f, 6);
|
|
|
|
|
progressFill.color = new Color(0.20f, 0.65f, 0.95f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
progressFill.type = Image.Type.Filled;
|
|
|
|
|
progressFill.fillMethod = Image.FillMethod.Horizontal;
|
|
|
|
|
progressFill.fillOrigin = 0;
|
2026-11-20 05:08:26 +03:00
|
|
|
progressFill.fillAmount = 0f;
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
GameObject pctObj = new GameObject("PercentText");
|
|
|
|
|
pctObj.transform.SetParent(progressTrack.transform, false);
|
|
|
|
|
RectTransform pctRt = pctObj.AddComponent<RectTransform>();
|
|
|
|
|
pctRt.anchorMin = Vector2.zero;
|
|
|
|
|
pctRt.anchorMax = Vector2.one;
|
|
|
|
|
pctRt.sizeDelta = Vector2.zero;
|
|
|
|
|
|
|
|
|
|
progressPercentText = pctObj.AddComponent<TextMeshProUGUI>();
|
2026-11-20 05:08:26 +03:00
|
|
|
progressPercentText.fontSize = 12f;
|
2026-11-19 23:24:44 +03:00
|
|
|
progressPercentText.fontStyle = FontStyles.Bold;
|
|
|
|
|
progressPercentText.color = Color.white;
|
|
|
|
|
progressPercentText.alignment = TextAlignmentOptions.Center;
|
2026-11-20 05:08:26 +03:00
|
|
|
progressPercentText.text = "0%";
|
2026-11-19 23:24:44 +03:00
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
// Нижняя подсказка
|
2026-11-19 23:24:44 +03:00
|
|
|
GameObject hintObj = new GameObject("HintText");
|
2026-11-20 05:08:26 +03:00
|
|
|
hintObj.transform.SetParent(parent, false);
|
2026-11-19 23:24:44 +03:00
|
|
|
RectTransform hintRt = hintObj.AddComponent<RectTransform>();
|
|
|
|
|
hintRt.anchorMin = new Vector2(0f, 0f);
|
|
|
|
|
hintRt.anchorMax = new Vector2(1f, 0f);
|
|
|
|
|
hintRt.pivot = new Vector2(0.5f, 0f);
|
|
|
|
|
hintRt.anchoredPosition = new Vector2(0f, 10f);
|
2026-11-20 05:08:26 +03:00
|
|
|
hintRt.sizeDelta = new Vector2(-24f, 34f);
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
hintText = hintObj.AddComponent<TextMeshProUGUI>();
|
2026-11-20 05:08:26 +03:00
|
|
|
hintText.fontSize = 13f;
|
|
|
|
|
hintText.color = new Color(0.90f, 0.93f, 0.97f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
hintText.alignment = TextAlignmentOptions.Center;
|
|
|
|
|
hintText.text = "[Удерж. ЛКМ] Водите инструментом по детали";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (hideTimer > 0f)
|
|
|
|
|
{
|
|
|
|
|
hideTimer -= Time.deltaTime;
|
|
|
|
|
if (hideTimer <= 0f) targetAlpha = 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (canvasGroup != null)
|
2026-11-20 05:08:26 +03:00
|
|
|
canvasGroup.alpha = Mathf.MoveTowards(canvasGroup.alpha, targetAlpha, Time.deltaTime * fadeSpeed);
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
if (progressFill != null)
|
|
|
|
|
progressFill.fillAmount = Mathf.Lerp(progressFill.fillAmount, currentFillAmount, Time.deltaTime * 15f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowRestorationProgress(
|
|
|
|
|
string partName,
|
|
|
|
|
RepairStage stage,
|
|
|
|
|
float progress01,
|
|
|
|
|
string contextualHint,
|
|
|
|
|
bool isCorrectTool)
|
|
|
|
|
{
|
|
|
|
|
EnsureUIElementsCreated();
|
2026-11-20 05:08:26 +03:00
|
|
|
lastShownFrame = Time.frameCount;
|
2026-11-19 23:24:44 +03:00
|
|
|
targetAlpha = 1f;
|
|
|
|
|
hideTimer = 0.25f;
|
|
|
|
|
|
|
|
|
|
if (titleText != null) titleText.text = partName;
|
|
|
|
|
currentFillAmount = Mathf.Clamp01(progress01);
|
|
|
|
|
|
|
|
|
|
int percent = Mathf.RoundToInt(currentFillAmount * 100f);
|
|
|
|
|
if (progressPercentText != null)
|
2026-11-20 05:08:26 +03:00
|
|
|
progressPercentText.text = (stage == RepairStage.Healthy || stage == RepairStage.Repaired) ? "100%" : $"{percent}%";
|
2026-11-19 23:24:44 +03:00
|
|
|
|
|
|
|
|
SetupStageBadge(stage);
|
|
|
|
|
|
|
|
|
|
if (hintText != null)
|
|
|
|
|
{
|
|
|
|
|
hintText.text = contextualHint;
|
2026-11-20 05:08:26 +03:00
|
|
|
hintText.color = isCorrectTool ? new Color(0.90f, 0.95f, 1f, 1f) : new Color(1f, 0.72f, 0.35f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetupStageBadge(RepairStage stage)
|
|
|
|
|
{
|
|
|
|
|
if (stageBadgeText == null || stageBadgeBg == null) return;
|
|
|
|
|
|
|
|
|
|
Color badgeColor;
|
|
|
|
|
string badgeName;
|
|
|
|
|
|
|
|
|
|
switch (stage)
|
|
|
|
|
{
|
|
|
|
|
case RepairStage.Healthy:
|
|
|
|
|
badgeName = "Заводская";
|
2026-11-20 05:08:26 +03:00
|
|
|
badgeColor = new Color(0.18f, 0.72f, 0.38f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
break;
|
|
|
|
|
case RepairStage.Rusted:
|
|
|
|
|
badgeName = "Ржавчина";
|
2026-11-20 05:08:26 +03:00
|
|
|
badgeColor = new Color(0.92f, 0.38f, 0.12f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
break;
|
|
|
|
|
case RepairStage.Cleaned:
|
|
|
|
|
badgeName = "Зачищено";
|
2026-11-20 05:08:26 +03:00
|
|
|
badgeColor = new Color(0.50f, 0.58f, 0.68f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
break;
|
|
|
|
|
case RepairStage.Puttied:
|
|
|
|
|
badgeName = "Шпаклёвка";
|
2026-11-20 05:08:26 +03:00
|
|
|
badgeColor = new Color(0.82f, 0.70f, 0.32f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
break;
|
|
|
|
|
case RepairStage.Sanded:
|
|
|
|
|
badgeName = "Шлифовка";
|
2026-11-20 05:08:26 +03:00
|
|
|
badgeColor = new Color(0.20f, 0.68f, 0.42f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
badgeName = "Восстановлено";
|
2026-11-20 05:08:26 +03:00
|
|
|
badgeColor = new Color(0.15f, 0.75f, 0.95f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stageBadgeText.text = badgeName;
|
|
|
|
|
stageBadgeBg.color = badgeColor;
|
|
|
|
|
if (progressFill != null) progressFill.color = badgeColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowFluidPouringHUD(
|
|
|
|
|
string tankTitle,
|
|
|
|
|
FluidType type,
|
|
|
|
|
float currentLiters,
|
|
|
|
|
float maxLiters,
|
|
|
|
|
float canisterRemainingLiters,
|
|
|
|
|
Color fluidColor)
|
|
|
|
|
{
|
|
|
|
|
EnsureUIElementsCreated();
|
2026-11-20 05:08:26 +03:00
|
|
|
lastShownFrame = Time.frameCount;
|
2026-11-19 23:24:44 +03:00
|
|
|
targetAlpha = 1f;
|
|
|
|
|
hideTimer = 0.25f;
|
|
|
|
|
|
|
|
|
|
float fill01 = Mathf.Clamp01(currentLiters / Mathf.Max(maxLiters, 0.01f));
|
|
|
|
|
currentFillAmount = fill01;
|
|
|
|
|
int percent = Mathf.RoundToInt(fill01 * 100f);
|
|
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
Color opaqueFluid = new Color(fluidColor.r, fluidColor.g, fluidColor.b, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
if (titleText != null) titleText.text = tankTitle;
|
|
|
|
|
if (stageBadgeText != null)
|
|
|
|
|
{
|
|
|
|
|
stageBadgeText.text = "Залив жидкости";
|
2026-11-20 05:08:26 +03:00
|
|
|
stageBadgeBg.color = opaqueFluid;
|
2026-11-19 23:24:44 +03:00
|
|
|
}
|
|
|
|
|
|
2026-11-20 05:08:26 +03:00
|
|
|
if (progressFill != null) progressFill.color = opaqueFluid;
|
2026-11-19 23:24:44 +03:00
|
|
|
if (progressPercentText != null)
|
|
|
|
|
progressPercentText.text = $"{currentLiters:F1} / {maxLiters:F1} л ({percent}%)";
|
|
|
|
|
|
|
|
|
|
if (hintText != null)
|
|
|
|
|
{
|
|
|
|
|
hintText.text = $"[Удерж. ЛКМ] Залить жидкость | В канистре: {canisterRemainingLiters:F1} л";
|
|
|
|
|
hintText.color = Color.white;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowCustomMessage(string message)
|
|
|
|
|
{
|
|
|
|
|
EnsureUIElementsCreated();
|
2026-11-20 05:08:26 +03:00
|
|
|
lastShownFrame = Time.frameCount;
|
2026-11-19 23:24:44 +03:00
|
|
|
targetAlpha = 1f;
|
|
|
|
|
hideTimer = 0.25f;
|
|
|
|
|
|
|
|
|
|
if (hintText != null)
|
|
|
|
|
{
|
|
|
|
|
hintText.text = message;
|
2026-11-20 05:08:26 +03:00
|
|
|
hintText.color = new Color(1f, 0.85f, 0.45f, 1f);
|
2026-11-19 23:24:44 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Hide()
|
|
|
|
|
{
|
2026-11-20 05:08:26 +03:00
|
|
|
if (Time.frameCount == lastShownFrame) return;
|
2026-11-19 23:24:44 +03:00
|
|
|
targetAlpha = 0f;
|
|
|
|
|
}
|
2026-11-20 05:08:26 +03:00
|
|
|
}
|