local UILevelSelectChapterPanel = UIViewClass() local EventSystem = require('Event/EventSystem') function UILevelSelectChapterPanel:OnOpened(context) self.curChapter = context[1] self.chosenChapterIndex = MDL.LevelSelect.GetIndexById(self.curChapter) self.difficult = MDL.LevelSelect.GetDifficultById(self.curChapter) self:SetChapterCell() self.curSelectIndex = self.chosenChapterIndex - 1 self.ChapterScroll:SelectIndex(self.chosenChapterIndex - 1) AuxUtil.InitEnhanceScroll(self.ChapterScroll.transform, self.chosenChapterIndex - 1) UIUtils.SetLabelText(self.enter_txt, Const_IDS.IDS_EnterChapter) end function UILevelSelectChapterPanel:OnButtonClicked(comp) if comp == self.event_Enter then self:EnterChapter() elseif comp == self.bg_Bottom then self:CloseView() end end function UILevelSelectChapterPanel:OnCellMoveCenter(scrollRect, index, cellTable, data) if scrollRect == self.ChapterScroll then self:ChapterSelect(index) end end function UILevelSelectChapterPanel:ChapterSelect(index) self.ChapterScroll:SelectIndex(index) if self.chosenChapter then self.ChapterScroll:UpdateIndex(self.chosenChapter - 1) end self.chosenChapter = index + 1 end function UILevelSelectChapterPanel:EnterChapter() EventSystem.Dispatch(EventID.UI_LevelSelect_RefreshChapter, self.chosenChapter) self:CloseView() end function UILevelSelectChapterPanel:SetChapterCell() for i, v in ipairs(DataSheetUtil.GetSortedLevelChapterData()) do local isShowByDifficulty = MDL.LevelSelect.GetDifficultById(v.BarrierCharpterID) == self.difficult -- 筛选难度 if isShowByDifficulty then local isShowByDLCBlock = MDL.LevelSelect.DLCBlockChapterID <= 0 or MDL.LevelSelect.GetChapterIDByBarrierLevelID(v.BarrierCharpterID) <= MDL.LevelSelect.DLCBlockChapterID -- 筛选DLC章节 if isShowByDLCBlock then self.ChapterScroll:AddData(v, 0) end end end end function UILevelSelectChapterPanel:OnCellSelect(scrollRect, index, cellTable, data) self.curSelectIndex = index self.chosenChapterIndex = MDL.LevelSelect.GetIndexById(data.BarrierCharpterID) local unlockChapterId = MDL.LevelSelect.GetUnlockChapterIdByDifficult(self.difficult) or 0 local chapterData = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(data.BarrierCharpterID) UIUtils.SetActive(cellTable.sprite_Selected, true) if data.BarrierCharpterID <= unlockChapterId then UIUtils.SetActive(cellTable.sprite_back, true) self.event_Enter:SetGray(false) self.event_Enter:SetRedPoint(CTL.LevelSelect.IsChapterShowRedPoint(data.BarrierCharpterID)) else UIUtils.SetActive(cellTable.sprite_back, true) UIUtils.SetActive(cellTable.group_Lock, false) for i, v in ipairs(chapterData.Unlock_Table) do local ifSatisfied, unlockText = CTL.Unlock.JudgeUnlockByParameterTable(v) UTL.String.SetLabelContent(cellTable["lab_ChapterCondition0"..i], unlockText) UIUtils.SetActive(cellTable["sprite_ChapterDot0"..i], true) UIUtils.SetActive(cellTable["lab_ChapterCondition0"..i], true) end self.event_Enter:SetRedPoint(false) self.event_Enter:SetGray(true) end end function UILevelSelectChapterPanel:OnCellInit(scrollRect, index, cellTable, data) local unlockChapterId = MDL.LevelSelect.GetUnlockChapterIdByDifficult(self.difficult) or 0 local name = CTL.LevelSelect.GetChapterWholeNameById(data.BarrierCharpterID) cellTable.lab_ChapterTitle.text = name --UIUtils.SetLabelText(cellTable.lab_ChapterTitle, Const_IDS[data.CharpterName]) UIUtils.SetLabelText(cellTable.lab_ChapterNum, Const_IDS[data.CharpterSortIDS]) UIUtils.SetImageByAssetBundle(cellTable.event_Bg, ConstAssetPathConfig.Path32..data.ChosenUI..".png") UIUtils.SetActive(cellTable.sprite_back, true) if data.BarrierCharpterID <= unlockChapterId then UIUtils.SetActive(cellTable.group_LockSelected.gameObject, false) UIUtils.SetActive(cellTable.group_Lock.gameObject, false) else UIUtils.SetActive(cellTable.group_LockSelected.gameObject, true) UIUtils.SetActive(cellTable.group_Lock.gameObject, self.curSelectIndex ~= index) end cellTable.event_cell:SetRedPoint(CTL.LevelSelect.IsChapterShowRedPoint(data.BarrierCharpterID)) end return UILevelSelectChapterPanel