using System; using game; using UnityEngine; using UnityEngine.UI; namespace RND { public class ConfirmationWindow : Window { public event Action OnHaveResult; [SerializeField] private Button closeButton; [SerializeField] private Button buyButton; [SerializeField] private Image image; [SerializeField] private Text priceText; private ConfBaseShopItem _itemToBuy; public override int ZOrder => -6; private void Start() { buyButton.onClick.AddListener(() => BuyButtonClick()); closeButton.onClick.AddListener(() => CloseButtonClick()); } public void SetItemForBuy(ConfBaseShopItem item) { _itemToBuy = item; UpdateView(); } private void BuyButtonClick() { OnHaveResult?.Invoke(_itemToBuy, EnumClickResult.Purchased); Close(); } private void UpdateView() { priceText.text = _itemToBuy.price.ToString(); image.sprite = Assets.Create(_itemToBuy.openPreviewIcon); } private void CloseButtonClick() { OnHaveResult?.Invoke(_itemToBuy, EnumClickResult.None); Close(); } } }