62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PaymentUI : MonoBehaviour
|
|
{
|
|
[SerializeField] private PaymentGate paymentGate;
|
|
[SerializeField] private RectTransform GameModesRoot;
|
|
[SerializeField] private GameObject GameModeViewPrefab;
|
|
[SerializeField] private RectTransform Pointer;
|
|
|
|
private List<GameModeView> views;
|
|
private GameModeView selectedView;
|
|
|
|
public event Action<GameMode> GamemodeChosen;
|
|
|
|
public void Initialize(Dictionary<GameMode, bool> gameModeAccesses)
|
|
{
|
|
Generate(gameModeAccesses);
|
|
selectedView = views[0];
|
|
}
|
|
|
|
public void Next()
|
|
{
|
|
print("next");
|
|
}
|
|
|
|
public void Previous()
|
|
{
|
|
print("previous");
|
|
}
|
|
|
|
public void Choose()
|
|
{
|
|
GamemodeChosen?.Invoke(selectedView.CachedGameMode);
|
|
}
|
|
|
|
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);
|
|
views.Add(view);
|
|
}
|
|
else
|
|
Debug.LogWarning($"Префаб не настроен или не содержит компонент GameModeView", this);
|
|
}
|
|
}
|
|
public void Refresh()
|
|
{
|
|
foreach(var view in views)
|
|
{
|
|
view.Refresh();
|
|
}
|
|
}
|
|
}
|