/// <summary> /// 创建图书列表 /// </summary> /// <param name="listData"></param> public void CreateBookList(List <ItemsInfoBean> listData) { CptUtil.RemoveChildsByActive(objBookItemContainer); if (CheckUtil.ListIsNull(listData)) { tvNull.gameObject.SetActive(true); return; } else { tvNull.gameObject.SetActive(false); } for (int i = 0; i < listData.Count; i++) { ItemsInfoBean itemData = listData[i]; if (!listBook.Contains(itemData.id)) { continue; } GameObject objItem = Instantiate(objBookItemContainer, objBookItemModel); ItemBaseTextCpt itemBaseText = objItem.GetComponent <ItemBaseTextCpt>(); PopupItemsButton infoItemsPopup = objItem.GetComponent <PopupItemsButton>(); Sprite spIcon = IconDataHandler.Instance.manager.GetIconSpriteByName(itemData.icon_key); itemBaseText.SetData(spIcon, itemData.name, ""); infoItemsPopup.SetData(itemData, spIcon); } }
/// <summary> /// 设置弹出框内容 /// </summary> /// <param name="itemsInfo"></param> public void SetPopupData(ItemsInfoBean itemsInfo) { if (infoItemsPopup != null) { infoItemsPopup.SetData(itemsInfo, ivIcon.sprite); } }
/// <summary> /// 设置奖励 /// </summary> /// <param name="listReward"></param> public void SetReward(List <RewardTypeBean> listReward) { foreach (RewardTypeBean itemReward in listReward) { GameObject objReward = Instantiate(objRewardContainer, objRewardModel); Image ivIcon = CptUtil.GetCptInChildrenByName <Image>(objReward, "Icon"); Text tvNumber = CptUtil.GetCptInChildrenByName <Text>(objReward, "Text"); RewardTypeEnumTools.GetRewardDetails(itemReward); ivIcon.sprite = itemReward.spRewardIcon; tvNumber.text = "x" + itemReward.rewardNumber; if (itemReward.dataType == RewardTypeEnum.AddItems) { PopupItemsButton infoItemsPopup = objReward.GetComponent <PopupItemsButton>(); ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(itemReward.rewardId); infoItemsPopup.SetData(itemsInfo, itemReward.spRewardIcon); } } }
/// <summary> /// 设置数据 /// </summary> /// <param name="infoBean"></param> /// <param name="itemBean"></param> public void SetData(ItemsInfoBean infoBean, ItemBean itemBean) { this.itemsInfoData = infoBean; this.itemBean = itemBean; if (infoBean != null) { SetName(infoBean.name); } else { SetName(""); } SetIcon(infoBean); if (itemBean != null) { SetNumber(itemBean.itemNumber); } else { SetNumber(0); } infoItemsPopup.SetData(itemsInfoData, ivIcon.sprite); }