using DG.Tweening; using PrizeSystem; using System; using UnityEngine; using UnityEngine.UI; public class PrizeButton : MSignalButton { public event Action OnPrize; private PrizeType _prizeType; [SerializeField] private RectTransform _pointer; public virtual void SetSelected(bool selected) => _pointer.gameObject.SetActive(selected); public override void ClickAnimation() { StopAnimation(); _animation = DOTween.Sequence(); _animation.Append(_image.DOColor(_pressedColor, 0.15f)); _animation.Append(_image.DOColor(_selectedColor, 0.15f)); _animation.AppendCallback(() => { OnPrize?.Invoke(_prizeType); SoundManager.instance.PlaySfx(_clip); }); _animation.PlayForward(); } public void Configure(PrizeType prizeType) { _prizeType = prizeType; _image.sprite = PrizeSystemManager.GetPrizeIcon(prizeType); _textMeshPro.text = GetText(prizeType); } public void Configure(Prize prize) { _prizeType = prize.PrizeType; _image.sprite = PrizeSystemManager.GetPrizeIcon(prize.PrizeType); _textMeshPro.text = PrizeView.GetPrizeText(prize); } private string GetText(PrizeType prizeType) => prizeType switch { PrizeType.Hopper => "Добавить хоппер", PrizeType.Marbles => "Добавить марблс", PrizeType.Ticket => "Добавить тикет", PrizeType.Qr => "Добавить QR", PrizeType.VitrinaBox => "Добавить витрину", _ => "ошибка" }; }