- Added PaymentManager integration with GameManager - Implemented credit-based lives increment system - Updated UI layout and anchor positions in MainMenu scene - Added AddCredit input action bindings for keyboard and gamepad - Refactored GameManager to use StartingLives, MaxLives properties - Added UICreditsTextController for displaying credits and lives- Fixed prefab initialization order and component dependencies - Updated ComWrapper serialization and prize checking logic - Removed obsolete setLivesToDefaultAfterFirstLose setting - Improved scene loading and player spawn management
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System;
|
||
using RR.Common.Managers;
|
||
using RR.Game2D.Core.Managers;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
|
||
public class UICreditsTextController : MonoBehaviour
|
||
{
|
||
// UI elements
|
||
[SerializeField] private TextMeshProUGUI creditsText;
|
||
[SerializeField] private TextMeshProUGUI livesText;
|
||
|
||
// Strings to display
|
||
[SerializeField] private string creditsString = "У вас {0} кредитов";
|
||
[SerializeField] private string livesString = "У вас будет {0}";
|
||
|
||
private void Start()
|
||
{
|
||
UpdateCreditsText(0);
|
||
UpdateLivesText(0);
|
||
|
||
// Subscribe to events
|
||
PaymentManager.Instance?.OnCreditsChanged.AddListener(UpdateCreditsText);
|
||
PaymentManager.Instance?.OnCreditsChanged.AddListener(UpdateLivesText);
|
||
}
|
||
|
||
private void UpdateCreditsText(int creditsCount)
|
||
{
|
||
creditsText.text = string.Format(creditsString, creditsCount);
|
||
}
|
||
|
||
private void UpdateLivesText(int creditsCount)
|
||
{
|
||
int totalLives = creditsCount > 1 ?
|
||
GameManager.Instance.StartingLives + GameManager.Instance.LivesIncrement * (creditsCount - 1) :
|
||
GameManager.Instance.StartingLives;
|
||
livesText.text = string.Format(livesString, totalLives);
|
||
}
|
||
}
|