local LevelSelect_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local ChapterIdStartNum = 100 local LevelIdStartNum = 10000 local _CommonItemDetail --通用道具提示界面 LevelSelect_Controller.CommonDifficultIDS = { [MDL.LevelSelect.Difficult.Normal] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Major"]), [MDL.LevelSelect.Difficult.Elite] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Dlite"]), [MDL.LevelSelect.Difficult.Hell] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Hell"]), } LevelSelect_Controller.DifficultIDS = { --[MDL.LevelSelect.Difficult.Normal] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_ChapterName_Normal"]), [MDL.LevelSelect.Difficult.Elite] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_ChapterName_Elite"]), [MDL.LevelSelect.Difficult.Hell] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_ChapterName_Inferno"]), } function LevelSelect_Controller.OnStartup() private._tempLevelViewData = {} private._isRecoverLevelView = nil private._tempCurrentLevelId = nil end function LevelSelect_Controller.SetRecoverBoolByDifficult(difficult) private._isRecoverLevelView = difficult ~= MDL.LevelSelect.Difficult.Normal end function LevelSelect_Controller.GetRecoverBool() return private._isRecoverLevelView end function LevelSelect_Controller.GetDifficultNameById(id) local difficult = MDL.LevelSelect.GetDifficultById(id) if difficult == MDL.LevelSelect.Difficult.Normal then return "" else return LevelSelect_Controller.DifficultIDS[difficult] end end function LevelSelect_Controller.GetLevelWholeNameById(levelId) local levelData = DataSheetManager.BarrierChosenData:GetDataByID(levelId) local levelNum = UIUtils.GetLocalizedTxt(Const_IDS[levelData.BarrierNum]) local levelName = UIUtils.GetLocalizedTxt(Const_IDS[levelData.BarrierName]) local difficultName = LevelSelect_Controller.GetDifficultNameById(levelId) return string.Concat(levelNum, difficultName, levelName) end function LevelSelect_Controller.GetChapterWholeNameById(chapterId) local difficultName = LevelSelect_Controller.GetDifficultNameById(chapterId) local chapterData = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(chapterId) local chapterName = UIUtils.GetLocalizedTxt(Const_IDS[chapterData.CharpterName]) return difficultName .. chapterName end function private.GetSubjugateSegmentIndex(subjugateDataId, myGs) local totalGs = myGs and myGs or MDL.Player.GetLineUpGs() local segmentIndex = 1 local segmentsTable = DataSheetManager.SubjugateDataPVE:GetDataByID(subjugateDataId).Segments_Table for i, v in ipairs(segmentsTable) do segmentIndex = i if totalGs < v.PowerPoint then break end end return segmentIndex end -- 使用自选将GS -- targetGs: 自身去对比的战力 -- showGs: 需要显示的战力 function LevelSelect_Controller.GetSubjugateFreeLineGsText(subjugateDataId, targetGs, showGs) local showGSText = showGs ~= nil and showGs or targetGs local segmentData = DataSheetManager.SubjugateDataPVE:GetDataByID(subjugateDataId).Segments_Table[private.GetSubjugateSegmentIndex(subjugateDataId, targetGs)] local colorCode = DataSheetManager.ConstData:GetDataByID("SubjugateLevelColor_" .. segmentData.SubjugateColor).StringValue return UTL.Color.FormatTextByColor(colorCode, showGSText) end -- 使用玩家本身GS function LevelSelect_Controller.GetSubjugateGsText(subjugateDataId, targetGs) local segmentData = DataSheetManager.SubjugateDataPVE:GetDataByID(subjugateDataId).Segments_Table[private.GetSubjugateSegmentIndex(subjugateDataId)] local colorCode = DataSheetManager.ConstData:GetDataByID("SubjugateLevelColor_" .. segmentData.SubjugateColor).StringValue return UTL.Color.FormatTextByColor(colorCode, targetGs) end function LevelSelect_Controller.IsShowPowerNotEnoughHint(subjugateDataId) local segmentData = DataSheetManager.SubjugateDataPVE:GetDataByID(subjugateDataId).Segments_Table[private.GetSubjugateSegmentIndex(subjugateDataId)] return segmentData.IsPowerNotEnough end function LevelSelect_Controller.GetSubjugateColorType(subjugateDataId) local segmentData = DataSheetManager.SubjugateDataPVE:GetDataByID(subjugateDataId).Segments_Table[private.GetSubjugateSegmentIndex(subjugateDataId)] return segmentData.SubjugateColor end function LevelSelect_Controller.GetSubjugateColorTypeByGS(subjugateDataId, targetGs) local segmentData = DataSheetManager.SubjugateDataPVE:GetDataByID(subjugateDataId).Segments_Table[private.GetSubjugateSegmentIndex(subjugateDataId, targetGs)] return segmentData.SubjugateColor end function LevelSelect_Controller.SetSelectCell() local realCheckPoint = TaskManager.Instance:GetCurRealCheckPoint() local checkPoint = string.split(realCheckPoint,"_") local checkPointIndex = checkPoint[2] EventSystem.Dispatch(EventID.UI_LevelSelect_SelectCell,checkPointIndex) end function LevelSelect_Controller.GetStarTable() local evaluationList = BattleDataGetter.GetLevelEvaluationList() local starTable = {} for i,v in ipairs(evaluationList) do starTable[i] = v.Completed and 1 or 0 end return starTable end -- 获取奖励物品信息并整理成表返回 function LevelSelect_Controller.ShowBattleSummary(msg) local rewardList = {} for k,v in ipairs(msg.Resp.Rewards) do local itemData = DataSheetManager.ItemData:GetDataByID(v.ItemId) table.insert(rewardList, {Item = itemData, Count = v.ItemCount}) end CTL.HomeMain.CloseOpenView() UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleSummaryPanel, {Reward = rewardList, Win = msg.isWin, Time = msg.passTime}) end -- 直接退出关卡 function LevelSelect_Controller.LeaveBattleDirectly(msg) MDL.Level.SendRoleLeaveFuben() end function LevelSelect_Controller.FormatTimeCHN(time) local minSec = UTL.Time.TotalSecondsOneMinute if time > minSec then local passMinutes = math.floor(time / minSec) local passSeconds = time % minSec local minText = string.FormatByIdsId(Const_IDS.IDS_TimeMinute, passMinutes) local secText = string.FormatByIdsId(Const_IDS.IDS_TimeSecond, passSeconds) return string.format("%s%s", minText, secText) else return string.FormatByIdsId(Const_IDS.IDS_TimeSecond, time) end end function LevelSelect_Controller.GetTemporaryLevelViewData() if private._tempLevelViewData ~= {} then local tempIndex = private._tempLevelViewData.index local tempLevelId = private._tempLevelViewData.levelId local tempChapterId = private._tempLevelViewData.chapterId return tempIndex, tempLevelId, tempChapterId else return nil end end function LevelSelect_Controller.SetTemporaryLevelViewData(index, levelId, chapterID) private._tempLevelViewData.index = index private._tempLevelViewData.levelId = levelId private._tempLevelViewData.chapterId = chapterID end function LevelSelect_Controller.ClearTemporaryLevelViewData() private._tempLevelViewData = {} end function LevelSelect_Controller.SkipToHeroLevelUpPanel() --MDL.HeroSelect.curSelectHeroID = MDL.HeroSelect.GetSortedHeroIdByIndex(1) --for index, value in ipairs(MDL.HeroSelect.GetSortedHeroData()) do -- --需要取到排序后的武将信息,并且当没有该武将时跳出循环,否则会报错 -- if not MDL.HeroSelect.IsHasHero(value.ID) then -- break -- end -- if CTL.HeroSelect.IsBagExpEnoughLevelUp(value.ID) then -- MDL.HeroSelect.curSelectHeroID = value.ID -- break -- end --end --UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) --UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroShowPanel, {subViewName = MDL.HeroSelect.ToggleViewNameList.LevelUp, isFormation = true}) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroFormationPanel, nil) end function LevelSelect_Controller.IsChapterShowRedPoint(chapterId) return private.IsChapterCanClaimChest(chapterId) or private.IsChapterHasLevelCanAttackEasily(chapterId) end function private.IsChapterCanClaimChest(chapterId) local levelChestData = MDL.LevelSelect.GetChapterDataById(chapterId) or {} local levelRewardData = DataSheetManager.BarrierChapterData:GetDataByBarrierCharpterID(chapterId).NormalBarrier3Stars_Table local chapterStarNums = MDL.LevelSelect.GetChapterStarNumsById(chapterId) for i, v in ipairs(levelRewardData) do if chapterStarNums >= v.StarNum then if not levelChestData[i] or levelChestData[i] == 0 then return true end end end return false end function private.IsChapterHasLevelCanAttackEasily(chapterId) local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(MDL.LevelSelect.GetDifficultById(chapterId)) for i, v in DataSheetManager.BarrierChosenData:GetEnumerator() do if v.BelongToChapter == chapterId and v.ID <= unlockLevelId then if MDL.LevelSelect.GetLevelStarNumById(v.ID) == 0 and MDL.Player.GetLineUpGs() >= v.Battle then return true end end end return false end function LevelSelect_Controller.GetDifficultChapterClaimChestTable(chapterId) local difficultClaimList = {} local simpleChapterId = chapterId % ChapterIdStartNum for i = 1, 3 do local difficultChapterId = i * ChapterIdStartNum + simpleChapterId local isCanClaim = private.IsChapterCanClaimChest(difficultChapterId) difficultClaimList[i] = isCanClaim end return difficultClaimList end function LevelSelect_Controller.IsAnyDifficultChapterCanClaimChest(chapterId) local difficultClaimList = LevelSelect_Controller.GetDifficultChapterClaimChestTable(chapterId) for i, v in ipairs(difficultClaimList) do if v then return true end end return false end function LevelSelect_Controller.IsDifficultShowRedPoint(difficult) return private.IsDifficultHaveChest(difficult) or private.IsDifficultHaveLevelCanAttackEasily(difficult) end function private.IsDifficultHaveChest(difficult) for i, v in DataSheetManager.BarrierChapterData:GetEnumerator() do if v.DifficultyDegree == difficult then if private.IsChapterCanClaimChest(v.BarrierCharpterID) then return true end end end return false end function private.IsDifficultHaveLevelCanAttackEasily(difficult) local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(difficult) for i, v in DataSheetManager.BarrierChosenData:GetEnumerator() do if v.DifficultyDegree == difficult and v.ID <= unlockLevelId then if MDL.LevelSelect.GetLevelStarNumById(v.ID) == 0 and MDL.Player.GetLineUpGs() >= v.Battle then return true end end end return false end function LevelSelect_Controller.IsShowLevelSelectRedPoint() return private.IsChapterHasChestToClaim() or private.IsLevelCanAttackEasily() end function private.IsChapterHasChestToClaim() for i, v in ipairs(DataSheetUtil.GetSortedLevelChapterData()) do local unlockChapterId = MDL.LevelSelect.GetUnlockChapterIdByDifficult(MDL.LevelSelect.GetDifficultById(v.BarrierCharpterID)) if unlockChapterId then if v.BarrierCharpterID > unlockChapterId then return false end local IsCanClaimChest = private.IsChapterCanClaimChest(v.BarrierCharpterID) if IsCanClaimChest then return true end end end return false end function private.IsLevelCanAttackEasily() for i, v in DataSheetManager.BarrierChosenData:GetEnumerator() do local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(MDL.LevelSelect.GetDifficultById(v.ID)) if unlockLevelId then if v.ID > unlockLevelId then return false end if MDL.LevelSelect.GetLevelStarNumById(v.ID) == 0 and MDL.Player.GetLineUpGs() >= v.Battle then return true end end end return false end function LevelSelect_Controller.SetCurrentLevelId(levelId) private._tempCurrentLevelId = levelId end function LevelSelect_Controller.ClearCurrentLevelId() private._tempCurrentLevelId = nil end function LevelSelect_Controller.GetCurrentLevelId() return private._tempCurrentLevelId end function LevelSelect_Controller.GetLevelCutsceneAutoPassTime(levelType) local time = -1 if levelType == LuaConst.LevelType.NORMAL then local difficult = MDL.LevelSelect.GetDifficultById(private._tempCurrentLevelId) if difficult == MDL.LevelSelect.Difficult.Elite then time = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("BarrierElitePassTimeLineDelay").FloatValue) elseif difficult == MDL.LevelSelect.Difficult.Hell then time = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("BarrierInfernoPassTimeLineDelay").FloatValue) end end return time end function LevelSelect_Controller.GetLevelCutsceneAutoPassTimeByLevelInfoData(levelInfoData) local time = -1 local levelType = levelInfoData.LevelType if levelType == LuaConst.LevelType.NORMAL then local barrierChosenData = LevelManager.GetBarrierChosenIDByLevelID(levelInfoData.LevelID) local systemId = barrierChosenData and barrierChosenData.ID if systemId then local difficult = MDL.LevelSelect.GetDifficultById(systemId) if difficult == MDL.LevelSelect.Difficult.Elite then time = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("BarrierElitePassTimeLineDelay").FloatValue) elseif difficult == MDL.LevelSelect.Difficult.Hell then time = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("BarrierInfernoPassTimeLineDelay").FloatValue) end end end return time end function LevelSelect_Controller.PlaySummaryTemplateEffect(effectList) effectList[1]:PlayUIEffect() --effectList[2]:PlayUIEffect() local handle1 = TimerUtil.Interval(function () if effectList and effectList[2]then effectList[2]:PlayUIEffect() end end, 0.5, 1) local handle2 = TimerUtil.Interval(function () if effectList and effectList[3] then effectList[3]:PlayUIEffect() end end, 0.7, 1) return handle1, handle2 end --清理播放特效的句柄 function LevelSelect_Controller.RemoveSummaryTemplateEffect(uiParent) if uiParent.summaryTemplateEffectHandle1 then TimerUtil.Remove(uiParent.summaryTemplateEffectHandle1) end if uiParent.summaryTemplateEffectHandle2 then TimerUtil.Remove(uiParent.summaryTemplateEffectHandle2) end end LevelSelect_Controller.CommonSummaryType = { Draw = 1, Over = 2, } --显示统一的结算动画UI模板 --返回播放特效的句柄,需要在界面关闭时 --isDraw 是否是平局 function LevelSelect_Controller.ShowCommonSummaryTemplate(uiParent,isWin,isShowTips,isShowBg, type) --先重置UI,方便播放动画 UIUtils.SetActive(uiParent.new_summary.gameObject, true) UIUtils.SetActive(uiParent.new_summary.group_Victory, false) UIUtils.SetActive(uiParent.new_summary.group_Fail, false) UIUtils.SetActive(uiParent.new_summary.ani_SummaryTxt,false) --关闭目前用不到,直接设为false UIUtils.SetActive(uiParent.new_summary.btn_close,false) --是否显示tips if isShowTips then UIUtils.SetActive(uiParent.new_summary.lab_Tips,true) else UIUtils.SetActive(uiParent.new_summary.lab_Tips,false) end --是否显示背景 if isShowBg then UIUtils.SetActive(uiParent.new_summary.UIMastBG,true) else UIUtils.SetActive(uiParent.new_summary.UIMastBG,false) end UIUtils.SetActive(uiParent.new_summary.ani_SummaryTxt,true) local WINIMAGEPATH = "UI_PVP/1v1_msz_sl.png" local FAILEDIMAGEPATH = "UI_PVP/1v1_msz_sb.png" local DRAWIMAGEPATH = "UI_PVP/gjcj_msz_pj.png" --平局的图 local BATTLEOVER = "UI_PVP/1v1_msz_zdjs.png" --战斗结束 local handle1,handle2 if isWin then --胜利 uiParent.new_summary.state_Result:SetState(0) -- CN UTL.Item.SetLocalizationImage(uiParent.new_summary.loc_Title, uiParent.new_summary.img_Result, WINIMAGEPATH) -- EN UIUtils.SetLabel(uiParent.new_summary.txt_Result, UIUtils.GetLocalizedTxt(Const_IDS["IDS_GuildWar_Win"])) uiParent.new_summary.loc_Color:SetState(0) CTL.Sound.PlayGameSound("UI_victory_v1") handle1,handle2 = CTL.LevelSelect.PlaySummaryTemplateEffect(uiParent.new_summary.victory_effect) else if type == LevelSelect_Controller.CommonSummaryType.Draw then --平局 uiParent.new_summary.state_Result:SetState(2) -- CN UTL.Item.SetLocalizationImage(uiParent.new_summary.loc_Title, uiParent.new_summary.img_Result, DRAWIMAGEPATH) -- EN UIUtils.SetLabel(uiParent.new_summary.txt_Result, UIUtils.GetLocalizedTxt(Const_IDS["IDS_CountryPVP_Draw"])) uiParent.new_summary.loc_Color:SetState(2) handle1,handle2 = CTL.LevelSelect.PlaySummaryTemplateEffect(uiParent.new_summary.draw_effect) elseif type == LevelSelect_Controller.CommonSummaryType.Over then --战斗结束 uiParent.new_summary.state_Result:SetState(2) -- CN UTL.Item.SetLocalizationImage(uiParent.new_summary.loc_Title, uiParent.new_summary.img_Result, BATTLEOVER) -- EN UIUtils.SetLabel(uiParent.new_summary.txt_Result, UIUtils.GetLocalizedTxt(Const_IDS["IDS_DemonGod_UI_24"])) uiParent.new_summary.loc_Color:SetState(2) handle1,handle2 = CTL.LevelSelect.PlaySummaryTemplateEffect(uiParent.new_summary.draw_effect) else --失败 uiParent.new_summary.state_Result:SetState(1) -- CN UTL.Item.SetLocalizationImage(uiParent.new_summary.loc_Title, uiParent.new_summary.img_Result, FAILEDIMAGEPATH) -- EN UIUtils.SetLabel(uiParent.new_summary.txt_Result, UIUtils.GetLocalizedTxt(Const_IDS["IDS_GuildWar_Lose"])) uiParent.new_summary.loc_Color:SetState(1) handle1,handle2 = CTL.LevelSelect.PlaySummaryTemplateEffect(uiParent.new_summary.defeat_effect) end CTL.Sound.PlayGameSound("UI_failed_v1") end return handle1,handle2 end --关闭统一的结算动画UI模板 function LevelSelect_Controller.CloseCommonSummaryTemplate(uiParent) UIUtils.SetActive(uiParent.new_summary.gameObject, false) end ---@param isWin boolean ---@param duration number ---@param ids string option function LevelSelect_Controller.ShowCommonSummaryTemplatePanel(isWin, duration, ids) local context = { isWin = isWin, duration = duration or 1, idsString = ids or nil, isShowBg = ids ~= nil, isShowTips = ids ~= nil, } if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIBattleVictoryPopUp) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIBattleVictoryPopUp, context) end UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleVictoryPopUp, context) end function LevelSelect_Controller.GetNextLevelId(curLevelId) local nextLevelId = curLevelId + 1-- 下一个关卡 是上一个关卡+1 local isSuccess, __ = DataSheetManager.BarrierChosenData:TryGetDataByID(nextLevelId) if isSuccess then return nextLevelId end -- 如果关卡+1没有数据 则说明是可能发生了跳章节 local nextLevelId = (math.floor(curLevelId / 100) + 1) * 100 + 1 if DataSheetManager.BarrierChosenData:GetDataByID(nextLevelId) then return nextLevelId end return 0 end function LevelSelect_Controller.SendStage299BI(difficult, levelId) --当点击进入2-1时 判断是否需要打点 以及打点的分包信息 if levelId == 10201 then local levelStar = MDL.LevelSelect.GetLevelStarNumById(levelId) if levelStar == 0 then local isDone = 0 if CTL.HotFix.Get_IfAllDownload() == false and CTL.HotFix.GetNextStage() <= 299 then isDone = 0 else isDone = 1 end BIManager.DispatchBIClientEvent(BIManager.EventName.FinishGuideLevel201, "curStage", LoginProxy.GetCurStage(), "pack_299_isDone", isDone) end end end return LevelSelect_Controller