local UIHeroFundPanel = UIViewClass() local HeroHalfCardImagePath = ConstAssetPathConfig.HeroPicPath local VerticalNameImagePath = "UI_NameCard/%s.png" local HERO_TITLE_NAME = "mjzl_msz_01.png" local HERO_LOCAL_TITLE_IDS = "IDS_HeroFund_Title" local Horse_TITLE_NAME = "mjzl_msz_03.png" local Horse_LOCAL_TITLE_IDS = "IDS_HorseFund_Title" local Treasure_TITLE_NAME = "mjzl_msz_02.png" local Treasure_LOCAL_TITLE_IDS = "IDS_TreasureFund_Title" local GoldIngot_TITLE_NAME = "ybzl_msz_02.png" local GoldIngot_LOCAL_TITLE_IDS = "IDS_GoldIngotFund_Title" local GoldIngotRebateAll = DataSheetManager.ConstData:GetDataByID("GoldIngotRebateAll").IntValue function UIHeroFundPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_HeroFund_RefreshPanel, self.RefreshHeroFund) self.type = context.type self:RefreshHeroFund() UIUtils.SetActive(self.group_NewYear, CTL.NewYear.IsInCfgNewYearPeriod()) end function UIHeroFundPanel:RefreshHeroFund() local type = self.type local fundID = MDL.HeroFund.GetFundID(type) local hasFundID = fundID and fundID > 0 --元宝战令没有state_Fund控件控件,无需设置 if type ~= LuaConst.ShowGoldenType.GoldIngot then self.state_Fund:SetState(type - 1) end local needCloseTips local titleName, localTitleIDS --左侧立绘展示 if type == LuaConst.ShowGoldenType.Hero then titleName = HERO_TITLE_NAME localTitleIDS = HERO_LOCAL_TITLE_IDS if hasFundID then self.state_Hero:SetState(0) needCloseTips = true local heroData = DataSheetManager.HeroNum:GetDataByID(fundID) UIUtils.SetImageByAssetBundle(self.img_Hero, string.format(HeroHalfCardImagePath, heroData.HalfCardImage)) UIUtils.SetLabelText(self.txt_HeroName, Const_IDS[heroData.NameIDS]) UTL.Item.SetLocalizationImage(self.loc_HeroName, self.img_HeroName, string.format(VerticalNameImagePath, heroData.HeadImageVertical)) else self.state_Hero:SetState(1) end elseif type == LuaConst.ShowGoldenType.Horse then titleName = Horse_TITLE_NAME localTitleIDS = Horse_LOCAL_TITLE_IDS if hasFundID then self.state_Horse:SetState(0) needCloseTips = true local horseData = DataSheetManager.HorseData:GetDataByHorseID(fundID) UIUtils.SetImageByAssetBundle(self.img_Horse, horseData.HorsePicture) UIUtils.SetLabelText(self.txt_HorseName, Const_IDS[horseData.HorseName]) else self.state_Horse:SetState(1) end elseif type == LuaConst.ShowGoldenType.Treasure then titleName = Treasure_TITLE_NAME localTitleIDS = Treasure_LOCAL_TITLE_IDS if hasFundID then self.state_Treasure:SetState(0) needCloseTips = true local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(fundID) UIUtils.SetImageByAssetBundle(self.img_Treasure, treasureData.TreasurePicture) self.img_Treasure:SetNativeSize() UIUtils.SetLabelText(self.txt_TreasureName, Const_IDS[treasureData.TreasureName]) else self.state_Treasure:SetState(1) end elseif type == LuaConst.ShowGoldenType.GoldIngot then titleName = GoldIngot_TITLE_NAME localTitleIDS = GoldIngot_LOCAL_TITLE_IDS UIUtils.SetLabelText(self.txt_Mark, Const_IDS.IDS_Gift_Rebate) UIUtils.SetLabel(self.txt_MarkNum, string.FormatByIdsId(Const_IDS.IDS_FairTournament_PickRate, GoldIngotRebateAll)) UIUtils.SetLabel(self.txt_Count, string.FormatByIdsId(Const_IDS.IDS_GoldIngotFund_Times3, MDL.HeroFund.GetCurStage(type))) end UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, titleName) self.img_Title:SetNativeSize() if self.txt_Title then UIUtils.SetLabelText(self.txt_Title, Const_IDS[localTitleIDS]) end if needCloseTips then UIManager.CloseView(Const_UI_Lua.UIEnum.UIHeroFundChooseTips) UIManager.CloseView(Const_UI_Lua.UIEnum.UIHeroFundChoosePanel) end --活动倒计时 local seasonData = MDL.HeroFund.GetFundSeasonDataData(type) local offset = UTL.Time.GetServerIntervalTimeByTimeId(seasonData.EndTimeID) self.txt_CountDown:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroFund_Timer), 1) self.txt_CountDown:ResetAndBeginTimer(false, offset) --奖励展示 local typeName = CTL.HeroFund.GetTypeName(type) local threeLineDatas = MDL.HeroFund.GetFundShowData(type) for gear = 1, 3 do UIUtils.SetLabelText(self["lab_Level" .. gear], Const_IDS[string.format("IDS_%sFund_Level" .. gear, typeName)]) UIUtils.SetImageByAssetBundle(self[string.format("img_Level%sIcon", gear)], threeLineDatas[gear].Pic) end local IsGearUnlock2 = MDL.HeroFund.IsGearUnlock(type, 2) local IsGearUnlock3 = MDL.HeroFund.IsGearUnlock(type, 3) UIUtils.SetActive(self.img_Lock2, not IsGearUnlock2) UIUtils.SetActive(self.img_Lock3, not IsGearUnlock3) self.Loop_HeroFund:ClearCells() for i = 1, #threeLineDatas[1].rewardList do self.Loop_HeroFund:AddData({ threeLineDatas[1].rewardList[i], threeLineDatas[2].rewardList[i], threeLineDatas[3].rewardList[i] }, 0) end local minClaimDayIndex = MDL.HeroFund.GetFirstClaimDayIndex(type) if minClaimDayIndex then self.Loop_HeroFund:MoveIndex(minClaimDayIndex - 1) end --底下按钮处理 if IsGearUnlock2 and IsGearUnlock3 then self.btn_Upgrade:SetGray(true) UIUtils.SetLabelText(self.txt_Upgrade, Const_IDS.IDS_HeroFund_AlreadyBuy) else self.btn_Upgrade:SetGray(false) UIUtils.SetLabelText(self.txt_Upgrade, Const_IDS[string.format("IDS_%sFund_Buy%sFund", typeName, typeName)]) end end function UIHeroFundPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.Loop_HeroFund then local day = data[1].Day if self.type == LuaConst.ShowGoldenType.GoldIngot then UIUtils.SetLabel(cellTable.txt_Day, string.FormatByIdsId(Const_IDS.IDS_GoldIngotFund_Times2, day)) else UIUtils.SetLabel(cellTable.txt_Day, string.FormatByIdsId(Const_IDS.IDS_HeroFund_DayNum, day)) end cellTable.state_Day:SetState(day > MDL.HeroFund.GetCurStage(self.type) and 1 or 0) for i = 1, 3 do UTL.Item.SetItemCell(cellTable["itemTemplate_Reward" .. i], data[i].ItemID, data[i].ItemNum) local itemState = MDL.HeroFund.GetFundItemState(self.type,day, i) UIUtils.SetActive(cellTable["mask" .. i], itemState ~= MDL.HeroFund.RewardClaimState.CanClaim) UIUtils.SetActive(cellTable["img_Lock" .. i], itemState == MDL.HeroFund.RewardClaimState.Locked) UIUtils.SetActive(cellTable["img_Received" .. i], itemState == MDL.HeroFund.RewardClaimState.Claimed) if itemState == 1 then cellTable["effect_Receive" .. i]:PlayUIEffect() else cellTable["effect_Receive" .. i]:StopUIEffect() end end end end function UIHeroFundPanel:OnButtonClicked(comp) if comp == self.btn_Info then local offset = self.type - 1 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.HeroFund + offset }) elseif comp == self.btn_Unselected_Hero or comp == self.btn_Unselected_Treasure or comp == self.btn_Unselected_Horse then -- 打开选X界面 UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFundChoosePanel, { type = self.type }) elseif comp == self.btn_Upgrade then -- 打开升阶之路 if self.type == LuaConst.ShowGoldenType.GoldIngot then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFundAdvancedPanel, { type = self.type }, Const_UI_Lua.UIEnum.UIGoldIngotFundAdvancedPanel) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFundAdvancedPanel, { type = self.type }) end elseif comp == self.btn_Receive then -- 一键领取,先判断本地是否有可领取的 local type = self.type local fundID = MDL.HeroFund.GetFundID(type) if type ~= LuaConst.ShowGoldenType.GoldIngot and (not fundID or fundID <= 0) then local typeName = CTL.HeroFund.GetTypeName(type) CTL.Tips.AddTipsMsg(Const_IDS[string.format("IDS_%sFund_ChooseTips",typeName)]) elseif MDL.HeroFund.CanClaimAnyReward(type) then MDL.HeroFund.HeroFundRewardAllReq(type) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroFund_NoReward) end elseif comp == self.btn_Go then CTL.GuildMine.OpenGuildMineMainView() end end function UIHeroFundPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.Loop_HeroFund then local gear local day = data[1].Day if target == cellTable.itemTemplate_Reward1.event_Click then gear = 1 elseif target == cellTable.itemTemplate_Reward2.event_Click then gear = 2 elseif target == cellTable.itemTemplate_Reward3.event_Click then gear = 3 end if gear then local type = self.type local itemState = MDL.HeroFund.GetFundItemState(type, day, gear) if itemState == MDL.HeroFund.RewardClaimState.CanClaim then local fundID = MDL.HeroFund.GetFundID(type) if type == LuaConst.ShowGoldenType.GoldIngot or (fundID and fundID > 0) then MDL.HeroFund.HeroFundRewardReq(type, gear, day) --可领取的时候直接领取 else local typeName = CTL.HeroFund.GetTypeName(type) CTL.Tips.AddTipsMsg(Const_IDS[string.format("IDS_%sFund_ChooseTips", typeName)]) end else --锁定或已领取的时候弹出通用提示 UTL.ItemTips.ShowCommonTipsById(data[gear].ItemID) end end end end return UIHeroFundPanel