| New file |
| | |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public abstract class OSRankGiftBaseCell : CellView |
| | | { |
| | | [SerializeField] protected ImageEx vipImage; |
| | | [SerializeField] protected TextEx vipText; |
| | | [SerializeField] protected OutlineEx vipTextOutline; |
| | | [SerializeField] protected ImageEx rateImage; |
| | | [SerializeField] protected TextEx rateText; |
| | | [SerializeField] protected Text nameText; |
| | | [SerializeField] protected ItemCell[] itemCells; |
| | | [SerializeField] protected Button buyBtn; |
| | | [SerializeField] protected Text moneyText; |
| | | [SerializeField] protected Image moneyIcon; |
| | | [SerializeField] protected Transform saleOutRect; |
| | | [SerializeField] protected Image redImg; |
| | | [SerializeField] protected Text buyLimitText; |
| | | [SerializeField] protected Image maskImg; |
| | | |
| | | // 由子类实现:获取礼包ID |
| | | protected abstract int GetGiftId(int index); |
| | | // 由子类实现:获取验证活动是否结束所需的活动FuncID |
| | | protected abstract int GetActivityFuncId(); |
| | | |
| | | public void Display(int index) |
| | | { |
| | | var id = GetGiftId(index); |
| | | if (id > 100000000) |
| | | { |
| | | // 充值礼包 |
| | | id -= 100000000; |
| | | var ctgConfig = CTGConfig.Get(id); |
| | | nameText.text = ctgConfig.Title; |
| | | |
| | | vipImage.SetActive(ctgConfig.VipLevel > 0); |
| | | if (ctgConfig.VipLevel > 0) |
| | | { |
| | | vipImage.SetSprite($"VipLevel{ctgConfig.VipLevel}"); |
| | | vipText.text = Language.Get($"VipLevelInfo{ctgConfig.VipLevel}"); |
| | | vipText.color = InvestModel.Instance.GetTextColor(ctgConfig.VipLevel); |
| | | vipTextOutline.OutlineColor = InvestModel.Instance.GetOutlineColor(ctgConfig.VipLevel); |
| | | } |
| | | |
| | | rateImage.SetActive(true); |
| | | rateText.text = Language.Get("DailySpecials07", ctgConfig.Percentage); |
| | | 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.IsOpened(GetActivityFuncId(), false)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("ActivityOver"); |
| | | return; |
| | | } |
| | | |
| | | if (ctgConfig.VipLevel > 0 && !FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.PrivilegeCard)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("MinggeAuto8"); |
| | | return; |
| | | } |
| | | if (ctgConfig.VipLevel == 1 && !InvestModel.Instance.IsInvested(InvestModel.monthCardType)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("MinggeAuto5"); |
| | | UIManager.Instance.OpenWindow<PrivilegeCardWin>(); |
| | | return; |
| | | } |
| | | if (ctgConfig.VipLevel == 2 && !InvestModel.Instance.IsInvested(InvestModel.foreverCardType)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("MinggeAuto7"); |
| | | UIManager.Instance.OpenWindow<PrivilegeCardWin>(); |
| | | return; |
| | | } |
| | | |
| | | RechargeManager.Instance.CTG(id); |
| | | }); |
| | | |
| | | RechargeManager.Instance.TryGetOrderInfo(id, out var orderInfo); |
| | | |
| | | moneyText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(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 |
| | | { |
| | | rateImage.SetActive(false); |
| | | vipImage.SetActive(false); |
| | | // 商店物品 |
| | | 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.IsOpened(GetActivityFuncId(), 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); |
| | | if (storeConfig.MoneyType <= 0) |
| | | { |
| | | moneyIcon.SetItemSprite(storeConfig.CostItemID); |
| | | } |
| | | else |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | } |