using System.Collections.Generic; using asap.core; using UnityEngine; using OfferStoryChain; using UnityEngine.UI; using GameCore; using UniRx; public class OfferStoryChainEntranceButton : EventButtonResource { [SerializeField] private Button button; [SerializeField] private BingoTimer timer; [SerializeField] private Image icon; private ILoadResourceService _loadResourceService; private void Awake() { var manager = GContext.container.Resolve(); if (manager == null || !manager.IsActive) { gameObject.SetActive(false); return; } var timerCtx = manager.GetTimerData(); timerCtx.OnExpire = () => { gameObject.SetActive(false); }; timer.Init(timerCtx); _loadResourceService = GContext.container.Resolve(); button.onClick.AddListener(OnClickOpen); CheckResource(new List() { UITypes.OfferStoryChainPanel.Path, manager.GetEntrancIconUrl() }); } private async void OnClickOpen() { try { var manager = GContext.container.Resolve(); bool isReady = await _loadResourceService.Loads(new List() { UITypes.OfferStoryChainPanel.Path, manager.GetEntrancIconUrl() }); if (isReady) { await UIManager.Instance.ShowUINotLoading(UITypes.OfferStoryChainPanel); } } catch (System.Exception ex) { Debug.LogError(ex); } } protected override void OnLoadEventResource() { var manager = GContext.container.Resolve(); if (manager != null && manager.IsActive) { GContext.container.Resolve().SetImageSprite(icon, manager.GetEntrancIconUrl()); gameObject.SetActive(true); manager.EventAggregator .GetEvent() .Subscribe(_ => gameObject.SetActive(manager.IsActive)) .AddTo(this); RedPointManager.Instance.SetRedPointState(Manager.RedPointKey, manager.DoNeedRedPoint); var faceUiService = GContext.container.Resolve(); faceUiService?.AddGiftFaceUI(manager.EventId, UITypes.OfferStoryChainPanel); } } }