local PlayerGuide_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') PlayerGuide_Controller.QuadrantType = { NONE = 0, RT = 1, --左上 RB = 2, --右下 LT = 3, --左下 LB = 4, --右上 } PlayerGuide_Controller.ActionType = { ObjNode = 1, -- 查找节点 LoopScrollRect = 2, --查找loopscroll index Euqipment = 3, -- 查找装备 HideNode = 4, -- 隐藏节点 ShowNode = 5, -- 显示节点 Buff = 6, -- 添加buff LoopScrollRectBtn = 7, -- 查找cell 下的button ActivityID = 8, HeroSelectId = 9, --武将展示界面武将id HeroShowPos = 10, --武将升阶 ToggleGroup = 11, --togglegroup 下的第几个 HeroChangeId = 12, ---武将切换界面的id } PlayerGuide_Controller.FinishAction = { SendMessage = 1, -- 发送给服务器算引导完成 DoNext = 2, -- 执行下一步引导 CloseView = 3, --关闭界面 DispatchEvent = 4, --派发事件 } local curGuideView = nil local curGuideData = nil local curLevelGuideCb = nil local DRIVE_GUIDE_ID = 32 -- 投石车引导id local ARRAY_GUIDE_ID = 1000 -- 布阵拖拽引导id local JP_ARRAY_GUIDE_ID = 1014 -- 日本布阵拖拽引导id local SETTING_GUIDE_ID = 100000 -- 设置界面引导id local VIRTUAL_CONTROLLER_ID = 1 -- 摇杆引导irtualController local GACHA_ID1 = 17 --抽卡引导id1 local GACHA_ID2 = 172 --抽卡引导id2 local AS_ID = 1007 --助阵引导id local CHAPTERGOAL_ID = 1009 -- 章节奖励 local SWEEP_EQUIP_ID = 2000 -- 扫荡一键装备引导 local SkipActionFunc = nil local AbTestGuideIDs = DataSheetManager.ConstData:GetDataByID("AbTestGuideID").IntListValue function PlayerGuide_Controller.OnStartup() EventSystem.Regist(EventID.UI_Guide_OnViewFocus,private.OnViewFocus) EventSystem.Regist(EventID.TeamLevelUpdate,private.OnLevelUpdate) EventSystem.Regist(EventID.UI_ShowGuildDriveBtn, private.ShowDriveBtn) EventSystem.Regist(EventID.PlayerGuide_StartGuideByLevelAction, private.StartGuideByLevelAction) EventSystem.Regist(EventID.UI_Task_Update,PlayerGuide_Controller.TryStartGuideNoView) SkipActionFunc = { private.SkipDrawCard, private.SkipWearEquip, private.SkipTenDrawCard, } end function private.OnViewFocus(viewName,value) if value then if curGuideData then PlayerGuide_Controller.FinishGuideByCompleteCondition(curGuideData,viewName) end PlayerGuide_Controller.TryStartGuide(viewName) else if curGuideView and not UIManager.IsFocus(curGuideView) then ---防止嵌套 在close里面改变焦点 又触发这里 又关闭一次 会报错 curGuideView = nil UIManager.CloseView(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue) end end end function PlayerGuide_Controller.TryStartGuide(viewName) if curGuideData then if curGuideData.ButtonContainer == viewName and curGuideData.ChildID ~= 1 then private.OpenGuide(viewName,curGuideData) return end end for i,v in DataSheetManager.GuideData:GetEnumerator() do if viewName == v.ButtonContainer and not MDL.PlayerGuide.IsComplete(v.ID,v.ChildID) then local isTrigger = #v.Trigger_Table > 0 for _,trigger in ipairs(v.Trigger_Table) do if not MDL.Unlock.IsComplete(trigger.Condition,trigger.ConditionParam) then isTrigger = false break end end if isTrigger then private.OpenGuide(viewName,v) end end end end function private.OpenGuide(viewName,guideData) local obj = nil if guideData.PushButtonType == PlayerGuide_Controller.ActionType.HideNode then ----- local transf = UIManager.FindViewTransform(guideData.ButtonContainer, nil, true) private.ActiveNode(transf,guideData.PushButton,false) PlayerGuide_Controller.FinishGuide(guideData,false) PlayerGuide_Controller.StartGuide(guideData.ID,guideData.ChildID + 1) return elseif guideData.PushButtonType == PlayerGuide_Controller.ActionType.ShowNode then ------ local transf = UIManager.FindViewTransform(guideData.ButtonContainer, nil, true) private.ActiveNode(transf,guideData.PushButton,true) PlayerGuide_Controller.FinishGuide(guideData,false) PlayerGuide_Controller.StartGuide(guideData.ID,guideData.ChildID + 1) return elseif guideData.PushButtonType == PlayerGuide_Controller.ActionType.Buff then NotSyncBattleSetter.AddBuffToMainEntity(tonumber(guideData.PushButton2)) PlayerGuide_Controller.FinishGuide(guideData,false) PlayerGuide_Controller.StartGuide(guideData.ID,guideData.ChildID + 1) return elseif guideData.PushButtonType == PlayerGuide_Controller.ActionType.HeroSelectId then EventSystem.Dispatch(EventID.UI_HeroSelect_SelectHero,tonumber(guideData.PushButton2)) end if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue) then return end if guideData.OpenPanel == 1 then EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightBottom, true) elseif guideData.OpenPanel == 2 then EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightTop, true) end curGuideView = guideData.ButtonContainer curGuideData = guideData if guideData.ID == ARRAY_GUIDE_ID or guideData.ID == JP_ARRAY_GUIDE_ID then --上阵引导 机制不太一样 UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerGuideHandMove, {guideData = guideData }) elseif guideData.ID == VIRTUAL_CONTROLLER_ID then --摇杆引导 if GameAppInfo.IsPCOrMacPackage() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIPCMoveGuideControl, {guideData = guideData }) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerGuideControl, {guideData = guideData }) end elseif guideData.ID == SETTING_GUIDE_ID then --设置引导 UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingInitial) else -- 普通引导 UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue, {guideData = guideData }) private.StartGuide201Level(guideData.ID) end end function private.ActiveNode(root,nodeStrs,active) local values = string.split( nodeStrs,",") for i,v in ipairs(values) do local childTf = UTL.UIRender.FindInChildren(root,v) childTf.gameObject:SetActive(active) end end --当满足条件时,结束当前引导 function PlayerGuide_Controller.FinishGuideByCompleteCondition(guideData,completeConditionParam) if guideData~= nil and PlayerGuide_Controller.CheckReachCompleteCondition(guideData.ID,guideData.ChildID,completeConditionParam) then PlayerGuide_Controller.FinishGuide(guideData,false) end end function PlayerGuide_Controller.FinishGuide(guideData,isSkip) LevelManager.PauseLevel(false) curGuideView = nil curGuideData = nil UIManager.CloseView(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue) if guideData.RepetitionType == 1 then MDL.PlayerGuide.SetFinishChild(guideData.ID) else MDL.PlayerGuide.SetFinishChild(guideData.ID, guideData.ChildID) end CTL.FunctionNotice.OnFinishPlayerGuide(guideData.ID) private.SendBI(guideData,isSkip) if isSkip then if not MDL.PlayerGuide.IsComplete(guideData.ID) then MDL.PlayerGuide.SendFinishGuide(guideData.ID) end if guideData.SkipAction>0 then local func = SkipActionFunc[guideData.SkipAction] if func then func() end end private.OnFinishCb(guideData) return end for i,v in ipairs(guideData.Completed_Table) do if PlayerGuide_Controller.FinishAction.DoNext == v.Actions and not isSkip then --执行下一小步引导 curGuideData = DataSheetManager.GuideData:GetDataByID_ChildID(guideData.ID,guideData.ChildID + 1) if UIManager.IsFocus(curGuideData.ButtonContainer) and not PlayerGuide_Controller.IsABTestGuide(guideData.ID) then PlayerGuide_Controller.StartGuide(curGuideData.ID,curGuideData.ChildID) end elseif PlayerGuide_Controller.FinishAction.SendMessage == v.Actions and not isSkip then -- 给服务器发送引导完成 if v.ActionParameters and string.len(v.ActionParameters) > 0 then MDL.PlayerGuide.SendFinishGuide(tonumber(v.ActionParameters)) else MDL.PlayerGuide.SendFinishGuide(guideData.ID) end private.OnFinishCb(guideData) elseif PlayerGuide_Controller.FinishAction.CloseView == v.Actions then --引导关闭界面 UIManager.CloseView(v.ActionParameters) elseif PlayerGuide_Controller.FinishAction.DispatchEvent == v.Actions then -- 派发事件 if not GameAppInfo.IsPCOrMacPackage() or guideData.ID ~= VIRTUAL_CONTROLLER_ID then EventSystem.Dispatch(v.ActionParameters) end end end end function private.SendBI(guideData,isSkip) local count = 0 for k,v in DataSheetManager.GuideData:GetDataByID_ChildID(guideData.ID) do count = count + 1 end EventSystem.Dispatch(EventID.BI_LevelMiddle,BIManager.BIType.PlayerGuide,isSkip,guideData.ID,guideData.ChildID,count) --BIManager end function PlayerGuide_Controller.OnLevelUpdate() PlayerGuide_Controller.TryStartGuideNoView() end function PlayerGuide_Controller.StartGuide(id,childId) -- 开始引导 不检测条件 用于关卡触发 其它外部触发 if MDL.PlayerGuide.IsComplete(id,childId) then return end childId = childId or 1 local isSucess, guideData = DataSheetManager.GuideData:TryGetDataByID_ChildID(id,childId) if not isSucess then return end private.OpenGuide(guideData.ButtonContainer,guideData) end function private.StartGuideByLevelAction(id,cb) -- 开始引导 不检测条件 用于关卡触发 local useNewGuideLevel = CTL.Login.GetLocalABTestMode() if GameAppInfo.IsJapanesePackage() then if id == 30014 and BattleDataGetter.GetAutoFightState() then return end else if useNewGuideLevel == 1 and id == 30014 and BattleDataGetter.GetAutoFightState() then return end end if cb then curLevelGuideCb = cb end PlayerGuide_Controller.StartGuide(id,1) end function PlayerGuide_Controller.TryStartGuideNoView() --遍历所有引导 是否有引导开始 for i,v in DataSheetManager.GuideData:GetEnumerator() do if not MDL.PlayerGuide.IsComplete(v.ID,v.ChildID) then local isTrigger = #v.Trigger_Table > 0 for _,trigger in ipairs(v.Trigger_Table) do if not MDL.Unlock.IsComplete(trigger.Condition,trigger.ConditionParam) then isTrigger = false end end if isTrigger then if UIManager.IsFocus(v.ButtonContainer) then private.OpenGuide(v.ButtonContainer,v) return end end end end end function PlayerGuide_Controller.TestStartGuide(id,childId) -- 测试引导接口 childId = childId or 1 local guideData = DataSheetManager.GuideData:GetDataByID_ChildID(id,childId) if guideData == nil then return end local obj = nil MDL.PlayerGuide.TestId = id if guideData.PushButtonType == PlayerGuide_Controller.ActionType.HideNode then ----- local transf = UIManager.FindViewTransform(guideData.ButtonContainer, nil, true) private.ActiveNode(transf,guideData.PushButton,false) PlayerGuide_Controller.FinishGuide(guideData,false) PlayerGuide_Controller.TestStartGuide(guideData.ID,guideData.ChildID + 1) return elseif guideData.PushButtonType == PlayerGuide_Controller.ActionType.ShowNode then ------ local transf = UIManager.FindViewTransform(guideData.ButtonContainer, nil, true) private.ActiveNode(transf,guideData.PushButton,true) PlayerGuide_Controller.FinishGuide(guideData,false) PlayerGuide_Controller.TestStartGuide(guideData.ID,guideData.ChildID + 1) return elseif guideData.PushButtonType == PlayerGuide_Controller.ActionType.Buff then NotSyncBattleSetter.AddBuffToMainEntity(tonumber(guideData.PushButton2)) PlayerGuide_Controller.FinishGuide(guideData,false) PlayerGuide_Controller.TestStartGuide(guideData.ID,guideData.ChildID + 1) return end if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue) then return end if guideData.OpenPanel == 1 then EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightBottom, true) elseif guideData.OpenPanel == 2 then EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightTop, true) end curGuideView = guideData.ButtonContainer if guideData.ID == ARRAY_GUIDE_ID or guideData.ID == JP_ARRAY_GUIDE_ID then --上阵引导 机制不太一样 UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerGuideHandMove,{guideData = guideData }) elseif guideData.ID == VIRTUAL_CONTROLLER_ID then -- 摇杆引导 UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerGuideControl,{guideData = guideData }) else --普通引导 UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue,{guideData = guideData }) end end function private.ShowDriveBtn(isShow) if LevelManager.IsMonsterTest() then return end if isShow then PlayerGuide_Controller.StartGuide(DRIVE_GUIDE_ID,1) else if curGuideData and curGuideData.ID == DRIVE_GUIDE_ID and curGuideData.ChildID == 1 then UIManager.CloseView(Const_UI_Lua.UIEnum.UIPlayerGuideDialogue) end end end --是否支持跳过 function PlayerGuide_Controller.IsCanSkip(id,childId) local guideData = DataSheetManager.GuideData:GetDataByID_ChildID(id,childId) if guideData~=nil then return guideData.CompletedType==1 else return false end end --校验引导完成条件 function PlayerGuide_Controller.CheckReachCompleteCondition(id,childId,otherParam) local completedCondition =0 local completeConditionParam=0 local guideData = DataSheetManager.GuideData:GetDataByID_ChildID(id,childId) local isUnlock = false if guideData~= nil and #guideData.CompletedTrigger_Table > 0 then for i = 1, #guideData.CompletedTrigger_Table do local temp=guideData.CompletedTrigger_Table[i] completedCondition= temp.CompletedCondition completeConditionParam =temp.CompleteConditionParam if completedCondition ~= 0 and completeConditionParam ~= 0 then if completedCondition== LuaConst.UnlockConditionType.CompleteMainAndSubStory then isUnlock = MDL.Unlock.IsComplete(completedCondition, completeConditionParam) elseif completedCondition== LuaConst.UnlockConditionType.OpenUIView then isUnlock= completeConditionParam==otherParam end end if isUnlock then return isUnlock end end return isUnlock or PlayerGuide_Controller.IsABTestGuide(id) end return isUnlock end function PlayerGuide_Controller.OnSetFinishInfo(info) --引导是否全部完成 删除注册函数 local isAllFinish = true for i,v in DataSheetManager.GuideData:GetEnumerator() do if not MDL.PlayerGuide.IsComplete(v.ID,v.ChildID) then isAllFinish = false end end if isAllFinish then EventSystem.UnRegist(EventID.UI_Guide_OnViewFocus,private.OnViewFocus) EventSystem.UnRegist(EventID.TeamLevelUpdate,private.OnLevelUpdate) EventSystem.UnRegist(EventID.UI_ShowGuildDriveBtn, private.ShowDriveBtn) end end function PlayerGuide_Controller.TryStartGaChaGuide() if not MDL.PlayerGuide.IsComplete(GACHA_ID1,1) then PlayerGuide_Controller.StartGuide(GACHA_ID1,1) elseif not MDL.PlayerGuide.IsComplete(GACHA_ID2,1) then PlayerGuide_Controller.StartGuide(GACHA_ID2,1) end end function PlayerGuide_Controller.TryStartAssistanceFightGuide() if not MDL.PlayerGuide.IsComplete(AS_ID,1) then PlayerGuide_Controller.StartGuide(AS_ID,1) end end function PlayerGuide_Controller.TryStartChapterGoalGuide() if not MDL.PlayerGuide.IsComplete(CHAPTERGOAL_ID,1) then PlayerGuide_Controller.StartGuide(CHAPTERGOAL_ID,1) end end function PlayerGuide_Controller.TryStartSweepEquipGuide() if not MDL.PlayerGuide.IsComplete(SWEEP_EQUIP_ID,1) then PlayerGuide_Controller.StartGuide(SWEEP_EQUIP_ID,1) end end function private.OnFinishCb(guideData) if curLevelGuideCb then curLevelGuideCb(guideData.ID) end curLevelGuideCb = nil return end function private.SkipDrawCard() local id = MDL.DrawCard.GetCurCardPoolID() if id < 1 then id = 1 end if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGachaMain) then MDL.DrawCard.RequestDrawCard(id, 1) else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGachaMain, {cardPoolId = id, drawNum = 1}) end end function private.SkipWearEquip() CTL.Equipment.GuideWearEquip() end function private.SkipTenDrawCard() local id = MDL.DrawCard.GetCurCardPoolID() if id < 1 then id = 1 end MDL.DrawCard.RequestDrawCard(id, 10) end --是否正在强制引导 function PlayerGuide_Controller.IsForceGuiding() return curGuideData and (curGuideData.GuideType ~= 2 and curGuideData.GuideType ~= 1) end --20220818 显礼需求 暂不生效 后续还要不要待定 function PlayerGuide_Controller.IsABTestGuide(id) return false end --是否需要短引导 所有的新兴渠道:b站、tap、好游用短引导 function private.IsNeedUseShortGuide() local channelID = SDKUtil.ChannelID local subChannelID = SDKUtil.SubChannelID if channelID == LuaConst.SDKChannelId.BiliBili then --B站 return true elseif channelID == LuaConst.SDKChannelId.Hero_Android then --英雄安卓 if subChannelID == LuaConst.SDKSubChannelId.HaoYouKuaiBao or subChannelID == LuaConst.SDKSubChannelId.TapTap then return true end end return false end function private.StartGuide201Level(guideId) if guideId == 30023 then BIManager.DispatchBIClientEvent(BIManager.EventName.StartGuideLevel201) end end return PlayerGuide_Controller