local UIHeroBiographyItemView = UIViewClass() local HeroBiographySweepTimes = DataSheetManager.ConstData:GetDataByID("HeroBiographySweepTimes").IntValue function UIHeroBiographyItemView:OnOpened(context) self:RegistSystemEvent(EventID.UI_HeroBiography_FinishSweep, self.RefreshTimes) self:RegistSystemEvent(EventID.UI_LaterEnter_QuickPass, self.CloseView) self.biographyLevelId = context.biographyLevelId self.isSweep = context.isSweep local biographyLevelData = DataSheetManager.HeroBiographyLevel:GetDataByID(self.biographyLevelId) local biographyName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroBiographyData:GetDataByID(biographyLevelData.BelongToBiography).BiographyName]) local chapterNum = tostring(self.biographyLevelId - biographyLevelData.BelongToBiography*100) UIUtils.SetLabel(self.Refer_Bg.txt_Title, biographyName.."-"..string.FormatByIdsId(Const_IDS.IDS_HeroBiography_Subtitle,chapterNum)) self:RefreshTimes() self:RefreshRewardScroll(biographyLevelData.RewardClientShowID) end function UIHeroBiographyItemView:RefreshTimes() self.btn_Enter:SetGray(false) local curTimes = MDL.Biography.GetEnterNums() if self.isSweep == nil then if MDL.Biography.GetBiographyLevelStarNumById(self.biographyLevelId) > 0 then UIUtils.SetLabel(self.txt_NumCost, 1) if MDL.Biography.GetBiographyIfDailyCountLeft(self.context.biographyId) ~= true or curTimes <= 0 then self.btn_Enter:SetGray(true, true) end else UIUtils.SetLabelText(self.txt_NumCost,Const_IDS.IDS_HeroBiography_FirstNoNeed) end UIUtils.SetLabelText(self.lab_Enter, Const_IDS.IDS_HeroBiography_Enter) UIUtils.SetLabel(self.txt_NumRemain, curTimes) UIUtils.SetLabel(self.txt_HeroDailyLimit, MDL.Biography.GetBiographyDailyCountShowById(self.context.biographyId)) else if MDL.Biography.GetBiographyLevelStarNumById(self.biographyLevelId) > 0 then UIUtils.SetLabel(self.txt_NumCost, 1) if MDL.Biography.GetBiographyIfDailyCountLeft(self.context.biographyId) and curTimes > 0 then self.btn_Enter:SetGray(false) else self.btn_Enter:SetGray(true, true) end else UIUtils.SetLabelText(self.txt_NumCost,Const_IDS.IDS_HeroBiography_FirstNoNeed) end UIUtils.SetLabelText(self.lab_Enter, Const_IDS.IDS_Sweep_Title) UIUtils.SetLabel(self.txt_NumRemain, curTimes) UIUtils.SetLabel(self.txt_HeroDailyLimit, MDL.Biography.GetBiographyDailyCountShowById(self.context.biographyId)) end end function UIHeroBiographyItemView:OnBackButtonPressed() self:OnButtonClicked(self.Refer_Bg.btn_Close) end function UIHeroBiographyItemView:OnButtonClicked(comp) if comp == self.Refer_Bg.btn_Close then self:CloseView() elseif comp == self.btn_Enter then if self.isSweep then MDL.Biography.SweepBiographyReq(self.context.biographyId, self.biographyLevelId, 1) CTL.Sound.PlayGameSound("UI_click_03") else self:OnClickChallenge() end end end function UIHeroBiographyItemView:OnClickChallenge() if MDL.LaterEnter.IsCanQuickSkip(MDL.LaterEnter.LaterEnterQuickPassType.HeroBiography, self.context.biographyId) then UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_COMMON_PROMPT, Const_IDS.IDS_LaterEnter_Hint_16, function () MDL.LaterEnter.LaterEnterQuickPassReq(MDL.LaterEnter.LaterEnterQuickPassType.HeroBiography, {self.context.biographyId}) end, function () self:EnterChallenge() end, Const_IDS.IDS_LaterEnter_Hint_12, Const_IDS.IDS_LaterEnter_Hint_15 ) else self:EnterChallenge() end end function UIHeroBiographyItemView:EnterChallenge() CTL.Biography.SetTempBiographyLevelId(self.biographyLevelId) -- 保存当前进入关卡 MDL.Biography.EnterHeroBiographyRequest(self.context.biographyId, self.biographyLevelId) CTL.Sound.PlayGameSound("UI_sound_Attack") end function UIHeroBiographyItemView:RefreshRewardScroll(rewardId) local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(rewardId) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) local levelStar = MDL.Biography.GetBiographyLevelStarNumById(self.biographyLevelId) for i, v in ipairs(rewardData) do if levelStar > 0 then if not v.FristGothrough then self.loop_BiographyItemScroll:AddData({v, false}, 0) end else if v.FristGothrough then self.loop_BiographyItemScroll:AddData({v, true}, 0) else self.loop_BiographyItemScroll:AddData({v, false}, 0) end end end end function UIHeroBiographyItemView:SetRewardItem(cellTable, data, isFirstPassReward) UTL.Item.SetItemCell(cellTable.Template, data.ItemID, data.ItemNum, isFirstPassReward) end function UIHeroBiographyItemView:OnCellInit(scrollRect, index, cellTable, data) self:SetRewardItem(cellTable, data[1], data[2]) end function UIHeroBiographyItemView:OnCellClicked(scrollRect, index, cellTable, target, data) local itemInfo = data[1] UTL.ItemTips.ShowCommonTipsById(itemInfo.ItemID) end return UIHeroBiographyItemView