local PlotReviewLibrary_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') PlotReviewLibrary_Controller.PlotReviewTabType = { MainLine = 1, GoldenHero = 2, OpeningCinematic = 3, } PlotReviewLibrary_Controller.PlotReview_NewData = "PlotReview_NewData" function PlotReviewLibrary_Controller.OnStartup() private.selectState = {} private.timeLineRewardNameList = {} end function PlotReviewLibrary_Controller.CheckUnlock() return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.PlotReviewLibrary) end function PlotReviewLibrary_Controller.OpenMainPanel() local isUnlock, content = MDL.Unlock.IsClientUnlockWithText(MDL.Unlock.FunctionType.PlotReviewLibrary, "IDS_Activity_Condition_01") if isUnlock then local levelFeatureType = DataSheetManager.LevelFeatureData:GetDataByLevelFeatureID(BattleDataGetter.GetCurLevelType()).LevelFeatureType if levelFeatureType == LuaConst.LevelFeatureType.Town then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIPlotReview) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_system_escapeforbid) end end end -- 根据传入的 PlotReviewData ID 和 是否连续状态,获取要播放的TimeLine列表 function PlotReviewLibrary_Controller.GetTimeLineList(id, isContinuous) local timeLineList = {} local pointData = DataSheetManager.PlotReviewData:GetDataByID(id) table.insert(timeLineList, pointData.PlotTimeline) if isContinuous then while pointData and pointData.PostPoint and next(pointData.PostPoint) do local _, nextPointData = DataSheetManager.PlotReviewData:TryGetDataByID(pointData.PostPoint[1]) if not nextPointData and #pointData.PostPoint > 1 then nextPointData = DataSheetManager.PlotReviewData:GetDataByID(pointData.PostPoint[2]) end pointData = nextPointData if pointData then local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(MDL.LevelSelect.Difficult.Normal) if pointData.BarrierID <= unlockLevelId then table.insert(timeLineList, pointData.PlotTimeline) end end end end return timeLineList end -- 计算红点整个功能是否有红点 function PlotReviewLibrary_Controller.CalculationMainLineRp() local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(MDL.LevelSelect.Difficult.Normal) local newDataDic = PersistentData.PlayerData:Get(PlotReviewLibrary_Controller.PlotReview_NewData, {}) for _, plotReviewData in DataSheetManager.PlotReviewData:GetEnumerator() do if plotReviewData.BarrierID > 0 and plotReviewData.BarrierID <= unlockLevelId then if not newDataDic[plotReviewData.ID] then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Library_PlotReview) EventSystem.Dispatch(EventID.PlotReview_CancelChapterRp) return end end end CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Library_PlotReview) EventSystem.Dispatch(EventID.PlotReview_CancelChapterRp) return end -- 计算当前选中的章节 是否有红点 function PlotReviewLibrary_Controller.CalculationChapterRp(plotType) local unlockLevelId = MDL.LevelSelect.GetUnlockLevelIdByDifficult(MDL.LevelSelect.Difficult.Normal) local newDataDic = PersistentData.PlayerData:Get(PlotReviewLibrary_Controller.PlotReview_NewData, {}) for _, plotReviewData in DataSheetManager.PlotReviewData:GetEnumerator() do if plotType == plotReviewData.PlotType then if plotReviewData.BarrierID <= unlockLevelId then if not newDataDic[plotReviewData.ID] then return true end end end end return false end function PlotReviewLibrary_Controller.CancelChapterRp(plotType) -- 记录已读 local newDataDic = PersistentData.PlayerData:Get(PlotReviewLibrary_Controller.PlotReview_NewData, {}) local refreshRedPoint = false for _, plotReviewData in DataSheetManager.PlotReviewData:GetEnumerator() do if plotType == plotReviewData.PlotType and not newDataDic[plotReviewData.ID] then newDataDic[plotReviewData.ID] = true refreshRedPoint = true end end PersistentData.PlayerData:Set(PlotReviewLibrary_Controller.PlotReview_NewData, newDataDic, true) if refreshRedPoint then PlotReviewLibrary_Controller.CalculationMainLineRp() end end function PlotReviewLibrary_Controller.SetSelectState(firstSelectTab, secondSelectTab, id) private.selectState.firstSelectTab = firstSelectTab private.selectState.secondSelectTab = secondSelectTab private.selectState.selectId = id end function PlotReviewLibrary_Controller.GetSelectState() return private.selectState end -- 播放TimeLine function PlotReviewLibrary_Controller.PlayTimeLine(firstSelectTab, secondSelectTab, id, auto) CTL.PlotReviewLibrary.SetSelectState(firstSelectTab, secondSelectTab, id) table.clearArray(private.timeLineRewardNameList) CTL.Cutscene.PlayCutsceneList(CTL.PlotReviewLibrary.GetTimeLineList(id, auto), nil, private.OneTimeLineEndEvent, private.AllTimeLineEndEvent) end -- 单个TimeLine播放完回调 function private.OneTimeLineEndEvent(name) table.insert(private.timeLineRewardNameList, name) end -- 全部TimeLine播放完回调 function private.AllTimeLineEndEvent() CTL.HomeMain.SetEnterTownRestoreView(Const_UI_Lua.UIEnum.UIPlotReview) end function PlotReviewLibrary_Controller.ReceiveAllReward() for _, name in ipairs(private.timeLineRewardNameList) do local cutsceneData for _, v in DataSheetManager.CutsceneList:GetEnumerator() do if v.CutsceneID == name then cutsceneData = v break end end if not cutsceneData then return end end table.clearArray(private.timeLineRewardNameList) end -- 播放CG function PlotReviewLibrary_Controller.PlayCG(id) local pointData = DataSheetManager.PlotReviewData:GetDataByID(id) UIManager.CloseSpecialView(Const_UI_Lua.UIEnum.UILoginVideo) local context = {movieID = pointData.CGName, banSkipTime = 1, autoPassTime = -1, noNeedBI = true, callback = private.CGEndEvent, needPause = true} UIManager.OpenView(Const_UI_Lua.UIEnum.UIMoviePanel, context) CTL.Sound.PlayGameSound(pointData.CGVoice) end function private.CGEndEvent(cgName) EventSystem.Dispatch(EventID.PlotReview_EndCG, cgName) end function PlotReviewLibrary_Controller.ResetLevelSound() local data = DataSheetManager.LevelInfoData:GetDataByLevelID(LevelManager.GetCurLevelID()) if data and not string.isNilOrEmpty(data.LevelSound) then CTL.Sound.PlayGameSound(data.LevelSound) else CTL.Sound.PlayGameSound("MUSiC_empty") end end return PlotReviewLibrary_Controller