44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System.Collections;
|
|
using asap.core;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class EventLuckMagicSkipAnimationBtn : MonoBehaviour
|
|
{
|
|
private bool _doesSkip;
|
|
[SerializeField] private Button btn;
|
|
[SerializeField] private GameObject mark;
|
|
private float _clickInterval = 0.3f;
|
|
private void Start()
|
|
{
|
|
btn.onClick.AddListener(OnClick);
|
|
}
|
|
public void Init()
|
|
{
|
|
UpdateState();
|
|
}
|
|
|
|
private void UpdateState()
|
|
{
|
|
var model = GContext.container.Resolve<EventLuckMagicModel>();
|
|
_doesSkip = model.DoesSkipAnimation;
|
|
mark.SetActive(_doesSkip);
|
|
}
|
|
|
|
private void OnClick()
|
|
{
|
|
var model = GContext.container.Resolve<EventLuckMagicModel>();
|
|
model.DoesSkipAnimation = !model.DoesSkipAnimation;
|
|
UpdateState();
|
|
btn.interactable = false;
|
|
StopAllCoroutines();
|
|
StartCoroutine(ResetCountDown());
|
|
}
|
|
|
|
private IEnumerator ResetCountDown()
|
|
{
|
|
yield return new WaitForSeconds(_clickInterval);
|
|
btn.interactable = true;
|
|
}
|
|
}
|