local SyncFourCountryWar_Model = {} local sync_four_country_pb = require "Proto.sync_four_country_pb" local private = {} local EventSystem = require('Event/EventSystem') local SyncFourCountryStage = { none = 1, -- 没开 show = 2, -- 展示期 fight = 3, --战斗期 finish = 4, --休赛期 } local freeHeroList = {} SyncFourCountryWar_Model.EnemySquare = ConstAssetPathConfig.EnemySquare SyncFourCountryWar_Model.SelfSquare = ConstAssetPathConfig.SelfSquare SyncFourCountryWar_Model.TeamSquare = ConstAssetPathConfig.TeamSquare SyncFourCountryWar_Model.EnemyRound = ConstAssetPathConfig.EnemyRound SyncFourCountryWar_Model.SelfRound = ConstAssetPathConfig.SelfRound SyncFourCountryWar_Model.TeamRound = ConstAssetPathConfig.TeamRound function SyncFourCountryWar_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageGetSyncFourCountryMainPanel, private.GetSyncFourCountryMainPanel) NetManager.RegisterMsgCB(MessageEnums.MessageG2CSyncFourCountryBalanceInfo, private.G2CSyncFourCountryBalanceInfo) EventSystem.Regist(EventID.FourCountryWar_SendResult, private.SendFourCountryResult) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.OnEnterWorldPostprocess) end function private.OnEnterWorldPostprocess() CTL.SyncFourCountryWar.RefreshRedPoint() end function SyncFourCountryWar_Model.GetFreeHeroList() return freeHeroList end function SyncFourCountryWar_Model.GetSyncFourCountryMainPanelReq() local msg = sync_four_country_pb.GetSyncFourCountryMainPanelReq() NetManager.SendMessage(MessageEnums.MessageGetSyncFourCountryMainPanel, msg) end function private.GetSyncFourCountryMainPanel(msgResp) logging.log(LTAG.LOG, "GetSyncFourCountryMainPanel", msgResp) if msgResp.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_FourCountryWar_MainPanel, msgResp) freeHeroList = msgResp.freeHero end end function SyncFourCountryWar_Model.SyncFourCountryWarBattleMatchResultReceive(msg) logging.log(LTAG.LOG, "SyncFourCountryWarBattleMatchResultReceive", msg) private.matchResult = msg private.tickTime = msg.countDownTick private.battleChatChannel = msg.battleChatChannel if msg.needCountDown == true then --匹配返回时,什么情况下,可以打开匹配成功界面?这里在其他需要跳转场景的玩法处做判断,使用IsCanGoOtherScene UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncFourCountryWarMatchSuccessPanel, msg) else if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISyncFourCountryWarSelectHeroPanel) then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIHomeMain) then local countryId = msg.friendlyFighters[1].campId UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISyncFourCountryWarSelectHeroPanel, { countryId = countryId }, Const_UI_Lua.UIEnum.UISyncTeamPVPSelectHeroPanel) else MDL.SyncFourCountryWar.SetReopenSelectHero(true) end end end EventSystem.Dispatch(EventID.UI_SyncTeamPVP_MatchSuccess) end function SyncFourCountryWar_Model.GetMatchResult() return private.matchResult end function SyncFourCountryWar_Model.GetTickTime() return private.tickTime end function SyncFourCountryWar_Model.GetReopenSelectHero() return private.reopenSelectHero end function SyncFourCountryWar_Model.SetReopenSelectHero(isReopen) private.reopenSelectHero = isReopen end function SyncFourCountryWar_Model.GetBattleChatChannel() if private.battleChatChannel == nil then local gRoomId = BIManager.GetSyncBattleGRoomID() local campID = LevelPlayerManager.MainEntityCampID private.battleChatChannel = "sfc_"..gRoomId.."_"..campID end return private.battleChatChannel end function private.SendFourCountryResult(msg) NetManager.SendMessage(MessageEnums.MessageC2GUploadSyncFourCountryBattleResult, msg) end function private.G2CSyncFourCountryBalanceInfo(msgResp) logging.log(LTAG.LOG, "G2CSyncFourCountryBalanceInfo", msgResp) CTL.Sound.PlayGameSound("MUSIC_Victory") UIManager.CloseAllBase() SystemManager.PlayTimeline(ConstAssetPathConfig.AssetPath3, true, -1, function() UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncFourCountryWarSummaryPanel, msgResp) end, nil, nil, true) MDL.SyncTeamPVP.ResetSelfInfo() end function SyncFourCountryWar_Model.InitTime(msg) logging.log(LTAG.LOG, "InitTime", msg) private.stageTime = msg.StageTime private.todayGainCoin = msg.TodayGainCoin if IsProtoDataNotNil(msg.FreeHero) then freeHeroList = msg.FreeHero end CTL.SyncFourCountryWar.RefreshRedPoint() if private.curStage and private.curStage ~= msg.stage then private.curStage = msg.stage EventSystem.Dispatch(EventID.UI_FourCountryWar_StageChange, msg.stage) end private.curStage = msg.stage EventSystem.Dispatch(EventID.TeamActivityChange, LuaConst.ActivityType.SyncFourCountryWar) end function SyncFourCountryWar_Model.GetCurStage() return private.curStage end function SyncFourCountryWar_Model.IsOpen() return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SyncFourCountryWar) and private.curStage and private.curStage > 1 -- private.curStage and SyncFourCountryStage.show <= private.curStage end function SyncFourCountryWar_Model.IsForecast() return SyncFourCountryStage.show == private.curStage end function SyncFourCountryWar_Model.IsBattle() return SyncFourCountryStage.fight == private.curStage end function SyncFourCountryWar_Model.IsDisplay() return SyncFourCountryStage.finish == private.curStage end function SyncFourCountryWar_Model.GetStageTime() return private.stageTime end function SyncFourCountryWar_Model.GetRankText(rankIndex, score) if rankIndex <= 0 or (score and score<=0) then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroMatch1v1_NowResult5) else local max = DataSheetManager.ConstData:GetDataByID("SyncFourCountryRankNumMax").IntValue if max < rankIndex then return max .. "+" end end return rankIndex end return SyncFourCountryWar_Model