local UIHeroBiographySubPanel = UIViewClass() local SliderSensitivityParam = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SliderSensitivityParam").FloatValue) function UIHeroBiographySubPanel:OnOpened(context) self.dragDict = {} self.animationStage = 0 self.biographyId = context.biographyId self.sweepLevelId = nil self:RefreshInsidePanel() self:RegistSystemEvent(EventID.UI_PurchaseNumsSuccess, self.RefreshEnterTimes) self:RegistSystemEvent(EventID.UI_HeroBiography_UpdateInfo, self.RefreshEnterTimes) self:RegistSystemEvent(EventID.UI_HeroBiography_FinishSweep, self.RefreshEnterTimes) self:RegistSystemEvent(EventID.UI_PurchaseNumsSuccess, self.RefreshSweepEntry) self:RegistSystemEvent(EventID.UI_HeroBiography_FinishSweep, self.RefreshSweepEntry) self:RegistSystemEvent(EventID.UI_HeroBiography_FinishSweep, self.RefreshBottom) self:RegistSystemEvent(EventID.UI_LaterEnter_QuickPass, self.RefreshInsidePanel) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_HeroBiography_Title"]) local index = CTL.Biography.GetLatestBiographyLevelIndex(self.biographyId) local levelNum = DataSheetManager.HeroBiographyData:GetDataByID(self.biographyId).LevelNum if (index + 1) > (levelNum / 2) then self.scroll_BiographyLevel:MoveEnd() end end function UIHeroBiographySubPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIHeroBiographySubPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:ClickBackBtn() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.add_Times then CTL.Biography.ClickAddTimes() elseif comp == self.btn_Array then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIArray) elseif comp == self.btn_Store then --添加商店的打开 elseif comp == self.btn_Skip then MDL.LaterEnter.LaterEnterQuickPassReq(MDL.LaterEnter.LaterEnterQuickPassType.HeroBiography, {self.biographyId}) elseif comp == self.group_BiographyHero.btn_Hero then self:ClickBackBtn() elseif comp == self.group_BiographyHero.item.event_Click then local heroId = DataSheetManager.HeroBiographyData:GetDataByID(self.biographyId).HeroID UTL.ItemTips.ShowCommonTipsById(DataSheetManager.HeroNum:GetDataByID(heroId).PieceItem) elseif comp == self.UITemplateTitlePanel.btn_Info then --每日5点 local timeTab = { 1 } local _, param1 = UTL.Time.GetDateDescAndTime(timeTab) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.HeroBiography, params = { param1 } }) elseif comp == self.btn_Sweep then self:OnSweepBtnClicked() end end function UIHeroBiographySubPanel:ClickBackBtn() self:CloseView() UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroBiographyMain, {biographyId = self.biographyId}) end function UIHeroBiographySubPanel:RefreshInsidePanel() self:RefreshSelectedHero() self:RefreshBiographyLevelScroll() self:RefreshBottom() self:RefreshSweepEntry() UIUtils.SetActive(self.btn_Skip, MDL.LaterEnter.IsCanQuickSkip(MDL.LaterEnter.LaterEnterQuickPassType.HeroBiography, self.biographyId)) end function UIHeroBiographySubPanel:RefreshSweepEntry() self.sweepLevelId = MDL.Biography.GetLastestSweepIndex(self.biographyId) self.hasCount = MDL.Biography.GetEnterNums() > 0 and MDL.Biography.GetBiographyIfDailyCountLeft(self.biographyId) local canSweep = self.sweepLevelId and self.hasCount if canSweep then self.btn_Sweep:SetGray(false, true) else self.btn_Sweep:SetGray(true, true) end end function UIHeroBiographySubPanel:OnSweepBtnClicked() if MDL.Biography.GetEnterNums() == 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroBiography_NoNum"]) elseif not MDL.Biography.GetBiographyIfDailyCountLeft(self.biographyId) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroBiography_Limit"]) elseif MDL.Biography.GetLastestSweepIndex(self.biographyId) == nil then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroBiography_NotClear"]) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroBiographyItemView, { biographyLevelId = self.sweepLevelId, biographyId = self.biographyId, isSweep = true }) end end function UIHeroBiographySubPanel:RefreshSelectedHero() local biographyData = DataSheetManager.HeroBiographyData:GetDataByID(self.biographyId) local heroId = biographyData.HeroID UIUtils.SetImageByAssetBundle(self.group_BiographyHero.img_Hero, biographyData.HeroShow) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UTL.Color.SetQualityImageByType(self.group_BiographyHero.img_quality, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyBg) UTL.Color.SetQualityImageByType(self.group_BiographyHero.img_qualityName, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyCornerBase) UTL.Color.SetQualityImageByType(self.group_BiographyHero.img_qualityNameLoc, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyCornerBase) UTL.Color.SetQualityImageByType(self.group_BiographyHero.img_Frame, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyFrame) UTL.Color.SetQualityImageByType(self.group_BiographyHero.img_GradientCover, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyGradientCover) CTL.HeroSelect.SetHeroName(heroId, self.group_BiographyHero.loc_Name, self.group_BiographyHero.img_Name, self.group_BiographyHero.txt_Name) local totalStar = MDL.Biography.GetHeroBiographyStarNums(biographyData.ID) UIUtils.SetLabel(self.group_BiographyHero.txt_Gs, MDL.Player.GetLineUpGs()) UIUtils.SetActive(self.group_BiographyHero.img_Get, MDL.HeroSelect.IsHasHero(heroId)) UIUtils.SetActive(self.group_BiographyHero.btn_Sweep, totalStar == maxStar) UTL.Item.SetItemCell(self.group_BiographyHero.item, DataSheetManager.HeroNum:GetDataByID(heroId).PieceItem) self.group_BiographyHero.StateSwitch:SetState(2) if MDL.Player.HeroIsLineUp(heroId) then self.group_BiographyHero.StateSwitch:SetState(1) elseif MDL.AssistanceFight.IsHeroOnAssistancePos(heroId) then self.group_BiographyHero.StateSwitch:SetState(0) end end function UIHeroBiographySubPanel:RefreshBiographyLevelScroll() self.scroll_BiographyLevel:ClearCells() for i, v in DataSheetManager.HeroBiographyLevel:GetEnumerator() do if v.BelongToBiography == self.biographyId then self.scroll_BiographyLevel:AddData(v, 0) end end end function UIHeroBiographySubPanel:RefreshBottom() self:RefreshEnterTimes() end function UIHeroBiographySubPanel:RefreshEnterTimes() local totalTimes = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.HeroBiography).DailyRefreshTimes --只显示基础次数 UIUtils.SetLabel(self.txt_Times, MDL.Biography.GetEnterNums().."/"..totalTimes) UIUtils.SetLabel(self.group_BiographyHero.txt_DailyLimit, MDL.Biography.GetBiographyDailyCountShowById(self.biographyId)) end function UIHeroBiographySubPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_BiographyLevel then UIUtils.SetLabelText(cellTable.lab_BiographyName, Const_IDS[data.LevelName]) UIUtils.SetLabelText(cellTable.txt_BiographyIntroduction, Const_IDS[data.LevelDesc]) local lastestIndex = MDL.Biography.GetLastestSweepIndex(self.biographyId) local hasPassed if lastestIndex == nil then hasPassed = false else hasPassed = data.ID <= lastestIndex end UIUtils.SetActive(cellTable.group_Clear, hasPassed) if CTL.Biography.IsHeroBiographyLevelUnlock(data.ID) then UIUtils.SetActive(cellTable.btn_Lock, false) UIUtils.SetActive(cellTable.btn_Enter, true) else UIUtils.SetActive(cellTable.btn_Lock, true) UIUtils.SetActive(cellTable.btn_Enter, false) end local starTable = MDL.Biography.GetBiographyLevelDataById(data.ID) for i = 1, #cellTable.group_Stars do if starTable[i] == 1 then UIUtils.SetActive(cellTable.group_Stars[i], true) else UIUtils.SetActive(cellTable.group_Stars[i], false) end end cellTable.btn_Enter:SetRedPoint(CTL.Biography.IsRecommendBiographyLevel(data.ID)) self.scroll_BiographyLevel:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.BeginDrag, index) self.scroll_BiographyLevel:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.Drag, index) self.scroll_BiographyLevel:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.EndDrag, index) self.dragDict[cellTable.drag_Obj.gameObject] = cellTable.scroll_HeroInfo.gameObject end end function UIHeroBiographySubPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.scroll_BiographyLevel then if target == cellTable.btn_Enter then if MDL.Biography.GetEnterNums() >= 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroBiographyItemView, {biographyLevelId = data.ID, biographyId = self.biographyId}) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroBiography_NoNum"]) end elseif target == cellTable.btn_Lock then local isUnlock, unlockText = CTL.Biography.IsHeroBiographyLevelUnlock(data.ID) CTL.Tips.AddTipsMsg(unlockText) end end end function UIHeroBiographySubPanel:Cell_OnBeginDrag(scrollRect, index, comp, eventData) if math.abs(eventData.delta.x) > SliderSensitivityParam then self.curDragObj = self.scroll_BiographyLevel.gameObject else self.curDragObj = self.dragDict[comp.gameObject] end UIUtils.ExecuteBeginDrag(self.curDragObj, eventData) end function UIHeroBiographySubPanel:Cell_OnDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteDrag(self.curDragObj, eventData) end function UIHeroBiographySubPanel:Cell_OnEndDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteEndDrag(self.curDragObj, eventData) end function UIHeroBiographySubPanel:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end return UIHeroBiographySubPanel