local UILevelSelectMainPanel = UIViewClass() local UILevelSelectChapterPanel = require "View/LevelSelect/UILevelSelectChapterPanel" local NORMAL_COLOR = "70C664" --三星条件或解锁条件满足颜色 local UNSATIFIED_COLOR = "FF3C3C" -- --解锁条件不满足颜色(红) local EventSystem = require('Event/EventSystem') --为以后增加难度不同章节关卡做准备,估计要重构 local ChapterIdStartNum = 100 local LevelIdStartNum = 10000 local SelectedScaleRatio = 1.2 local SubjugateGsLowLimit = 4 function UILevelSelectMainPanel:OnCreated() self.heroImageTrans = self.img_Avatar01.transform self.heroImageRect = self.img_Avatar01.rectTransform self.heroAnchorPosX, self.heroAnchorPosY = self.heroImageRect:GetAnchoredPosition() end function UILevelSelectMainPanel:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_Item_Source03"]) --刷新所选章节事件注册(需要刷新一切) self:RegistSystemEvent(EventID.UI_LevelSelect_RefreshChapter, self.RefreshChapter) self:RegistSystemEvent(EventID.UI_LaterEnter_QuickPass, self.RefreshChapter) self:RegistSystemEvent(EventID.UI_LevelSelect_ClaimedReward, self.RefreshDifficultRedPoint) --领取宝箱并刷新宝箱事件注册 self:RegistSystemEvent(EventID.UI_LevelSelect_ClaimedReward, self.RefreshChapterChestReward) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshChapterAward) self:RegistSystemEvent(EventID.UI_ChapterGoal_RefreshChapterAward, self.RefreshChapterAward) self:RegistTriggerEvent(self.img_Back, UIEventTriggerType.Drag) self:RegistTriggerEvent(self.img_Back, UIEventTriggerType.EndDrag) local difficult = MDL.LevelSelect.GetTempLastDifficult() or MDL.LevelSelect.Difficult.Normal -- 禁用默认选中Button放置再次点击 self.group_Difficult[difficult].event_Difficult.interactable = false local levelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(difficult) if not levelId or levelId == 0 then levelId = LevelIdStartNum * difficult + ChapterIdStartNum + 1 end local index = MDL.LevelSelect.GetIndexById(levelId) - 1 local chapterId = MDL.LevelSelect.GetChapterIdByLevelId(levelId) --local chapterId = MDL.LevelSelect.GetUnlockChapterIdByDifficult(difficult) or 0 if not chapterId or chapterId == 0 then chapterId = ChapterIdStartNum * difficult + 1 end --打开界面是否进入爬塔 if context then index = context.index - 1 chapterId = context.chapterId levelId = context.levelId difficult = context.difficult elseif CTL.LevelSelect.GetTemporaryLevelViewData() then index, levelId, chapterId = CTL.LevelSelect.GetTemporaryLevelViewData() CTL.LevelSelect.ClearTemporaryLevelViewData() end --将条件的各种组件整理组合 self.conditionText = {} for i = 1, 3 do self.conditionText[i] = {} self.conditionText[i].label = self["lab_Condition0"..i] self.conditionText[i].dot = self["sprite_ConditionDot0"..i] self.conditionText[i].star = self["sprite_ConditionStar0"..i] end self:InitData(chapterId, difficult) self:UpdateSelectState(self.difficult) self:ResetData() local realCheckPoint if context then realCheckPoint = context.param end local checkPoint = string.split(realCheckPoint,"_") local checkPointIndex = checkPoint[2] self.TableShowSystem:EnterTableShow(levelId) self.TableShowSystem:SwitchTable(true) self:RefreshChapter(self.curChapter, index) self:CheckDifficultySituation() UIManager.ActiveUIModle(false, "UILevelSelectMainPanel") --self:AutoClaimChest() if context and context.chestIndex then local index = context.chestIndex if self.group_Chest[index] then local px = self.group_Chest[index].event_Reward.transform:GetPosition() self:ShowChestReward(self.chestData[index].starReward, px) end end UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) end function UILevelSelectMainPanel:AutoClaimChest() local unlockChapterId = MDL.LevelSelect.GetUnlockChapterIdByDifficult(self.difficult) or (ChapterIdStartNum * self.difficult + 1) for index, data in ipairs(DataSheetUtil.GetSortedLevelChapterData()) do if data.BarrierCharpterID > unlockChapterId then return end local chapterStarNum = 0 local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) for i, barrierId in ipairs(MDL.LevelSelect.GetLevelIdByChapterId(data.BarrierCharpterID)) do local starNum = MDL.LevelSelect.GetLevelStarNumById(barrierId) if unlockLevelId and barrierId <= unlockLevelId then if starNum then chapterStarNum = starNum + chapterStarNum end end end local isGot = MDL.LevelSelect.GetChapterDataById(data.BarrierCharpterID) or {} local ChapterData = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(data.BarrierCharpterID) local starInfo = ChapterData.NormalBarrier3Stars_Table for i, v in ipairs(starInfo) do if chapterStarNum >= v.StarNum then if not isGot[i] or isGot[i] <= 0 then MDL.LevelSelect.ClaimChapterRewardChestRequest(data.BarrierCharpterID, i-1) end end end end end function UILevelSelectMainPanel:OnDrag(comp, eventData) if not self.m_Pointer_One then self.m_Pointer_One = eventData self.position1 = {} self.delta = {} end if self.m_Pointer_One then UIUtils.GetEventDataDelta(self.m_Pointer_One, self.delta) self.delta.x = self.delta[1] self.TableShowSystem:DraggingByManual(self.delta.x) end end function UILevelSelectMainPanel:OnEndDrag(comp, eventData) self.m_Pointer_One = nil end function UILevelSelectMainPanel:OnClosed() self.chestData = {} MDL.LevelSelect.SaveTempLastDifficult(self.difficult) CTL.LevelSelect.SetRecoverBoolByDifficult(self.difficult) UIManager.ActiveUIModle(true, "UILevelSelectMainPanel") UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder) end function UILevelSelectMainPanel:InitData(chapterId, difficult) self.totalStar = 0 self.nowStar = 0 self.cellSelectList = {} self.cellUnSelectList = {} if self.LoopScroll_PanelLeft.Count > 0 then self.LoopScroll_PanelLeft:ClearCells() end self.difficult = difficult or MDL.LevelSelect.Difficult.Normal self.curChapter = chapterId or (1 + ChapterIdStartNum * self.difficult) --为左边关卡选择列表增加数据初始化,同时计算现在拥有的星数 for index, barrierId in ipairs(MDL.LevelSelect.GetLevelIdByChapterId(self.curChapter)) do local barrierData = DataSheetManager.BarrierChosenData:GetDataByID(barrierId) local starNum = MDL.LevelSelect.GetLevelStarNumById(barrierId) local starTable = MDL.LevelSelect.GetLevelDataById(barrierId) local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) if unlockLevelId and barrierId <= unlockLevelId then if starNum then self.nowStar = starNum + self.nowStar end end self.LoopScroll_PanelLeft:AddData({Data = barrierData, StarTable = starTable}, 0) end end function UILevelSelectMainPanel:RefreshLevelInfo(cellIndex) for index, barrierId in ipairs(MDL.LevelSelect.GetLevelIdByChapterId(self.curChapter)) do local barrierData = DataSheetManager.BarrierChosenData:GetDataByID(barrierId) local unlockList = barrierData.Unlock_Table if tostring(barrierData.BarrierID) == tostring(cellIndex + 1) then if self.curLevelID == barrierData.ID then return end self.curLevelID = barrierData.ID --刷新桌子物体 self.TableShowSystem:LoadLevelInfo(self.curLevelID) --刷新关卡描述 UIUtils.SetLabelText(self.txt_heroIntroduction, Const_IDS[barrierData.BarrierDes]) --UIUtils.SetLabelText(self.txt_Level, Const_IDS[barrierData.BarrierProgressAndName]) self.txt_Level.text = CTL.LevelSelect.GetLevelWholeNameById(barrierData.ID) --战力压制 UIUtils.SetLabel(self.txt_Gs, CTL.LevelSelect.GetSubjugateGsText(barrierData.SubjugateDataPVE, barrierData.Battle)) --这里传MissonDataID[1]就行,因为后续只是取关卡类型 local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) local levelStar = MDL.LevelSelect.GetLevelStarNumById(self.curLevelID) local levelStarTable = MDL.LevelSelect.GetLevelDataById(self.curLevelID) if unlockLevelId and self.curLevelID <= unlockLevelId then local data = DataSheetManager.BarrierChosenData:GetDataByID(self.curLevelID) self.event_Attack:SetGray(false) if levelStar > 0 then UIUtils.SetActive(self.event_Sweep, true) UIUtils.SetActive(self.event_Skip, false) self.event_Sweep:SetGray(false) UIUtils.SetLabel(self.txt_Cost, data.Energy) UIUtils.SetActive(self.group_CostIcon.gameObject, true) UIUtils.SetActive(self.group_FirstPassCostHint, false) else self:RefreshSweepAndSkipBtn(true) UIUtils.SetActive(self.group_CostIcon.gameObject, false) UIUtils.SetActive(self.group_FirstPassCostHint, true) end UIUtils.SetLabelText(self.lab_ConditionTitle, Const_IDS.IDS_Barrier_ThreeStarsTrigger) self.event_Attack:SetRedPoint(MDL.LevelSelect.GetLevelStarNumById(self.curLevelID) == 0 and MDL.Player.GetLineUpGs() >= data.Battle) else self:RefreshSweepAndSkipBtn(false) self.event_Attack:SetGray(true, true) self.event_Attack:SetRedPoint(false) UIUtils.SetLabelText(self.lab_ConditionTitle, Const_IDS.IDS_Barrier_Unlock) end for i = 1, 3 do if unlockLevelId and self.curLevelID <= unlockLevelId then local evaluationList = DataSheetManager.LevelEvaluationData:GetDataByLevelID_Order(barrierData.MissonDataID[#barrierData.MissonDataID], i) if not evaluationList then logging.error(LTAG.ERROR, "LevelEvaluationData表里找不到LevelID: ", barrierData.MissonDataID[#barrierData.MissonDataID], "Order: ", i, " 的数据,请策划自己去检查,谢谢!:D") end local unlockContent = self:FormatEvaluationText(evaluationList) UIUtils.SetLabel(self.conditionText[i].label, unlockContent) UIUtils.SetActive(self.conditionText[i].label, true) UIUtils.SetActive(self.conditionText[i].dot, false) if next(levelStarTable) and levelStarTable[i] == 1 then self.conditionText[i].label.text = UTL.Color.FormatTextByColor(NORMAL_COLOR, unlockContent) UTL.Item.SetAtlasSprite(self.conditionText[i].star, "UI_MainStory", "zsjq_bg_xx") else self.conditionText[i].label.text = UTL.Color.FormatTextByColor(UNSATIFIED_COLOR, unlockContent) UTL.Item.SetAtlasSprite(self.conditionText[i].star, "UI_MainStory", "zsjq_bg_xx2") end UIUtils.SetActive(self.conditionText[i].star, true) else UIUtils.SetActive(self.conditionText[i].dot, true) UIUtils.SetActive(self.conditionText[i].star, false) if unlockList[i] then local ifUnlock, unlockText = CTL.Unlock.JudgeUnlockByParameterTable(unlockList[i]) if not ifUnlock then UIUtils.SetLabel(self.conditionText[i].label, UTL.Color.FormatTextByColor(UNSATIFIED_COLOR, unlockText)) else UIUtils.SetLabel(self.conditionText[i].label, UTL.Color.FormatTextByColor(NORMAL_COLOR, unlockText)) end UIUtils.SetActive(self.conditionText[i].label, true) else UIUtils.SetActive(self.conditionText[i].label, false) end end end local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(barrierData.RewardClientShowID) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) if self.loop_BarrierReward.Count > 0 then self.loop_BarrierReward:ClearCells() end for i, v in ipairs(rewardData) do local cellData if levelStar > 0 then if not v.FristGothrough then cellData = {v, false} end else if v.FristGothrough then cellData = {v, true} else cellData = {v, false} end end if cellData then self.loop_BarrierReward:AddData(cellData, 0) end end self:SaveChapterAndLevel() end end end function UILevelSelectMainPanel:RefreshSweepAndSkipBtn(isMeetAttackCondition) local isCanQuickSkip = MDL.LaterEnter.IsCanQuickSkip(MDL.LaterEnter.LaterEnterQuickPassType.MainLine, self.curChapter) --是否可以速通 UIUtils.SetActive(self.event_Skip, isCanQuickSkip) UIUtils.SetActive(self.event_Sweep, not isCanQuickSkip) self.event_Skip:SetGray(not (isCanQuickSkip and isMeetAttackCondition), true) self.event_Sweep:SetGray(true, true) end function UILevelSelectMainPanel:SaveChapterAndLevel() if self.context then self.context.levelId = self.curLevelID self.context.chapterId = self.curChapter self.context.index = MDL.LevelSelect.GetIndexById(self.curLevelID) self.context.difficult = self.difficult else self.context = {levelId = self.curLevelID, chapterId = self.curChapter, index = MDL.LevelSelect.GetIndexById(self.curLevelID), difficult = self.difficult} end end function UILevelSelectMainPanel:RefreshChapterChestReward() local ChapterData = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(self.curChapter) local starInfo = ChapterData.NormalBarrier3Stars_Table local chestNum = #starInfo self.totalStar = starInfo[chestNum].StarNum -- 重置显示宝箱 if self.group_Chest then for _, v in ipairs(self.group_Chest) do v.effect_Chest:StopUIEffect() UIUtils.SetActive(v.gameObject, false) end end self.chestData = {} UIUtils.SetLabel(self.lab_total, "/"..self.totalStar) UIUtils.SetLabel(self.txt_Rate, self.nowStar) self.Fill.fillAmount = self.nowStar / self.totalStar local width = self.FillArea.gameObject.transform:GetSizeDelta() local isGot = MDL.LevelSelect.GetChapterDataById(self.curChapter) or {} for i, v in ipairs(starInfo) do local offsetX = v.StarNum / self.totalStar * width if not self.group_Chest[i] then self:InstantiateCollection(self.group_Chest, self.cell_Chest.gameObject) end local curChest = self.group_Chest[i] UIUtils.SetActive(curChest.gameObject, true) curChest.gameObject.transform:SetAnchoredPosition(offsetX, 0) curChest.name = v.StarReward self.chestData[i] = {} self.chestData[i].starReward = v.StarReward self.chestData[i].starNum = v.StarNum self.chestData[i].isGot = isGot[i] self:SetChestImgByState(self.group_Chest[i], v.StarNum, isGot[i]) UIUtils.SetLabel(self.group_Chest[i].lab_Reward, v.StarNum) self:ShowHeroInChest() end end function UILevelSelectMainPanel:ShowHeroInChest() if not self.chestData then return end for i, v in ipairs(self.group_Chest) do if self.chestData[i] then local rewardData = DataSheetManager.BarrierStarsRewardRepeat:GetDataByAttrRepeatID(self.chestData[i].starReward).Item_Table UIUtils.SetActive(v.group_RewardHeroWhole, false) local isGot = self.chestData[i].isGot if not isGot or isGot == 0 then for key, itemTable in ipairs(rewardData) do local heroId = UTL.Item.IsItemWholeHero(itemTable.ItemID) if heroId then UTL.Color.SetQualityImageByType(v.img_RewardQualityHero, DataSheetManager.HeroNum:GetDataByID(heroId).HeroQuality, UTL.Color.QualityType.Square) UTL.Item.SetHeroIconByHeroId(v.img_RewardHeroHead, heroId) UIUtils.SetActive(v.group_RewardHeroWhole, true) end end end end end end function UILevelSelectMainPanel:HideHeroInChest() for i, v in ipairs(self.group_Chest) do UIUtils.SetActive(v.group_RewardHeroWhole, false) end end function UILevelSelectMainPanel:ShowChestReward(starReward, locateX) UIUtils.SetActive(self.info_Reward.gameObject, true) UIUtils.SetActive(self.Bottom, true) if self.ChestRewardScroll.Count > 0 then self.ChestRewardScroll:ClearCells() end local rewardData = DataSheetManager.BarrierStarsRewardRepeat:GetDataByAttrRepeatID(starReward).Item_Table for i,v in ipairs(rewardData) do self.ChestRewardScroll:AddData(v, 0) end self.info_Reward.transform:SetPosition(locateX, nil, nil) end function UILevelSelectMainPanel:SaveChestOpenIndex(index) if self.context then self.context.chestIndex = index else self.context = {chestIndex = index} end end function UILevelSelectMainPanel:SetChestImgByState(chestCompnent, starNum, isGot) local state = chestCompnent.state_Chest local eft = chestCompnent.effect_Chest if self.nowStar >= starNum then if isGot and isGot > 0 then eft:StopUIEffect() state:SetState(2) else eft:PlayUIEffect() state:SetState(0) end else eft:StopUIEffect() state:SetState(1) end end function UILevelSelectMainPanel:FormatEvaluationText(evaluateData) return string.FormatByIdsId(Const_IDS[evaluateData.EvaluationNextIDS], evaluateData.Param1, evaluateData.Param2, evaluateData.Param3) end --扫荡 function UILevelSelectMainPanel:OnClickSweep() local levelStar = MDL.LevelSelect.GetLevelStarNumById(self.curLevelID) if levelStar > 0 then if DataSheetManager.BarrierChosenData:GetDataByID(self.curLevelID).Energy <= MDL.Player.GetEnergyValue() then CTL.Sweep.OpenSweepFubenView(self.curLevelID) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Sweep_Finish_NoEnergy"]) UTL.ItemTips.OpenAboutEnergyPillView() end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Sweep_NoCondition"]) end end --速通 function UILevelSelectMainPanel:OnClickSkip() if self.curLevelID and self.curLevelID <= MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) then MDL.LaterEnter.LaterEnterQuickPassReq(MDL.LaterEnter.LaterEnterQuickPassType.MainLine, {self.curChapter}) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Barrier_NoCondition"]) end end --进攻 function UILevelSelectMainPanel:OnClickAttackBtn() if self.curLevelID and self.curLevelID <= MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) then if MDL.LaterEnter.IsCanQuickSkip(MDL.LaterEnter.LaterEnterQuickPassType.MainLine, self.curChapter) then UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_COMMON_PROMPT, Const_IDS.IDS_LaterEnter_Hint_14, function () MDL.LaterEnter.LaterEnterQuickPassReq(MDL.LaterEnter.LaterEnterQuickPassType.MainLine, {self.curChapter}) end, function () self:OnClickAttack() end, Const_IDS.IDS_LaterEnter_Hint_12, Const_IDS.IDS_LaterEnter_Hint_15 ) else self:OnClickAttack() end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Barrier_NoCondition"]) end end --进攻 function UILevelSelectMainPanel:OnClickAttack() if GameAppInfo.IsVietnamPackage() and self.curLevelID == 10201 then --越南埋点要走特殊处理,不要走通用逻辑 SDKUtil.OnNewUserMission() end local barrierData = DataSheetManager.BarrierChosenData:GetDataByID(self.curLevelID) EventSystem.Dispatch(EventID.BI_ViewClick, BIManager.ViewBIEvent.UILevelSelectMainPanel_event_Attack, self.curLevelID) if CTL.LevelSelect.IsShowPowerNotEnoughHint(barrierData.SubjugateDataPVE) then CTL.LevelSelect.SetTemporaryLevelViewData(MDL.LevelSelect.GetIndexById(self.curLevelID) - 1, self.curLevelID, self.curChapter) UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_FightingCapacityNotEnough, Const_IDS.IDS_FightingCapacityNotEnough_Tips, function () CTL.LevelSelect.SkipToHeroLevelUpPanel() end, function () self:PrepareAttackFuben() end, Const_IDS.IDS_FightingCapacityNotEnough_Button02, Const_IDS.IDS_FightingCapacityNotEnough_Button01) else self:PrepareAttackFuben() end CTL.LevelSelect.SendStage299BI(self.difficult, self.curLevelID) end function UILevelSelectMainPanel:PrepareAttackFuben() local levelStarData = MDL.LevelSelect.GetLevelStarNumById(self.curLevelID) local barrierData = DataSheetManager.BarrierChosenData:GetDataByID(self.curLevelID) if barrierData.Energy <= MDL.Player.GetEnergyValue() or levelStarData == 0 then MDL.LevelSelect.EnterFuben(LuaConst.LevelType.NORMAL ,self.curLevelID, nil, barrierData.MissonDataID[1]) CTL.LevelSelect.ClearTemporaryLevelViewData() else CTL.Tips.AddTipsMsg(Const_IDS["IDS_Sweep_Finish_NoEnergy"]) UTL.ItemTips.OpenAboutEnergyPillView() end end function UILevelSelectMainPanel:OnClickClose() self:CloseView(true) end function UILevelSelectMainPanel:ResetData() self.curLevelID = nil end -- 刷新章节 function UILevelSelectMainPanel:RefreshChapter(selectedChapter, index) if selectedChapter and selectedChapter < ChapterIdStartNum then selectedChapter = self.difficult * ChapterIdStartNum + selectedChapter end self.curChapter = selectedChapter or self.curChapter self:InitData(self.curChapter, self.difficult) -- 增加配置背景图,章节文字图片的方法 self:RefreshBackGround() self:ResetData() self:ClearChestViews() self:RefreshChapterChestReward() local levelNum = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(self.curChapter).BarrierNum if not index then --选中章节的时候默认选中最新已解锁的关卡 index = levelNum - 1 for i, v in ipairs(MDL.LevelSelect.GetLevelIdByChapterId(self.curChapter)) do if not MDL.LevelSelect.IsLevelUnlock(v) then index = math.max(0, i - 2) break end end end if (index + 1) > (levelNum / 2) then self.LoopScroll_PanelLeft:MoveEnd() end self.LoopScroll_PanelLeft:SelectIndex(index) self:RefreshLevelInfo(index) UnityEngine.UI.LayoutRebuilder.MarkLayoutForRebuild(self.group_Chapter) self:RefreshDifficultRedPoint() self:RefreshChapterAward() end function UILevelSelectMainPanel:RefreshDifficultRedPoint() for i, v in ipairs(self.group_Difficult) do if i ~= self.difficult then v.event_Difficult:SetRedPoint(CTL.LevelSelect.IsDifficultShowRedPoint(i)) else v.event_Difficult:SetRedPoint(false) end end UIUtils.SetActive(self.icon_ChapterRedPoint, CTL.LevelSelect.IsDifficultShowRedPoint(self.difficult)) end function UILevelSelectMainPanel:CheckDifficultySituation() for i = MDL.LevelSelect.Difficult.Elite, MDL.LevelSelect.Difficult.Hell do local showLockTable = DataSheetManager.BarrierDifficultyDegree:GetDataByDifficultyID(i).ShowUnlock_Table local realLockTable = DataSheetManager.BarrierDifficultyDegree:GetDataByDifficultyID(i).RealUnlock_Table local isShow = CTL.Unlock.JudgeIfSatisfiedUnlockTable(showLockTable) local isReal = CTL.Unlock.JudgeIfSatisfiedUnlockTable(realLockTable) local cell = self.group_Difficult[i] if isShow then UIUtils.SetActive(cell.gameObject, true) UIUtils.SetActive(self.group_Difficult[MDL.LevelSelect.Difficult.Normal].gameObject, true) UIUtils.SetActive(cell.img_mask, not isReal) else UIUtils.SetActive(cell.gameObject, false) end end end function UILevelSelectMainPanel:RefreshBackGround() local ChapterData = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(self.curChapter) self.TableShowSystem:LoadChapterInfo(ChapterData.BGUI) local name = CTL.LevelSelect.GetChapterWholeNameById(self.curChapter) self.txt_Title.text = name --UIUtils.SetLabelText(self.txt_Title, Const_IDS[ChapterData.CharpterName]) UIUtils.SetLabelText(self.txt_TitleNumber, Const_IDS[ChapterData.CharpterSortIDS]) end function UILevelSelectMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UILevelSelectMainPanel:OnButtonClicked(obj) if obj == self.event_Sweep then self:OnClickSweep() elseif obj == self.event_Skip then self:OnClickSkip() elseif obj == self.event_Attack then self:OnClickAttackBtn() elseif obj == self.UITemplateTitlePanel.btn_close then self:OnClickClose() elseif obj == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif obj == self.Bottom then self:ClearChestViews() elseif obj == self.event_Chapter then self:OpenChapterPanel() elseif obj == self.btn_ChapterGoal then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChapterGoal) else for i, v in ipairs(self.group_Difficult) do if obj == v.event_Difficult then v.event_Difficult.interactable = false self.TableShowSystem:SwitchTable(true) self:RefreshDifficult(i) for j, v in ipairs(self.group_Difficult) do v.event_Difficult.interactable = i ~= j end break end end for i = 1, #self.group_Chest do if obj == self.group_Chest[i].event_Reward then if self.nowStar >= self.chestData[i].starNum and (not self.chestData[i].isGot or self.chestData[i].isGot == 0) then MDL.LevelSelect.ClaimChapterRewardChestRequest(self.curChapter, i-1) else local px = self.group_Chest[i].gameObject.transform:GetPosition() self:ShowChestReward(self.chestData[i].starReward, px) self:SaveChestOpenIndex(i) self:HideHeroInChest() end break end end end end function UILevelSelectMainPanel:UpdateSelectState(index) for i, v in ipairs(self.group_Difficult) do if i == index then v.effect_Selected:PlayUIEffect() v.gameObject.transform:SetLocalScale(SelectedScaleRatio,SelectedScaleRatio,SelectedScaleRatio) else v.effect_Selected:StopUIEffect() v.gameObject.transform:SetLocalScale(1,1,1) end end end function UILevelSelectMainPanel:RefreshDifficult(difficult) if difficult ~= MDL.LevelSelect.Difficult.Normal then local realLockTable = DataSheetManager.BarrierDifficultyDegree:GetDataByDifficultyID(difficult).RealUnlock_Table local isReal, realDes = CTL.Unlock.JudgeIfSatisfiedUnlockTable(realLockTable) if not isReal then CTL.Tips.AddTipsMsg(realDes) return end end self:UpdateSelectState(difficult) if difficult == self.difficult then return end self.difficult = difficult --self.curChapter = (MDL.LevelSelect.GetIndexById(self.curChapter) + ChapterIdStartNum * self.difficult) local levelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(difficult) if not levelId or levelId == 0 then self.curChapter = self.curChapter % ChapterIdStartNum + difficult * ChapterIdStartNum levelId = self.curChapter * ChapterIdStartNum + 1 end self.curLevelID = levelId --local unlockChapterId = MDL.LevelSelect.GetUnlockChapterIdByDifficult(difficult) local unlockChapterId = MDL.LevelSelect.GetChapterIdByLevelId(levelId) if not unlockChapterId then logging.error(LTAG.ERROR, "难度解锁条件与该难度首章解锁条件不一致,请策划同学检查并修改表里内容!!!") return end self.curChapter = unlockChapterId self:RefreshChapter(self.curChapter, MDL.LevelSelect.GetIndexById(self.curLevelID) - 1) end function UILevelSelectMainPanel:OpenChapterPanel() if not CTL.HotFix.CheckAssetIsReady("OpenChapter") then CTL.Tips.AddTipsMsg(Const_IDS.IDS_DownloadNotFinish) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UILevelSelectChapterPanel, {self.curChapter}) end function UILevelSelectMainPanel:ClearChestViews() UIUtils.SetActive(self.Bottom, false) UIUtils.SetActive(self.info_Reward.gameObject, false) --if self.context and self.context.chestIndex then -- self.context.chestIndex = nil --end if self.group_Chest then self:ShowHeroInChest() end end function UILevelSelectMainPanel:SetRewardItem(cellTable, data, isFirstPassReward) UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum, isFirstPassReward) end function UILevelSelectMainPanel:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_PanelLeft then self:RefreshLevelInfo(index) local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) local levelStar = MDL.LevelSelect.GetLevelStarNumById(self.curLevelID) local levelStarTable = MDL.LevelSelect.GetLevelDataById(self.curLevelID) if not unlockLevelId or self.curLevelID > unlockLevelId then CTL.Sound.PlayGameSound("UI_invalid") end end end function UILevelSelectMainPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_PanelLeft then local levelData = DataSheetManager.BarrierChosenData:GetDataByID(data.Data.ID) local name = CTL.LevelSelect.GetLevelWholeNameById(data.Data.ID) --英语、印尼语,只显示章节号-关卡号 if Localization.IsEnglish() or Localization.IsIndonesian() or Localization.IsJapanese() or GameAppInfo.IsVietnamPackage() or Localization.IsThailand() then UIUtils.SetLabel(cellTable.labLocalContent,UIUtils.GetLocalizedTxt(Const_IDS[levelData.BarrierNum])) UIUtils.SetLabel(cellTable.labLocalContent_Select, UIUtils.GetLocalizedTxt(Const_IDS[levelData.BarrierNum])) else UIUtils.SetLabel(cellTable.labLocalContent, name) UIUtils.SetLabel(cellTable.labLocalContent_Select, name) end --加入处理星星根据获取数量显隐的逻辑 local UnlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(self.difficult) for i = 1, 3 do UIUtils.SetActive(cellTable["Star"..i], false) end if UnlockLevelId and data.Data.ID <= UnlockLevelId then UIUtils.SetActive(cellTable.group_Lock.gameObject, false) for i, v in ipairs(data.StarTable) do if v == 1 then UIUtils.SetActive(cellTable["Star"..i], true) end end cellTable.cell:SetRedPoint(MDL.LevelSelect.GetLevelStarNumById(data.Data.ID) == 0 and MDL.Player.GetLineUpGs() >= data.Data.Battle) else UIUtils.SetActive(cellTable.group_Lock.gameObject, true) cellTable.cell:SetRedPoint(false) end elseif scrollRect == self.ChestRewardScroll then self:SetRewardItem(cellTable, data) elseif scrollRect == self.loop_BarrierReward then self:SetRewardItem(cellTable, data[1], data[2]) end end function UILevelSelectMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.ChestRewardScroll then UTL.ItemTips.ShowCommonTipsById(data.ItemID) elseif scrollRect == self.loop_BarrierReward then local itemInfo = data[1] UTL.ItemTips.ShowCommonTipsById(itemInfo.ItemID) end end function UILevelSelectMainPanel:RefreshChapterAward() if not MDL.LevelSelect.IsUnlockChapterGoalAward() then UIUtils.SetActive(self.group_ProgressAim, false) return end local chapterGoalId = MDL.LevelSelect.GetCurChapterGoalId() UIUtils.SetActive(self.group_ProgressAim, chapterGoalId ~= -1) if chapterGoalId ~= -1 then local data = DataSheetManager.ChapterGoalData:GetDataByChapterGoalID(chapterGoalId) local cache = MDL.LevelSelect.GetChapterGoalCache(chapterGoalId) local completeCount = MDL.LevelSelect.GetCompleteLevelCount(chapterGoalId) local amountCount = cache.amountLevel UIUtils.SetImageByAssetBundle(self.img_Avatar01, data.DisplayHeroHeadPicture) self.heroImageRect:SetAnchoredPosition(self.heroAnchorPosX + data.DisplayHeroSmallOffset_X, self.heroAnchorPosY + data.DisplayHeroSmallOffset_Y) local scaleX = data.DisplayHeroSmallMirror == 1 and -1 or 1 self.heroImageTrans:SetLocalScale(scaleX, 1, 1) local isUnlock = MDL.Unlock.IsComplete(data.Unlock_Table[1].UnlockCondition, data.Unlock_Table[1].UnlockConditionParam) if not isUnlock then UIUtils.SetLabelText(self.txt_Num, Const_IDS["IDS_Unlock"]) self.ProgressBar.fillAmount = 0 return end UIUtils.SetLabelText(self.txt_Num, completeCount < amountCount and Const_IDS["IDS_ChapterGoal_Hint16"] or Const_IDS["IDS_Reward_Receive"]) self.ProgressBar.fillAmount = completeCount / amountCount end end return UILevelSelectMainPanel