54 lines
1.5 KiB
C#
54 lines
1.5 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.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 => "Добавить витрину",
|
|
_ => "ошибка"
|
|
};
|
|
|
|
}
|