using IVDataFormat; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// This is the view of our cell which handles how the cell looks. /// public class EScrEventRaise : EScrCell { private GameObject[] goItems, soldOut; private Image[] imgIcons; private TextMeshProUGUI[] txtNames, txtAvails, txtCounts, txtLefts; public override void InitCell() { Transform trfself = transform; int ilen = trfself.childCount; goItems = new GameObject[ilen]; imgIcons = new Image[ilen]; txtNames = new TextMeshProUGUI[ilen]; txtAvails = new TextMeshProUGUI[ilen]; txtCounts = new TextMeshProUGUI[ilen]; txtLefts = new TextMeshProUGUI[ilen]; soldOut = new GameObject[ilen]; for (int i = 0; i < ilen; i++) { Transform trfchild = trfself.GetChild(i); goItems[i] = trfchild.gameObject; imgIcons[i] = trfchild.Find("icon").GetComponent(); txtNames[i] = trfchild.Find("txtName").GetComponent(); txtAvails[i] = trfchild.Find("txtAvail").GetComponent(); txtCounts[i] = trfchild.Find("txtCount").GetComponent(); txtLefts[i] = trfchild.Find("txtLeft").GetComponent(); soldOut[i] = trfchild.Find("EventRaise").gameObject; } } public override void RefreshCellView() { SetData(itemID); } public override void SetData(int itemid) { itemID = itemid; for (int i = 0; i < goItems.Length; i++) { // 이벤트 매니저에서 뽑기 가능한 보상을 행번호(itemid)와 열번호(i)로 가져옴. int rewindex = EventMgr.SGetRaiseRewardIndex(itemid, i); if (rewindex < 0) { goItems[i].gameObject.SetActive(false); continue; } nGoods reward = EventMgr.SGetRaiseReward(rewindex); imgIcons[i].sprite = AddressableMgr.GetIcon(reward.propertyType, reward.propertyId); txtNames[i].text = FormatString.GetGoodsName(reward.propertyType, reward.propertyId); txtCounts[i].text = reward.propertyCount.ToString(); txtAvails[i].gameObject.SetActive(false); int buyGoods = 0; for (int j = DataHandler.GetSysEventRaise().rewards.Length; j > 0; j--) { if (DataHandler.GetPlayEventRaise().rewards[j - 1].sid == DataHandler.GetSysEventRaise().rewards[rewindex].id) { buyGoods = DataHandler.GetPlayEventRaise().rewards[j - 1].cnt; break; } } txtLefts[i].text = FormatString.StringFormat(LocalizationText.GetText("even_left_goods_count"), DataHandler.GetSysEventRaise().rewards[rewindex].cnt - buyGoods, DataHandler.GetSysEventRaise().rewards[rewindex].cnt); if(DataHandler.GetSysEventRaise().rewards[rewindex].cnt - buyGoods <= 0) { soldOut[i].SetActive(true); } else { soldOut[i].SetActive(false); } goItems[i].gameObject.SetActive(true); } } public void OnBtnSelect(int ichildindex) { BagMgr.SSelectConsume(itemID, ichildindex); } }