Подробные изменения: - Добавлена система призовых уровней и выдачи призов с QR-контуром Telegram, шаблоном сообщения и генерацией QR без внешних библиотек. - Доработаны сервисные настройки: действия кнопок, модальные окна, ввод с джойстика/клавиатуры, статистика, настройки призов и маршрутизация QR. - Переработаны gameplay HUD и overlay-панели на UI Toolkit со спрайтовыми плашками, DEV BUILD-статистикой, экраном продолжения и экраном результата приза. - Исправлены сценарии смерти, GameOver, продолжения игры, начисления очков за высоту и перехода в главное меню. - Перенесены UI-шаблоны из Resources в Assets/UI, подключена Addressables-загрузка шаблонов настроек и standalone-стили для MainMenuModals. - Добавлены EditMode/PlayMode тесты для призов, QR, arcade input, UI-модалок, scene flow, HUD и gameplay-сессии. - Обновлены сцены, настройки Addressables, service settings database, документация и дорожная карта. Проверки: - Targeted EditMode QR/UI/settings: 23/23 passed - Targeted UI templates/EditMode: 17/17 passed - MainMenuUxmlTests: 3/3 passed - Full EditMode: 129/129 passed - PlayMode: 6/6 passed - Runtime Addressables template load check: loaded=5 - Unity Console после финального refresh: 0 errors
143 lines
3.9 KiB
C#
143 lines
3.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace DanroJump.UI.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// Полноэкранное предложение продолжить забег за баланс.
|
|
/// </summary>
|
|
public sealed class ContinueGameOverlayWindow : IDisposable
|
|
{
|
|
private const float OpenInputGuardSeconds = 0.45f;
|
|
|
|
private readonly VisualElement root;
|
|
private readonly Label titleLabel;
|
|
private readonly Label detailsLabel;
|
|
private readonly Button continueButton;
|
|
private readonly Button menuButton;
|
|
private float inputEnabledAtTime = float.NegativeInfinity;
|
|
|
|
public ContinueGameOverlayWindow(VisualElement root)
|
|
{
|
|
this.root = root;
|
|
if (this.root != null)
|
|
{
|
|
this.root.focusable = true;
|
|
}
|
|
|
|
titleLabel = root?.Q<Label>("ContinueGameTitle");
|
|
detailsLabel = root?.Q<Label>("ContinueGameDetails");
|
|
continueButton = root?.Q<Button>("ContinueGameButton");
|
|
menuButton = root?.Q<Button>("ContinueMenuButton");
|
|
|
|
if (continueButton != null)
|
|
{
|
|
continueButton.clicked += HandleContinueClicked;
|
|
}
|
|
|
|
if (menuButton != null)
|
|
{
|
|
menuButton.clicked += HandleMenuClicked;
|
|
}
|
|
}
|
|
|
|
public event Action ContinueRequested;
|
|
public event Action MenuRequested;
|
|
|
|
public bool IsOpen { get; private set; }
|
|
|
|
public void SetOffer(int cost, int lives)
|
|
{
|
|
SetLabel(titleLabel, "Продолжить игру?");
|
|
SetLabel(detailsLabel, $"Стоимость: {Math.Max(0, cost)}. Дополнительные жизни: {Math.Max(1, lives)}.");
|
|
if (continueButton != null)
|
|
{
|
|
continueButton.SetEnabled(true);
|
|
}
|
|
}
|
|
|
|
public void SetUnavailable()
|
|
{
|
|
SetLabel(titleLabel, "Игра окончена");
|
|
SetLabel(detailsLabel, "Недостаточно баланса или функция отключена в сервисных настройках.");
|
|
if (continueButton != null)
|
|
{
|
|
continueButton.SetEnabled(false);
|
|
}
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
if (root == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
root.style.display = DisplayStyle.Flex;
|
|
root.SetEnabled(true);
|
|
IsOpen = true;
|
|
inputEnabledAtTime = Time.unscaledTime + OpenInputGuardSeconds;
|
|
root.Focus();
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
if (root == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
root.style.display = DisplayStyle.None;
|
|
root.SetEnabled(false);
|
|
IsOpen = false;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (continueButton != null)
|
|
{
|
|
continueButton.clicked -= HandleContinueClicked;
|
|
}
|
|
|
|
if (menuButton != null)
|
|
{
|
|
menuButton.clicked -= HandleMenuClicked;
|
|
}
|
|
}
|
|
|
|
private static void SetLabel(Label label, string value)
|
|
{
|
|
if (label != null)
|
|
{
|
|
label.text = value;
|
|
}
|
|
}
|
|
|
|
private void HandleContinueClicked()
|
|
{
|
|
if (IsInputGuardActive())
|
|
{
|
|
return;
|
|
}
|
|
|
|
ContinueRequested?.Invoke();
|
|
}
|
|
|
|
private void HandleMenuClicked()
|
|
{
|
|
if (IsInputGuardActive())
|
|
{
|
|
return;
|
|
}
|
|
|
|
MenuRequested?.Invoke();
|
|
}
|
|
|
|
private bool IsInputGuardActive()
|
|
{
|
|
return Time.unscaledTime < inputEnabledAtTime;
|
|
}
|
|
}
|
|
}
|