// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2022-02-14 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { partial class WomanWindow { class GiftBagInfo : KUIWidget { #region Fide #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] KUIList __listRewards; [KUIFlag] TextMeshProUGUI _tmpDescription; [KUIFlag] Button _btnReceive; [KUIFlag] TextMeshProUGUI _tmpPrice; [KUIFlag] GameObject _goImageIcon; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Mothod public override void Refresh() { if (this.data is ActivitySubInfo subInfo) { var gift = RmbShopProxy.Instance.GetGiftBoxInfo(subInfo.item.typeArgs[0]); _tmpDescription.text = "礼包剩余:" + (TimeProxy.Instance.GetTimes(gift.item.timeId)); if (TimeProxy.Instance.GetTimes(gift.item.timeId) >0) { if (gift.id == 2000) { _goImageIcon.SetActive(false); _tmpPrice.text = "免费"; } else { _goImageIcon.SetActive(true); _tmpPrice.text = gift.rmbPrice.ToString(); } _tmpDescription.color = Color.white; _btnReceive.interactable = true; } else { _goImageIcon.SetActive(false); _tmpPrice.text = "已购买"; _tmpDescription.color = new Color32(255, 182, 91, 255); _btnReceive.interactable =false; } __listRewards.Clear(); foreach (var itemInfo in gift.exchanges) { __listRewards.GetItem().SetItem(itemInfo); } } } private void OnReceiveBtnClick() //购买礼包 { if (this.data is ActivitySubInfo subInfo) { WomenActivity.Instance.BuyGift(subInfo.item.typeArgs[0], (error, message) => { if (error ==0) { GetWindow().RefreshGiftBagPanle(); //根据到时是否需要,暂测试使用 PostNotification(GlobalDefine.EVENT_MONEY_CHANGED, "Exchange", "Women_w_Btn"); } }); } } #endregion #region Unity private void Awake() { SetViewData(); _btnReceive.onClick.AddListener(this.OnReceiveBtnClick); __listRewards.AddTemplate(true); } #endregion } class GiftBag : KUIWidget { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] TextMeshProUGUI _tmpPropNumber; [KUIFlag] KUIList __listGifts; [KUIFlag] TextMeshProUGUI _tmpTime3; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null #endregion #region Method public void RefreshView() { var propCount = ItemProxy.Instance.GetPropCount(3000); _tmpPropNumber.text = propCount.ToString(); __listGifts.Clear(); var subInfos = WomenActivity.Instance.giftBoxActivityInfo.subInfos; foreach (var subInfo in subInfos)//将未购买过的礼包添加进去 { var gift = RmbShopProxy.Instance.GetGiftBoxInfo(subInfo.item.typeArgs[0]); if (TimeProxy.Instance.GetTimes(gift.item.timeId) > 0) __listGifts.GetItem().SetData(subInfo); } foreach (var subInfo in subInfos)//将已购买过的礼包添加进去 { var gift = RmbShopProxy.Instance.GetGiftBoxInfo(subInfo.item.typeArgs[0]); if (TimeProxy.Instance.GetTimes(gift.item.timeId) <= 0) __listGifts.GetItem().SetData(subInfo); } } public void RefreshTimer()//刷新时间 { _tmpTime3.text = WomenActivity.Instance.sigeInSurplusTime; } #endregion #region Unity private void Awake() { SetViewData(); __listGifts.AddTemplate(true); } private void OnEnable() { RefreshView(); } #endregion } } }