local Guide_Controller = {} local EventSystem = require('Event/EventSystem') local private = {} local K0Map = 1000 --新的新手关,章节地图里没有 local K1_1LevelID = 10101 --老的新手关,章节地图的1-1 local GuideLevelBeginStep, GuideLevelEndStep = -1, 1 --当前step为-1或0则是新手关,1则过了新手关了 function Guide_Controller.OnStartup() EventSystem.Regist(EventID.Guide_SetGuideStep, private.SetNextGuideStep) end function Guide_Controller.CheckInGuideLevel() return MDL.Guide.GetGuideStep() < GuideLevelEndStep end --结束所有的新手关,包括step为0和小于0的 function Guide_Controller.EndGuideLevel() private.SetNextGuideStep(GuideLevelEndStep) Guide_Controller.HandleGuideSummary() end function private.GetLevelIDAndMap(step) if step == GuideLevelBeginStep then return nil, K0Map --如果没有id只有map,表示这个关卡没有配置在BarrierChosenData里,直接用layout1000的map elseif step == GuideLevelBeginStep + 1 then return K1_1LevelID --有id,则从BarrierChosenData里找map end end function private.SetNextGuideStep(step) if step <= MDL.Guide.GetGuideStep() then return -- 只有递增才设置和触发stepNextSet的相应逻辑 end UIUtils.SetScreenBlack(true) private.stepNextSet = step end function private.TryEnterFubenByStep(step) local entered local levelID, mapID = private.GetLevelIDAndMap(step) if mapID then --进第0关,对应step -1 MDL.LevelSelect.EnterFuben(LuaConst.LevelType.NORMAL, K1_1LevelID - 1, nil, K0Map) --K0没有对应的levelID,先传一个不存在但是有区别的,目前没有问题 entered = true elseif levelID then --进新手1-1关,可能是通完0关的a包用户,可能是初始新手的b包用户 local barrierChosenData = DataSheetManager.BarrierChosenData:GetDataByID(levelID) MDL.LevelSelect.EnterFuben(LuaConst.LevelType.NORMAL, levelID, nil, barrierChosenData.MissonDataID[1]) entered = true end return entered end function Guide_Controller.HandleGuideStep(step) NotSyncBattleSetter.SetGuideLevelState(step < GuideLevelEndStep) private.TryEnterFubenByStep(step) end --新手关结算,设置了nextStep就进入next,否则进入当前的step function Guide_Controller.HandleGuideSummary() local nextStep = private.stepNextSet if nextStep then private.stepNextSet = nil MDL.Guide.SetGuideStepRequest(nextStep) --在协议回包里处理,会走到HandleGuideStep然后进入next的副本 return true end --没有设置nextStep,进入当前的step副本 local curStep = MDL.Guide.GetGuideStep() return private.TryEnterFubenByStep(curStep) end return Guide_Controller