local WarZone_Controller = {} local EventSystem = require('Event/EventSystem') WarZone_Controller.TimeState = { NotStart = 1, Preview = 2, Start = 3 } function WarZone_Controller.OnStartup() EventSystem.Regist(EventID.FunctionUnlockUpdate, WarZone_Controller.RefreshInfoByFunction) end function WarZone_Controller.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.CountryWorldBoss then if not isUnlock then WarZone_Controller.CloseAllFuncPanel() end end end function WarZone_Controller.CloseAllFuncPanel() UIManager.CloseView(Const_UI_Lua.UIEnum.UIWarzoneList) UIManager.CloseView(Const_UI_Lua.UIEnum.UIWorldBossSetting) UIManager.CloseView(Const_UI_Lua.UIEnum.UICommonNoteView) EventSystem.Dispatch(EventID.UI_CountryWorldBoss_OnCloseGamePlay) end function WarZone_Controller.GetTimeState() local timeInfo = MDL.WarZone.GetTimeInfo() if timeInfo and timeInfo.noticeTime ~= 0 and timeInfo.startTime ~= 0 then local curTimer = UTL.Time.GetServerTimestamp() if curTimer >= timeInfo.noticeTime and curTimer < timeInfo.startTime then local remainTimer = timeInfo.startTime - curTimer return WarZone_Controller.TimeState.Preview, remainTimer > UTL.Time.TotalSecondsOneHour and UTL.Time.FormatTimeClockBySeconds(remainTimer) or UTL.Time.FormatTimeSeconds(remainTimer) elseif curTimer >= timeInfo.startTime then return WarZone_Controller.TimeState.Start end end return WarZone_Controller.TimeState.NotStart end function WarZone_Controller.IsInWarZonePeriod(startTimer) if not startTimer then return false end local warzoneStartTimer = 0 local state = CTL.WarZone.GetTimeState() if state == WarZone_Controller.TimeState.Start then local timeInfo = MDL.WarZone.GetTimeInfo() warzoneStartTimer = timeInfo and timeInfo.startTime or 0 end return warzoneStartTimer ~= 0 and startTimer >= warzoneStartTimer end function WarZone_Controller.IsWarZoneOpen() return WarZone_Controller.GetTimeState() >= WarZone_Controller.TimeState.Start end return WarZone_Controller