Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
- добавлена новая система призов: PrizeBase, PrizeType, PrizeDatabase, LevelPrizeConfig и реализации для hopper, QR-кода, отсутствия приза и стойки с призом - добавлена конфигурация призов уровней через `prizes.json` и связанная логика загрузки/обработки в менеджерах игры - расширен UI главного меню и настроек уровней: добавлены LevelSettingsModal, LevelPrizeSettingsModal, QRCodeModal и PrizeStandModal - обновлена навигация модальных окон и связанный UI-код: ModalManager, MainMenu, RulesModal, PauseMenu, PrizeErrorDisplay, UIRowPointer и WinBannerController - доработаны настройки и генерация UI-элементов: обновлены SettingsDatabase, SettingsUIGenerator, SettingUIItem, ValueSelectorRow и editor drawer для настроек - обновлены и добавлены UI-prefab'ы для кнопок, строк настроек, панели групп и кнопки настроек уровня - обновлены сцены `MainMenu` и `Level UI` под новый флоу настройки уровней, выбора призов и отображения модалок - добавлены файлы лаунчера в `StreamingAssets`, включая `RRLauncher.exe`, служебные meta-файлы и документацию - улучшено логирование через FileLogger и удален устаревший код лицензирования - удалены больше неиспользуемые файлы: `Licensing.cs`, `SteppedSlider.cs` и recovery-сцены
118 lines
4.1 KiB
C#
118 lines
4.1 KiB
C#
using RR.Game2D.Core.Managers;
|
|
using RR.Common.Settings;
|
|
using RR.Common.Managers;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace RR.Common.UI
|
|
{
|
|
public class UICreditsTextController : MonoBehaviour
|
|
{
|
|
// UI elements
|
|
[SerializeField] private TextMeshProUGUI livesIncreaseText;
|
|
[SerializeField] private TextMeshProUGUI livesText;
|
|
|
|
// Strings to display
|
|
[SerializeField] private string livesIncreaseString = "{0}";
|
|
[SerializeField] private string livesString = "{0}";
|
|
|
|
private GameManager _gameManager;
|
|
private SettingsManager _settingsManager;
|
|
private BalanceManager _balanceManager;
|
|
|
|
private void Start()
|
|
{
|
|
_gameManager = GameManager.Instance;
|
|
_balanceManager = BalanceManager.Instance;
|
|
|
|
if (_gameManager == null) return;
|
|
|
|
_settingsManager = _gameManager.Settings;
|
|
|
|
if (_settingsManager == null) _settingsManager = SettingsManager.Instance;
|
|
|
|
UpdateLivesText();
|
|
UpdateLivesIncreaseText();
|
|
|
|
// Подписываемся на изменение баланса для пересчета жизней
|
|
if (_balanceManager != null)
|
|
{
|
|
_balanceManager.OnBalanceChanged.AddListener(OnBalanceChanged);
|
|
}
|
|
|
|
if (_settingsManager != null)
|
|
{
|
|
_settingsManager.OnSettingsLoaded += UpdateLivesIncreaseText;
|
|
_settingsManager.OnSettingsSaved += UpdateLivesIncreaseText;
|
|
_settingsManager.OnSettingsLoaded += OnSettingsChanged;
|
|
_settingsManager.OnSettingsSaved += OnSettingsChanged;
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (_gameManager == null) _gameManager = GameManager.Instance;
|
|
|
|
if (_balanceManager != null)
|
|
{
|
|
_balanceManager.OnBalanceChanged.RemoveListener(OnBalanceChanged);
|
|
}
|
|
|
|
if (_settingsManager != null)
|
|
{
|
|
_settingsManager.OnSettingsLoaded -= UpdateLivesIncreaseText;
|
|
_settingsManager.OnSettingsSaved -= UpdateLivesIncreaseText;
|
|
_settingsManager.OnSettingsLoaded -= OnSettingsChanged;
|
|
_settingsManager.OnSettingsSaved -= OnSettingsChanged;
|
|
}
|
|
}
|
|
|
|
private void OnBalanceChanged(int newBalance)
|
|
{
|
|
UpdateLivesText();
|
|
}
|
|
|
|
private void OnSettingsChanged()
|
|
{
|
|
UpdateLivesText();
|
|
}
|
|
|
|
private void UpdateLivesIncreaseText()
|
|
{
|
|
if (_settingsManager == null) return;
|
|
|
|
int additionalLives = _settingsManager.GetInt("gameplay.additionalLives");
|
|
|
|
if (livesIncreaseText != null)
|
|
{
|
|
livesIncreaseText.transform.parent.gameObject.SetActive(additionalLives > 0);
|
|
livesIncreaseText.text = string.Format(livesIncreaseString, additionalLives);
|
|
}
|
|
}
|
|
|
|
private void UpdateLivesText()
|
|
{
|
|
if (_gameManager == null || _balanceManager == null || _settingsManager == null)
|
|
return;
|
|
|
|
int currentBalance = _balanceManager.CurrentBalance;
|
|
int impulseCost = _settingsManager.GetInt("payment.paymentImpulseCost");
|
|
int startLives = _settingsManager.GetInt("gameplay.startLives");
|
|
int livesIncrement = _settingsManager.GetInt("gameplay.additionalLives");
|
|
|
|
if (impulseCost <= 0) impulseCost = 10;
|
|
|
|
// Рассчитываем количество жизней на основе баланса
|
|
int totalImpulses = currentBalance / impulseCost;
|
|
int totalLives = startLives;
|
|
|
|
if (totalImpulses > 0)
|
|
{
|
|
int additionalImpulses = totalImpulses - 1;
|
|
totalLives = startLives + (additionalImpulses * livesIncrement);
|
|
}
|
|
|
|
livesText.text = string.Format(livesString, totalLives);
|
|
}
|
|
}
|
|
} |