local TreasureBowl_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local TreasureBowlActiveView = { Const_UI_Lua.UIEnum.UITreasureBowlPanel, Const_UI_Lua.UIEnum.UITreasureBowlReward, } function TreasureBowl_Controller.OnStartup() EventSystem.Regist(EventID.UI_OperationActivity_InfoChanged, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.New_Day_Refresh, private.RefreshNewDay) private.ActivityType = MDL.OperationActivity.ActivityType.TreasureBowl private.NewDay = false end function private.RefreshNewDay() private.NewDay = true EventSystem.Dispatch(EventID.UI_TreasureBowl_UpdateRedPoint) end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.TreasureBowl then if not isUnlock then for i, v in ipairs(TreasureBowlActiveView) do UIManager.CloseView(v) end end end end function TreasureBowl_Controller.OpenMainPanel() local info = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType) if info then for activityId, v in pairs(info) do UIManager.OpenView(Const_UI_Lua.UIEnum.UITreasureBowlPanel, {activityId = activityId}) private.NewDay = false EventSystem.Dispatch(EventID.UI_TreasureBowl_UpdateRedPoint) return end end end function TreasureBowl_Controller.GetTreasureBowlRedPoint() local remainCount = MDL.TreasureBowl.GetTreasureBowlAvailableCount() local maxCount = MDL.OperationActivity.TreasureBowlReward:GetDataLengthByActivityID(MDL.TreasureBowl.GetActivityId()) local drawCount = MDL.TreasureBowl.GetDrawCount(MDL.TreasureBowl.GetActivityId()) return remainCount > 0 or (private.NewDay and drawCount < maxCount) end function private.CheckFuncOpenIssue() if not CTL.OperationActivity.IsOperationActivityTypeOpen(private.ActivityType) or not CTL.OperationActivity.IsOperationActivityTypeUnlock(private.ActivityType) or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.TreasureBowl) then for i, v in ipairs(TreasureBowlActiveView) do UIManager.CloseView(v) end end end return TreasureBowl_Controller