59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PaymentUI : MonoBehaviour
|
|
{
|
|
[SerializeField] PaymentGate paymentGate;
|
|
[SerializeField] private RectTransform GameModesRoot;
|
|
[SerializeField] private GameObject GameModeViewPrefab;
|
|
|
|
private bool initialized = false;
|
|
private List<GameModeView> views;
|
|
|
|
public void Initialize(Dictionary<GameMode, bool> gameModeAccesses)
|
|
{
|
|
Generate(gameModeAccesses);
|
|
initialized = true;
|
|
}
|
|
|
|
public void Next()
|
|
{
|
|
print("next");
|
|
}
|
|
|
|
public void Previous()
|
|
{
|
|
print("previous");
|
|
}
|
|
|
|
public void Choose()
|
|
{
|
|
print("choose");
|
|
}
|
|
|
|
private void Generate(Dictionary<GameMode, bool> gameModeAccesses)
|
|
{
|
|
views = new List<GameModeView>();
|
|
foreach (var gameModeAccess in gameModeAccesses)
|
|
{
|
|
var go = Instantiate(GameModeViewPrefab, GameModesRoot);
|
|
|
|
if(go.TryGetComponent<GameModeView>(out var view))
|
|
{
|
|
view.Setup(gameModeAccess.Key, gameModeAccess.Value);
|
|
views.Add(view);
|
|
}
|
|
else
|
|
Debug.LogWarning($"Префаб не настроен или не содержит компонент GameModeView", this);
|
|
}
|
|
}
|
|
public void Refresh()
|
|
{
|
|
foreach(var view in views)
|
|
{
|
|
view.Refresh();
|
|
}
|
|
}
|
|
|
|
}
|