46 lines
1.2 KiB
C#

using DG.Tweening;
using PrizeSystem;
using System;
using UnityEngine.UI;
public class PrizeButton : MSignalButton
{
public event Action<PrizeType> OnPrize;
private PrizeType _prizeType;
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.playClip(_clip);
});
_animation.PlayForward();
}
public void Configure(PrizeType prizeType)
{
_prizeType = prizeType;
_image.sprite = PrizeSystemManager.GetPrizeIcon(prizeType);
_textMeshPro.text = GetText(prizeType);
}
private string GetText(PrizeType prizeType)
=> prizeType switch
{
PrizeType.Hopper => "Добавить хоппер",
PrizeType.Marbles => "Добавить марблс",
PrizeType.Ticket => "Добавить тикет",
PrizeType.Qr => "Добавить QR",
PrizeType.VitrinaBox => "Добавить витрину",
_ => "ошибка"
};
}