using UnityEngine; using TMPro; using IVDataFormat; using System.Collections.Generic; public class IVPpGoods : MonoBehaviour { protected RectTransform rtrfSelf; protected TextMeshProUGUI txtTitle; protected GoodsNameItem[] goodsNameItems; protected System.Action actionBtnYes; public bool IsOpen() { return gameObject.activeSelf; } public void Init() { rtrfSelf = GetComponent(); txtTitle = rtrfSelf.Find("titlebg").transform.Find("txtTitle").GetComponent(); goodsNameItems = rtrfSelf.Find("wrapper").GetComponentsInChildren(true); } public void Open(IList goods, System.Action actionyes = null, string strtitle = null, float ftime = 0f) { CancelInvoke(nameof(Close)); if (string.IsNullOrEmpty(strtitle)) strtitle = LocalizationText.GetText(Global.STR_REWARDGET); txtTitle.text = strtitle; actionBtnYes = actionyes; if (goods.Count <= 11) { Vector2 v2size = rtrfSelf.sizeDelta; v2size.y = 200f; rtrfSelf.sizeDelta = v2size; GameUIMgr.SetLineSML(1); } else if (goods.Count <= 22) { Vector2 v2size = rtrfSelf.sizeDelta; v2size.y = 340f; rtrfSelf.sizeDelta = v2size; GameUIMgr.SetLineSML(2); } else { Vector2 v2size = rtrfSelf.sizeDelta; v2size.y = 480f; rtrfSelf.sizeDelta = v2size; GameUIMgr.SetLineSML(3); } for (int i = 0; i < goodsNameItems.Length; i++) { if (i >= goods.Count) { goodsNameItems[i].gameObject.SetActive(false); continue; } goodsNameItems[i].SetData(goods[i]); goodsNameItems[i].gameObject.SetActive(true); } gameObject.SetActive(true); if (ftime > 0f) Invoke(nameof(Close), ftime); } protected void Close() { GameUIMgr.SOnClosePopup(); gameObject.SetActive(false); } public void BtnYesPressed() { CancelInvoke(nameof(Close)); GameUIMgr.SOnClosePopup(); gameObject.SetActive(false); for (int i = 0; i < goodsNameItems.Length; i++) { goodsNameItems[i].ReleaseData(); } if (actionBtnYes != null) actionBtnYes.Invoke(); } }