local FunctionNotice_Controller = {} local EventSystem = require('Event/EventSystem') local private = {} local AUTO_PREF_KEY = "AutoFunctionNotice" --是否已经自动弹出 function FunctionNotice_Controller.OnStartup() EventSystem.Regist(EventID.UI_UpdateFunctionNoticeUnlock, private.OnFunctionUnlockExp) EventSystem.Regist(EventID.UI_UpdateFunctionNoticeExpEnd, private.OnFunctionUnlockExp) EventSystem.Regist(EventID.UI_UpdateFunctionUnlockAward, private.OnRewardChange) EventSystem.Regist(EventID.UI_UpdateFunctionNoticeUnlock, private.OnRewardChange) private.isCheatCloseNotice = false private.isExpInDelay = false end function FunctionNotice_Controller.OpenFunctionPreview(funcID) local content = funcID and { [1] = funcID } or nil UIManager.OpenView(Const_UI_Lua.UIEnum.UIFunctionNoticeMain, content) end --部分表现会夹在引导之间,需要监听引导结束 function FunctionNotice_Controller.OnFinishPlayerGuide(guideID) local info = MDL.FunctionNotice.GetExpInfoByGuideID(guideID) if info then private.TryUnlockExp(info) end end --功能解锁表现 function private.OnFunctionUnlockExp() local info = MDL.FunctionNotice.GetCurExpInfo() if info then private.TryUnlockExp(info) else private.AutoShowFunctionNotice() end end function FunctionNotice_Controller.CheatCloseNotice() private.isCheatCloseNotice = true end function FunctionNotice_Controller.CheatOpenNotice(id) private.isCheatCloseNotice = false local unExpList = MDL.FunctionNotice.GetUnExpList() table.insert(unExpList, DataSheetManager.FunctionPredictionData:GetDataByFunctionPredictionID(id)) private.OnFunctionUnlockExp() end function private.TryUnlockExp(info) if private.ShowUnlockExpression(info) == false then if private.isExpInDelay == false then CTL.HomeMain.AddTownHomeDelayFuncNoUI(FunctionNotice_Controller.DelayUnlockExp) private.isExpInDelay = true end end end function FunctionNotice_Controller.DelayUnlockExp() private.isExpInDelay = false local info = MDL.FunctionNotice.GetCurExpInfo() if info then private.TryUnlockExp(info) end end --打断表现 function FunctionNotice_Controller.TryBreakUnlockExp() EventSystem.Dispatch(EventID.UI_FunctionNotice_BreakExp) end --主界面飘图标的表现 function private.ShowUnlockExpression(info) if private.isCheatCloseNotice then return true end if not MDL.Unlock.IsUnlock(info.FucID) then MDL.FunctionNotice.SetFunctionNoticeUnlockFalse(info.FucID) return true end if UIManager.IsFocus(Const_UI_Lua.UIEnum.UITownHome) == false then return false end --不重复表现 if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIFunctionUnlockShow) then return false end --保证按钮组展开 EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightBottom, false) EventSystem.Dispatch(EventID.UI_TownHome_Btn_Exchange, MDL.HomeMain.TownFoldType.RightTop, true) local context = { Config = info, } UIManager.OpenView(Const_UI_Lua.UIEnum.UIFunctionUnlockShow, context) return true end --满足条件自动弹出预告界面 function private.AutoShowFunctionNotice() local nextID = MDL.FunctionNotice.GetNextFuncID() if nextID > 0 then if private.GetIfSavePrefs(nextID) == false then local config = DataSheetManager.FunctionPredictionData:GetDataByFunctionPredictionID(nextID) if config and config.IsAutoEject == 2 then local isUnlock = true for _, v in pairs(config.Unlock_Table) do local tmpIsUnlock, tmpContent = MDL.Unlock.IsComplete(v.UnlockCondition, v.UnlockConditionParam) isUnlock = tmpIsUnlock if isUnlock == false then break end end if isUnlock then FunctionNotice_Controller.OpenFunctionPreview(nextID) private.SavePrefs(nextID) end end end end end function private.SavePrefs(funcID) local tb = PersistentData.PlayerData:Get(AUTO_PREF_KEY) if tb == nil then tb = {} end tb[funcID] = 1 PersistentData.PlayerData:Set(AUTO_PREF_KEY, tb, true) end function private.GetIfSavePrefs(funcID) local tb = PersistentData.PlayerData:Get(AUTO_PREF_KEY) local intValue = 0 if tb ~= nil then intValue = tb[funcID] if intValue == nil then intValue = 0 end end return intValue > 0 end function private.OnRewardChange() if MDL.FunctionNotice.GetIfAwardLeft() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.FunctionNotice_Award) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.FunctionNotice_Award) end end function FunctionNotice_Controller.ShowTownMiddleRemind(content, btn1Content, clickBtn1Func, btn2Content, clickBtn2Func) UIManager.OpenView(Const_UI_Lua.UIEnum.UITownMiddleRemind, { content = content, btn1Content = btn1Content, clickBtn1Func = clickBtn1Func, btn2Content = btn2Content, clickBtn2Func = clickBtn2Func }) end return FunctionNotice_Controller