local UIGoldenHeroStore = UIViewClass() local EventSystem = require('Event/EventSystem') function UIGoldenHeroStore:OnOpened(context) self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.GoldenHero self.tabUnlockList = {} local heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(self.activityId) local heroTypeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(heroType) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[heroTypeData.StoreName]) self:RegistSystemEvent(EventID.UI_Shop_RefreshShopInfo, self.RefreshStoreTab) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshTabGoods) self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.RefreshStoreTab) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.storeType = MDL.OperationActivity.ActivityBaseData[self.activityType]:GetDataByActivityID(self.activityId).HeroStoreType self:InitStoreTab() CTL.GoldenHeroMain.OpenCurrencyPanel(MDL.GoldenHeroMain.GetHeroTypeByActivityId(self.activityId), self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, title = "IDS_DrawCard_Title_QuickBuy"}) CTL.GoldenHeroMain.SetIsOpenedActivity(self.activityId, true) end function UIGoldenHeroStore:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UIGoldenHeroStore:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGoldenHeroStore:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GoldHeroStore}) end end function UIGoldenHeroStore:RefreshStoreTab() self.loop_StoreTab:RefreshCells() self:RefreshTabGoods() end function UIGoldenHeroStore:InitStoreTab() if self.loop_StoreTab.Count > 0 then self.loop_StoreTab:ClearCells() end for i, v in DataSheetManager.GoldHeroActivityStore[self.storeType]:GetEnumerator() do if MDL.Shop.GetShopTypeInfoByTabID(v.StoreType) then self.loop_StoreTab:AddData(v, 0) end end self.loop_StoreTab:SelectIndex(self.storeId and self.storeId - 1 or 0) end function UIGoldenHeroStore:RefreshTabGoods() local goods = MDL.Shop.GetShopGoodsCfgByTypeID(self.tabId) self.loop_Goods:ReloadAll(goods) end function UIGoldenHeroStore:InitTabGoods() if self.loop_Goods.Count > 0 then self.loop_Goods:ClearCells() end local goods = MDL.Shop.GetShopGoodsCfgByTypeID(self.tabId) for i, v in ipairs(goods) do self.loop_Goods:AddData(v, 0) end end function UIGoldenHeroStore:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_StoreTab then if self.storeId ~= data.StoreID then self.storeId = data.StoreID self.tabId = data.StoreType self:InitTabGoods() end end end local IconNormalScale = 0.6 function UIGoldenHeroStore:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_StoreTab then local name = data.StoreName local UnSelectIcon = data.StorePic local SelectedIcon = data.StorePic_2 UIUtils.SetLabelText(cellTable.lab_UnSelectTab, Const_IDS[name]) UIUtils.SetLabelText(cellTable.lab_SelectedTab, Const_IDS[name]) local isUnlock = CTL.GoldenHeroMain.IsStoreTabUnlock(self.activityId, data.StoreID) cellTable.state_Unlock:SetState(isUnlock and 1 or 0) UIUtils.SetActive(cellTable.btn_SoldOut, CTL.GoldenHeroMain.IsStoreTabSoldOut(data.StoreType)) UIUtils.SetImageByAssetBundle(cellTable.img_Box, UnSelectIcon) UIUtils.SetImageByAssetBundle(cellTable.img_BoxSelected, SelectedIcon) cellTable.img_BoxSelected:SetNativeSize() cellTable.img_Box:SetNativeSize() cellTable.img_BoxSelected.transform:SetLocalScale(IconNormalScale, IconNormalScale) cellTable.img_Box.transform:SetLocalScale(IconNormalScale, IconNormalScale) local oldUnlockState = self.tabUnlockList[index] if oldUnlockState ~= nil and oldUnlockState == false then --如果记录过值,且记录的值是未解锁 if oldUnlockState ~= isUnlock then --如果现在的解锁状态和以前(未解锁时)的不同,说明是现在解锁了 --执行解锁特效的播放 self.SelectedIcon = SelectedIcon self.name = name self.imgBoxTrans = cellTable.img_Box.transform self:StartRepeatFunc(self.DelayAddGoldenHero, 0, 1) end end self.tabUnlockList[index] = isUnlock elseif scrollRect == self.loop_Goods then local goodData = data.OriData UIUtils.SetLabel(cellTable.txt_Name, UTL.Item.GetItemDataSpliceByType(goodData.ItemID).Name) local moneyId = goodData.MoneyID local buyPrice = goodData.BuyPrice if MDL.Currency.GetMoneyCount(moneyId) < buyPrice then cellTable.txt_Cost.text = UTL.Color.FormatRedColor(buyPrice) else cellTable.txt_Cost.text = buyPrice end UTL.Item.MoneyIcon(cellTable.icon_Cost, moneyId) UTL.Item.SetItemCell(cellTable.item, goodData.ItemID, goodData.ItemNum) local canBuy = not CTL.PayMall.IsSoldOut(goodData) UIUtils.SetActive(cellTable.group_SellOut, not canBuy) local isLimit, limitStr = CTL.PayMall.IsLimitedGood(goodData) UIUtils.SetActive(cellTable.group_Limit, isLimit and canBuy) UIUtils.SetActive(cellTable.img_LimitBg, isLimit and canBuy) if isLimit and canBuy then if goodData.LimitBuyType == LuaConst.LimitBuyType.Forever then UIUtils.SetLabelText(cellTable.lab_Limit, Const_IDS.IDS_GoldHeroActivity_Store_LimitBuyHint) else UIUtils.SetLabel(cellTable.lab_Limit, CTL.PayMall.GetLimitedTitle(goodData)) end UIUtils.SetLabel(cellTable.txt_LimitNum, limitStr) end cellTable.state_Rare:SetState(goodData.IsRareItem and 1 or 0) end end function UIGoldenHeroStore:DelayAddGoldenHero() CTL.GoldenHeroMain.AddGoldenHeroDelayFunc(Const_UI_Lua.UIEnum.UIGoldenHeroStore, self.activityId, CTL.GoldenHeroMain.OpenStoreUnlockShow, self.SelectedIcon, self.name, self.imgBoxTrans) end function UIGoldenHeroStore:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Goods then if target == cellTable.btn_Exchange then local goodData = data.OriData local isUnlock, deltaNum = CTL.GoldenHeroMain.IsStoreTabUnlock(self.activityId, self.storeId) if not isUnlock then local storeData = DataSheetManager.GoldHeroActivityStore[self.storeType]:GetDataByStoreID(self.storeId) local itemData = DataSheetManager.ItemData:GetDataByID(storeData.MoneyType) CTL.Tips.AddTipsMsgAndPlaySound(string.FormatByIdsKey("IDS_GoldHeroActivity_Store_LockHint", deltaNum, UIUtils.GetLocalizedTxt(Const_IDS[itemData.Name]))) return end if CTL.PayMall.IsSoldOut(goodData) then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_GoldHeroActivity_Store_WrongHint1) return end if MDL.Currency.GetMoneyCount(goodData.MoneyID) < goodData.BuyPrice then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS.IDS_GoldHeroActivity_Store_WrongHint2) return end local storeData = DataSheetManager.GoldHeroActivityStore[self.storeType]:GetDataByStoreID(self.storeId) if CTL.Currency.IsDragonJadeUsedInJapan(goodData.MoneyID) then --日本消耗龙玉特殊弹窗 UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoreExchange, {activityId = self.activityId, title = storeData.StoreName, itemStoreData = data}, "GoldenHero/GoldenHeroStore/UIGoldenHeroStoreExchange_JP") else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoreExchange, {activityId = self.activityId, title = storeData.StoreName, itemStoreData = data}) end elseif target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.OriData.ItemID) end elseif scrollRect == self.loop_StoreTab then if target == cellTable.img_UnSelectMask or target == cellTable.img_SelectedMask then local isUnlock, deltaNum = CTL.GoldenHeroMain.IsStoreTabUnlock(self.activityId, data.StoreID) local storeData = DataSheetManager.GoldHeroActivityStore[self.storeType]:GetDataByStoreID(self.storeId) local itemData = DataSheetManager.ItemData:GetDataByID(storeData.MoneyType) CTL.Tips.AddTipsMsgAndPlaySound(string.FormatByIdsKey("IDS_GoldHeroActivity_Store_LockHint", deltaNum, UIUtils.GetLocalizedTxt(Const_IDS[itemData.Name]))) end end end function UIGoldenHeroStore:OnFocusChanged(isFocus) if isFocus then CTL.GoldenHeroMain.SetGoldenHeroFocusTarget(Const_UI_Lua.UIEnum.UIGoldenHeroStore, self.activityId) EventSystem.Dispatch(EventID.UI_GoldenHero_FocusOnGoldenHeroView, Const_UI_Lua.UIEnum.UIGoldenHeroStore, self.activityId) else CTL.GoldenHeroMain.SetGoldenHeroFocusTarget(nil, nil) end end return UIGoldenHeroStore