using asap.core; using cfg; using game; using Game; using GameCore; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class RewardNormal1 : RewardPopupBase { public RewardNormal reward; public Button btn_next; public Button btn_all; public RewardItemNew rewardNew; public RewardItemNew rewardNewShow; public TMP_Text text_title; public GameObject[] _lights; public float showTime = 0.3f; int curIndex; int allCount; List itemDatas; ItemData curItemData; bool isClose; bool isClickClose; bool text_title_restore = false; private void Start() { btn_next.onClick.AddListener(OnClickNext); btn_all.onClick.AddListener(OnClickAll); } public void InitRestore(List dropItems) { text_title_restore = true; text_title.text = LocalizationMgr.GetText("UI_RewardPopupPanel_9"); Init(dropItems); } public void InitAsync(List itemDatas) { text_title_restore = false; text_title.text = LocalizationMgr.GetText("UI_FishingRewardPanel_101002"); Init(itemDatas); } public void Init(List itemDatas) { this.itemDatas = itemDatas; InitResource(itemDatas); allCount = itemDatas.Count; curIndex = 0; SetData(); } async void SetData() { int audioName = curIndex % 4 + 1; GContext.Publish(new EventUISound($"audio_ui_getreward_{audioName}")); isClickClose = false; isClose = false; curItemData = itemDatas[curIndex]; rewardNew.SetData(curItemData); rewardNew.PlayOpen("reward_common1_open"); float showCount = curItemData.count; ItemShow itemShow = GContext.container.Resolve().TbItemShow.GetOrDefault(curItemData.id); int light_index = 1; if (itemShow != null) { light_index = 0; if (itemShow.Id == 1002) { showCount = (showCount / GContext.container.Resolve().ExtraCoinMag()); } for (int i = itemShow.Count.Count - 1; i >= 0; i--) { if (showCount > itemShow.Count[i]) { light_index = i + 1; break; } } } if (light_index >= _lights.Length) { light_index = _lights.Length - 1; } for (int i = 0; i < _lights.Length; i++) { _lights[i].SetActive(i == light_index); } receive.SetActive(false); receive.SetActive(true); curIndex++; if (curIndex >= allCount) { btn_all.gameObject.SetActive(false); } //if (curItemData.id == 1001 || curItemData.id == 1002 || curItemData.id == 1005) //{ await Awaiters.Seconds(showTime); rewardNewShow.SetData(curItemData, false); await rewardNewShow.ParticleAttractor(true); if (isClickClose) { GContext.Publish(new ShowData(RewardType.Destroy)); } //} isClose = true; } void OnClickNext() { if (curIndex >= allCount) { receive.SetActive(false); if (isClose) { GContext.Publish(new ShowData(RewardType.Destroy)); } else { isClickClose = true; } return; } SetData(); } void OnClickAll() { gameObject.SetActive(false); reward.gameObject.SetActive(true); var allItemDatas = new List(); for (int i = curIndex; i < allCount; i++) { allItemDatas.Add(itemDatas[i]); } if (text_title_restore) { reward.InitRestore(allItemDatas); } else { reward.InitAsync(allItemDatas, null); } } }