local UIGachaShop = UIViewClass() local HeroPicPath = ConstAssetPathConfig.HeroPicPath local UIHeroLightEffectTool = require "View/Common/UIHeroLightEffectTool" local PADScreenRatio = 1.4 local NormalScaleSize = 1.2 local PADScreenScaleSize = 1.4 local HERO_RENDER_ID = 1000001 local BattelLight = ConstAssetPathConfig.LightLeft local EternalTabID = 301 local ColumnCount = 4 ----------------------------- 系统函数 ------------------------------ function UIGachaShop:OnCreated() self.heroLightEffectDatas = UIHeroLightEffectTool.CreateHeroLightEffectDatas(true) self.heroModelComponentHandle = UTL.UIRender.CreateModelComponentDatas(self.img_Hero) -- 创建handle,别忘记关闭时释放 end function UIGachaShop:OnOpened(context) self:RegistSystemEvent(EventID.UI_GachaShop_Refresh, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_GoldenHero_ActivityEnd, self.ActivityInfoChange) self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.OnDataChanged) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.drawCardType = context.drawCardType self.activityId = context.activityId self.activityType = context.activityType self.drawCardPoolId = context.drawCardPoolId self.drawCardStoreId = context.drawCardStoreId self.heroType = context.heroType local heroId if self.activityType == MDL.OperationActivity.ActivityType.GoldenHero then heroId = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).SynergyBossHeroID elseif self.activityType == MDL.OperationActivity.ActivityType.SuperGold then heroId = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType).HeroID elseif self.activityType == MDL.OperationActivity.ActivityType.GoldHeroReprint then heroId = self.heroType end local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLabelText(self.txt_Name, Const_IDS[heroData.NameIDS]) UTL.UIRender.CreateHeroRenderTexture(self.heroModelComponentHandle, heroId, 0, HERO_RENDER_ID, BattelLight, true) UTL.UIRender.HeroEquipMagicWeapon(self.heroModelComponentHandle, heroId, 0, 15, true, true) local controlInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) local leftTime = controlInfo.endTime - UTL.Time.GetServerTimestamp() -- 时间过大好像会丢失精度 self.txt_LeftTime:SetDHMSStr(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow), "{0}:{1}:{2}", "{0}:{1}", "{0}:{1}") self.txt_LeftTime:ResetAndBeginCustomTimer(false, leftTime, 0, nil) self:OnDataChanged() CTL.Currency.OpenCurrencyPanel(nil, self.currency_Info, DataSheetManager.DrawCardData:GetDataByID(self.drawCardPoolId).Money) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) end function UIGachaShop:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGachaShop:OnDataChanged() local tabID = self.drawCardType == CTL.DrawCard.DrawCardType.Eternal and EternalTabID or self.drawCardStoreId local tabName = MDL.Shop.GetStoreTypeTabName(tabID) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[tabName]) self.goods = {} for _, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.TabID == tabID then local isUnlock = true for _, show in ipairs(v.Show_Table) do if MDL.Unlock.IsComplete(show.ShowCondition, show.ShowConditionParam) == false then isUnlock = false break end end if isUnlock then table.insert(self.goods, v) end end end table.sort(self.goods, MDL.PayMall.SortShowGoods) local lineCount = math.ceil(#self.goods / ColumnCount) local tab = {} for i = 1, lineCount do tab[i] = i end self.loop_Commodity_Gacha:ReloadAll(tab) end function UIGachaShop:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Commodity_Gacha then local endIndex = data * ColumnCount local startIndex = endIndex - (ColumnCount - 1) local index = 1 for i = startIndex, endIndex do local contentItem = cellTable.Content[index] if self.goods[i] then local goodData = self.goods[i] local itemData = DataSheetManager.ItemData:GetDataByID(goodData.ItemID) if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.cell_Good.gameObject) end UIUtils.SetActive(contentItem.img_Selected, false) local isLimit, limitStr = CTL.PayMall.IsLimitedGood(goodData) UIUtils.SetActive(contentItem.group_Limit, isLimit) if goodData.LimitBuyType == LuaConst.LimitBuyType.Forever then contentItem.txt_limit.text = UIUtils.GetLocalizedTxt( Const_IDS.IDS_GoldHeroActivity_Store_LimitBuyHint) .. limitStr else contentItem.txt_limit.text = CTL.PayMall.GetLimitedTitle(goodData, true) .. limitStr end UTL.Item.SetItemCell(contentItem.Item, goodData.ItemID, goodData.ItemNum) local name = UTL.Item.GetItemDataSpliceByType(itemData.ID).Name if itemData.FirstType == LuaConst.ItemType.HeroFragment and itemData.SecondType == LuaConst.ItemHeroType.Hero then name = UTL.Color.FormatQualityText(name, itemData.Color) end contentItem.scrollText_Name:SetText(name) UTL.Item.SetCurrencyImageIcon(contentItem.img_Icon, goodData.MoneyID) local isInDiscount, timeStr, singlePrice = CTL.PayMall.IsInDiscount(goodData) UIUtils.SetLabel(contentItem.txt_cost, singlePrice) UIUtils.SetActive(contentItem.group_SellShort, CTL.PayMall.IsSoldOut(goodData)) UIUtils.SetActive(contentItem.gameObject, true) UTL.Item.SetFormationAndBreakLv(contentItem.Item, goodData.ItemID) else if contentItem then UIUtils.SetActive(contentItem.gameObject, false) else break end end index = index + 1 end end end function UIGachaShop:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Commodity_Gacha then for i, v in ipairs(cellTable.Content) do local goodData = self.goods[index * ColumnCount + i] if v.Item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(goodData.ItemID) break elseif v.btn_Exchange == target then CTL.PayMall.OpenPayMallPopUp(goodData, self.activityId, self.activityType) break end end end end function UIGachaShop:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGachaShop:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() end end function UIGachaShop:OnClosed() UTL.UIRender.DisposeModelComponentData(self.heroModelComponentHandle) -- 释放 UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end ---------------------------------------------------------------------- function UIGachaShop:RefreshPanel() table.sort(self.goods, MDL.PayMall.SortShowGoods) self.loop_Commodity_Gacha:RefreshCells(false) end function UIGachaShop:ActivityInfoChange() if not self.activityType or not self.activityId then return end local info = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) if not CTL.OperationActivity.IsOperationActivityOpen(info) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIGachaExchangePopUp) self:CloseView() return end end return UIGachaShop