Danro-Jump/Assets/Scripts/Runtime/Gameplay/GameplayInstaller.cs
Danil Iarosh c1b72854f4 Implement prize QR and service UI polish
Подробные изменения:

- Добавлена система призовых уровней и выдачи призов с 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
2026-06-12 16:43:28 +03:00

86 lines
3.8 KiB
C#

using UnityEngine;
using Zenject;
using DanroJump.Prizes;
using DanroJump.Prizes.Qr;
using DanroJump.UI.Gameplay;
namespace DanroJump.Gameplay
{
/// <summary>
/// Регистрирует зависимости игровой сцены в SceneContext Extenject.
/// Является единой точкой связывания gameplay-сервисов и сценовых объектов.
/// </summary>
public sealed class GameplayInstaller : MonoInstaller
{
[SerializeField] private JumpPlayerController player;
[SerializeField] private Camera gameplayCamera;
[SerializeField] private PlatformSpawner platformSpawner;
[SerializeField] private GameplayDifficultyProgression difficultyProgression;
/// <summary>
/// Привязывает игрока, камеру, спавнер, прогрессию сложности и runtime-сервисы.
/// </summary>
public override void InstallBindings()
{
if (!ValidateReferences())
{
throw new ZenjectException($"{nameof(GameplayInstaller)} has missing required scene references.");
}
Container.BindInstance(player).AsSingle();
Container.BindInstance(gameplayCamera).AsSingle();
Container.BindInstance(platformSpawner).AsSingle();
Container.BindInstance(difficultyProgression).AsSingle();
Container.Bind<IGameplayDifficultyProgression>().FromInstance(difficultyProgression).AsSingle();
Container.BindInterfacesAndSelfTo<PrizeFlowService>().AsSingle();
Container.Bind<TelegramPrizeQrPayloadBuilder>().AsSingle();
Container.Bind<QrCodeTextureRenderer>().AsSingle();
Container.Bind<IPrizeQrService>().To<PrizeQrService>().AsSingle();
Container.Bind<GameplaySession>().AsSingle().NonLazy();
Container.Bind<PlatformContentSpawner>().AsSingle();
Container.Bind<GameplayHudController>().FromComponentInHierarchy().AsSingle().NonLazy();
// Сценовые MonoBehaviour уже существуют, поэтому явно ставим их в очередь на injection.
Container.QueueForInject(player);
Container.QueueForInject(difficultyProgression);
Container.QueueForInject(platformSpawner);
if (gameplayCamera != null && gameplayCamera.TryGetComponent(out VerticalCameraFollow cameraFollow))
{
Container.QueueForInject(cameraFollow);
}
}
/// <summary>
/// Проверяет обязательные ссылки сцены до регистрации зависимостей.
/// </summary>
/// <returns>True, если SceneContext настроен достаточно для запуска gameplay.</returns>
private bool ValidateReferences()
{
var isValid = true;
isValid &= ValidateReference(player, nameof(player));
isValid &= ValidateReference(gameplayCamera, nameof(gameplayCamera));
isValid &= ValidateReference(platformSpawner, nameof(platformSpawner));
isValid &= ValidateReference(difficultyProgression, nameof(difficultyProgression));
return isValid;
}
/// <summary>
/// Валидирует одну сценовую ссылку и пишет понятную ошибку в Unity Console.
/// </summary>
private bool ValidateReference(Object reference, string fieldName)
{
if (reference != null)
{
return true;
}
Debug.LogError($"{nameof(GameplayInstaller)} is missing '{fieldName}' reference.", this);
return false;
}
}
}