using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class OSGalaGiftCell : CellView { [SerializeField] Text nameText; [SerializeField] ItemCell[] itemCells; [SerializeField] Button buyBtn; [SerializeField] Text moneyText; [SerializeField] Image moneyIcon; [SerializeField] Transform saleOutRect; [SerializeField] Image redImg; [SerializeField] Text buyLimitText; [SerializeField] Image maskImg; public void Display(int index) { var id = OSActivityManager.Instance.osGalaGiftSortList[index]; if (id > 100000000) { //充值 id -= 100000000; var ctgConfig = CTGConfig.Get(id); nameText.text = ctgConfig.Title; for (int i = 0; i < itemCells.Length; i++) { var itemCell = itemCells[i]; if (i < ctgConfig.GainItemList.Length) { itemCell.SetActive(true); int itemID = ctgConfig.GainItemList[i][0]; itemCell.Init(new ItemCellModel(itemID, true, ctgConfig.GainItemList[i][1])); itemCell.button.SetListener(() => ItemTipUtility.Show(itemID)); } else { itemCell.SetActive(false); } } RechargeManager.Instance.TryGetRechargeCount(id, out var rechargeCount); var limitCnt = ctgConfig.DailyBuyCount; if (rechargeCount.todayCount < limitCnt) { saleOutRect.SetActive(false); maskImg.SetActive(false); buyBtn.SetActive(true); buyBtn.SetListener(() => { if (!OSActivityManager.Instance.IsOpenedOSGala(false)) { SysNotifyMgr.Instance.ShowTip("ActivityOver"); return; } RechargeManager.Instance.CTG(id); }); RechargeManager.Instance.TryGetOrderInfo(id, out var orderInfo); moneyText.text = Language.Get("PayMoneyNum", orderInfo.PayRMBNumOnSale); moneyIcon.SetActive(false); } else { saleOutRect.SetActive(true); maskImg.SetActive(true); buyBtn.SetActive(false); } buyLimitText.text = Language.Get("storename6", limitCnt - rechargeCount.todayCount, limitCnt); redImg.SetActive(false); } else { //商店 var storeConfig = StoreConfig.Get(id); nameText.text = storeConfig.Name; var awards = StoreModel.Instance.GetShopItemlistEx(storeConfig); for (int i = 0; i < itemCells.Length; i++) { var itemCell = itemCells[i]; if (i < awards.Count) { itemCell.SetActive(true); int itemID = awards[i][0]; itemCell.Init(new ItemCellModel(itemID, true, awards[i][1])); itemCell.button.SetListener(() => ItemTipUtility.Show(itemID)); } else { itemCell.SetActive(false); } } var state = StoreModel.Instance.GetShopIDState(id); if (state == 1) { saleOutRect.SetActive(true); maskImg.SetActive(true); buyBtn.SetActive(false); redImg.SetActive(false); } else { saleOutRect.SetActive(false); maskImg.SetActive(false); buyBtn.SetActive(true); buyBtn.SetListener(() => { if (!OSActivityManager.Instance.IsOpenedOSGala(false)) { SysNotifyMgr.Instance.ShowTip("ActivityOver"); return; } StoreModel.Instance.SendBuyShopItemWithPopCheck(storeConfig, 1); }); moneyText.text = storeConfig.MoneyNum == 0 ? Language.Get("L1127") : storeConfig.MoneyNum.ToString(); moneyIcon.SetActive(storeConfig.MoneyNum != 0); moneyIcon.SetIconWithMoneyType(storeConfig.MoneyType); redImg.SetActive(storeConfig.MoneyNum == 0); } var buyCnt = StoreModel.Instance.GetShopLimitBuyCount(id); buyLimitText.text = Language.Get("storename6", storeConfig.LimitCnt - buyCnt, storeConfig.LimitCnt); } } }