PuzzleGame/PuzzleGameProject/Assets/Scripts/UI/ChestPopUpController.cs
2025-02-27 15:52:40 +01:00

46 lines
1.2 KiB
C#

using System;
using UnityEngine;
using UnityEngine.UIElements;
namespace UI
{
public class ChestPopUpController : MonoBehaviour
{
public event Action BlackDieSelected;
public event Action KeySelected;
public event Action ArmorAndDiamondSelected;
private Button _blackDie;
private Button _key;
private Button _armorAndDiamond;
private void OnEnable()
{
VisualElement root = GetComponent<UIDocument>().rootVisualElement;
_blackDie = root.Q<Button>("BlackDie");
_blackDie.clicked += () => BlackDieSelected?.Invoke();
_key = root.Q<Button>("Key");
_key.clicked += () => KeySelected?.Invoke();
_armorAndDiamond = root.Q<Button>("ArmorAndDiamond");
_armorAndDiamond.clicked += () => ArmorAndDiamondSelected?.Invoke();
}
public void DisableBlackDie()
{
_blackDie.SetEnabled(false);
}
public void DisableKey()
{
_key.SetEnabled(false);
}
public void DisableArmorAndDiamond()
{
_armorAndDiamond.SetEnabled(false);
}
}
}