chip-game/Assets/Scripts/GameModePriceApplicator.cs
2026-01-12 09:36:17 +03:00

61 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class GameModePriceApplicator : MonoBehaviour
{
public TextMeshProUGUI label;
public string prefix = "?";
public string GameModePriceKey = "?";
public string ValutaNameKey = "ValutaName";
private void OnEnable()
{
RefreshUI();
SettingsManager.OnSettingsChanged.AddListener(RefreshUI);
}
private void OnDisable()
{
SettingsManager.OnSettingsChanged.RemoveListener(RefreshUI);
}
private void RefreshUI()
{
if (label == null)
{
Debug.LogError("Лэйбл не установлен", this);
return;
}
//тут надо на фриплей проверять
if(SettingsManager.GetBool("Freeplay", false))
{//бесплатная игра
label.color = new Vector4(1,1,1,0);
}
else
{//платная игра
label.color = new Vector4(1, 1, 1, 1);
}
int price = PlayerPrefs.GetInt(GameModePriceKey, 10);
string valutaName = PlayerPrefs.GetString(ValutaNameKey, "руб.");
if (price == 0)
{
label.text = $"{prefix} БЕСПЛАТНО";
}
else
{
label.text = $"{prefix} {price} {valutaName}";
}
}
}