local SyncFourCountryWar_Controller = {} local EventSystem = require('Event/EventSystem') local private = {} function SyncFourCountryWar_Controller.OnStartup() EventSystem.Regist(EventID.UI_FourCountryWar_StageChange, private.OnStageChange) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.VoiceRoom_OnServerRoomInitStateResp, private.OnServerRoomInitStateResp) EventSystem.Regist(EventID.TimerWheelStartTimeOver, private.SetActivityRedPoint) EventSystem.Regist(EventID.TimerWheelEndTimeOver, private.SetActivityRedPoint) end function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.SyncFourCountryWar then if not isUnlock then private.OnStageChange(0) end end end function SyncFourCountryWar_Controller.ReOpenSelectHeroPanel() if MDL.SyncFourCountryWar.GetReopenSelectHero() == true then local countryId = MDL.SyncFourCountryWar.GetMatchResult().friendlyFighters[1].campId UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISyncFourCountryWarSelectHeroPanel, { countryId = countryId }, Const_UI_Lua.UIEnum.UISyncTeamPVPSelectHeroPanel) MDL.SyncFourCountryWar.SetReopenSelectHero(false) end end function SyncFourCountryWar_Controller.OpenMainPanel() if MDL.SyncFourCountryWar.IsOpen() then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISyncFourCountryWarMain) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_FairPlay_3v3NotOpen) end end function private.SetActivityRedPoint(timeId, activityId, timeIndex) if activityId == LuaConst.ActivityType.SyncFourCountryWar then SyncFourCountryWar_Controller.RefreshRedPoint() end end function SyncFourCountryWar_Controller.RefreshRedPoint() local stage = MDL.SyncFourCountryWar.GetCurStage() if stage ~= 3 or not CTL.Activities.IsOpeningTime(LuaConst.ActivityType.SyncFourCountryWar) then EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.SyncFourCountryWar, false) else local time = MDL.RedPoint.GetRedPointTimeByType(MDL.RedPoint.RedPointType.SyncFourCountryWar) if time and time > 0 and UTL.Time.IsTimestampSameDay(time) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.SyncFourCountryWar) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.SyncFourCountryWar, false) else CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.SyncFourCountryWar) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.SyncFourCountryWar, true) end end end function SyncFourCountryWar_Controller.RemoveRedPoint() if CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.SyncFourCountryWar) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.SyncFourCountryWar) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.SyncFourCountryWar, false) MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.SyncFourCountryWar, 1, true, LuaConst.ActivityType.SyncFourCountryWar) end end function private.OnStageChange(stage) if stage <= 1 then UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncFourCountryWarRank) UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncFourCountryWarReward) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISyncFourCountryWarStore) then UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncFourCountryWarStore) UIManager.CloseView(Const_UI_Lua.UIEnum.UIPayMallPopUp) end UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncFourCountryNote) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UISyncFourCountryWarMain) end end function SyncFourCountryWar_Controller.GetEndTimeOffset(activityData) local endData = DataSheetManager.TimeRefresh:GetDataByID(activityData.Time_Table[1].EndTime) local dayRefreshTime = DataSheetManager.TimeRefresh:GetDataByID(1) local endTime = endData.HMS if endData.HMS < dayRefreshTime.HMS then return dayRefreshTime.HMS - endData.HMS end return UTL.Time.TotalSecondsOneDay - endData.HMS + dayRefreshTime.HMS end function private.OnServerRoomInitStateResp(roomType) if roomType == MDL.VoiceRoom.VoiceRoomType.Room_SyncFourCountry then local listenerState, microState = MDL.VoiceRoom.GetVoiceRoomInitState(roomType) local roomId = MDL.SyncFourCountryWar.GetBattleChatChannel() CTL.VoiceRoom.EnterVoiceRoom(roomType, roomId, listenerState, microState) end end return SyncFourCountryWar_Controller