local EventSystem = require('Event/EventSystem') local GuildWar_Model = {} local private = { killedCount = 0, redBossExpEntity = nil, blueBossExpEntity = nil, guildWarProtoDataCache= {}, guildWarProtoVersion = {}, } local guild_war_pb = require 'Proto/guild_war_operate_pb' local guild_war_base_pb = require 'Proto/guild_war_base_pb' local guild_war_enum_pb = require 'Proto/guild_war_enum_pb' local battle_common_pb = require 'Proto/battle_common_pb' local guildWarInfo = nil local groupInfos = nil local guildWarKillInfo = {} local GuildWarId = 101 local battleInfo = {selfCamp = {},enemyCamp = {}} local ScoutsList = {} --斥候列表 local readyStageTime = nil local bigMapInfo = {mapInfoLeft ={}, mapInfoMiddle={}, mapInfoRight={}, mapInfoResource={}} local bigMapItemIds={} local MiddleMapChongcheId = 10001 local KillMaxTitleId = nil local isFirstGetGuildInfo = true local crossServerInfo = {} --跨服分组服务器请求类型 GuildWar_Model.CrossServerZoneGroupType = { GuildWar = guild_war_enum_pb.GuildWar } -- 优化协议ID local ProtoOptID = { GuildWarHistoryRecordProto = 1, --势力战历史记录 } --投石车据点对应生成的投石车 地图id local StrongHoldToMonter = { [355011] = {[10001] = {2041, 2042}}, [355021] = {[10001] = {2031, 2032},[10002] = {2041, 2042},[10003] = {2051, 2052}}, [355031] = {[10001] = {2041, 2042}}, } GuildWar_Model.Stages = { StageTypeNone = -1, --活动未开启 StageTypeSignUp = 0, --//报名阶段 StageTypePrepare = 1, --//准备区阶段 StageTypeBattle = 2, --//战斗阶段 StageTypeEnd = 3, ---//已结束 } GuildWar_Model.FightStages = { FirstPrepare = 0, FirstFighting = 1, -- //第一场战斗中 FirstEnd = 2, -- //第一场已结束 SecondPrepare = 3, SecondFighting = 4, -- //第二场战斗中 SecondEnd = 5, -- //第二场已结束 } GuildWar_Model.Tags = { None = 0, -- 首期 Peak = 1, --巅峰 king = 2, --王者 Elite = 3, --精英 Combat = 4, --拼搏 Leisure = 5, --休闲 } GuildWar_Model.RoomTypes = { RoomMiddle = 1, --中 主战场 RoomLeft = 2, --左 高地战场 RoomRight = 3, -- 右 山谷战场 RoomResource = 4, --资源 物资战场 } GuildWar_Model.PrepareOperate = { Join = 0, --加入 Leave = 1,--离开 Lock = 2, --锁定 LockSave = 3, --锁定保存 UnLock = 4, --解锁 SetLimit = 5, --设置战力限制 KickLowScorePlayer = 6; --移除低战力玩家 } GuildWar_Model.PrePareStages = { AnyOne = 10, --所有人都能操作 SomeOne =11, --会长和太尉操作 SysTem = 12, --系统操作 } GuildWar_Model.HonorWalls = { MaxScore = 1, MaxKillNum = 2, Leader = 3, MaxContinuouskilling = 4, MaxAssiant = 5, } local BattleTipsType = { Occupy = 1, KillHero = 2, KillBoss = 3, } local DragonBuffTips = { self = "IDS_GuildWar_BattleTipText1" , enemy = "IDS_GuildWar_BattleTipText2" } local OccupyMyTips = "IDS_GuildWar_BattleReportText3" local OccupyOtherTips = "IDS_GuildWar_BattleReportText4" local MyCampDmgTips = "IDS_GuildWar_BattleReportText5" local OtherCampDmgTips = "IDS_GuildWar_BattleReportText6" local MyCampKillBossTips = "IDS_GuildWar_BattleReportText11" local OtherCampKillBossTips = "IDS_GuildWar_BattleReportText12" -- 势力战地图资源 local ImageResource_BatteringRamPoint = { My = { Main = "slz_zd_gongchengche04", Progress = "slz_zd_gongchengche03" }, Enemy = { Main = "slz_zd_gongchengche02", Progress = "slz_zd_gongchengche01" } } local ImageResource_BatteringRamSuperPoint = { My = { Main = "slz_icon_cjcc04", Progress = "slz_icon_cjcc02" }, Enemy = { Main = "slz_icon_cjcc03", Progress = "slz_icon_cjcc01" } } local ImageResource_MangonelPoint = { My = { Main = "slz_zd_toushiche_02", Progress = "slz_zd_toushiche_01" }, Enemy = { Main = "slz_zd_toushiche_04", Progress = "slz_zd_toushiche_03" } } local ImageResource_Camp_BatteringRam = "slz_icon_gcc" local ImageResource_Camp_Mangonel = "slz_icon_tsc" local PlayerNormalPointWidthAndHeight = {Width = 16, Height = 16} local ImageResource_Player = { Team = "slz_ad_dian_lv", Camp = "slz_ad_dian_lan", Enemy = "slz_ad_dian_hong", CampBomb = "zd_icon_zd01", EnemyBomb = "zd_icon_zd02", } local ImageResource_OccupationBar = { My = "slz_zd_bg03", Enemy = "slz_zd_bg02" } local ImageResource_Drivable_Ballista = { My = "slz_icon_nclv", Friend = "slz_icon_ncl", Enemy = "slz_icon_nch" } local ImageResource_Drivable_Mangonel = { My = "slz_icon_tsclv", Friend = "slz_icon_tscl", Enemy = "slz_icon_tsch" } local ImageResource_Quartermaster = { Friend = "slz_icon_jxl", Enemy = "slz_icon_jxh" } GuildWar_Model.MapItemIndex = { MiddleChongChe = 1, MiddleLeftTouShi = 2, MiddleRightTouShi = 3, LeftTouShi = 4, RightTouShi = 5, LeftBoss = 6, LeftEnemyCity = 7, LeftMyCity = 8, MiddleEnemyCity = 9, MiddleMyCity = 10, RightBoss = 11, RightEnemyCity = 12, RightMyCity = 13, } GuildWar_Model.CommandMapItemType = { MiddleChongChe = 3, --中央战车 MiddleLeftTouShi = 1, --中央左投石车 MiddleRightTouShi = 2, --中央右投石车 Resource = 4, -- 号召资源 LeftBoss = 5, -- 左BOSS LeftTouShi = 6, --左投石车 EnemyCity = 7, --敌方城门 MyCity = 8, --我方城门 } GuildWar_Model.SummaryType = { GuildWar = 1, GuildBoss = 2, SyncTeamPVP = 3, } local _hasSetVolume=false --是否设置了音量 local _lastSetVolumeTime=0 --上一次设置音量的时间 local lastSelectReviveIndex = {} --上一次选择的复活点 GuildWar_Model.ReviveType = { GuildWar = 1, ChangAnSiege = 2, } function GuildWar_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageGuildWarReduceResource, private.OnGuildWarReduceResourceResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarHpInfo, private.OnG2CPushGuildWarHpInfo) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarResult, private.OnG2CPushGuildWarResult) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarMapInfo, private.OnG2CPushGuildWarMapInfo) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarResource, private.OnG2CPushGuildWarResource) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarInfo, private.OnG2CPushGuildWarInfo) NetManager.RegisterMsgCB(MessageEnums.MessageEnterGuildWar, nil) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarPlayerScore, private.OnPushGuildWarPlayerScore) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarProduct,private.OnGetGuildWarProduct) NetManager.RegisterMsgCB(MessageEnums.MessageGuildWarSignUp, private.OnGuildWarSignUp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarPrepareInfo, private.OnPushGuildWarPrepareInfo) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarPrepareForWar, private.OnPushGuildWarPrepareForWar) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarHistoryMatch, private.OnPushHistoryRecord) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarHistoryHonorWall, private.OnPushHonorWall) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarStageInfo, private.OnPushGuildWarStageInfo) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushStringTips,private.OnPushStringTips ) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarBattleTips, private.OnBattleTips) --军团长聊天相关 NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarListenInfo, private.OnPushGuildWarListenInfo) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarConvene,private.OnPushGuildWarConvene) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildWarScoursList,private.OnPushGuildWarScoursList) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushAppointGuildWarScouts,private.OnPushAppointGuildWarScouts) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushCancelGuildWarScouts,private.OnPushCancelGuildWarScouts) NetManager.RegisterMsgCB(MessageEnums.MessageGuildWarSendCommandTips, nil) NetManager.RegisterMsgCB(MessageEnums.MessageG2CGuildWarCommandTips, private.OnG2CGuildWarCommandTips) NetManager.RegisterMsgCB(MessageEnums.MessageG2CGuildWarResourceCostNotify, private.OnG2CGuildWarResourceCostNotify) NetManager.RegisterMsgCB(MessageEnums.MessageG2CGuildWarSomeThingCanBuyNotify, private.OnG2CGuildWarSomeThingCanBuyNotify) EventSystem.Regist(EventID.GuildWar_SendResult , private.SendGuildWarResult) EventSystem.Regist(EventID.Level_InitLevel, private.OnInitLevel) EventSystem.Regist(EventID.GuildWar_MainPlayerBuy, private.OnMainPlayerBuy) --只有主角才会Dispath 下列事件↓ EventSystem.Regist(EventID.UI_GuildWarTips_InteractGetRes, private.ShowTips_InteractGetRes) EventSystem.Regist(EventID.UI_GuildWarTips_HandInRes, private.ShowTips_HandInRes) EventSystem.Regist(EventID.UI_GuildWarTips_DropRes, private.ShowTips_DropRes) EventSystem.Regist(EventID.UI_GuildWarTips_TouchGetRes, private.ShowTips_TouchGetRes) EventSystem.Regist(EventID.GuildWar_WallBorn, private.OnWallBorn) -- ↑ GuildWar_Model.MaxGuildWarBaseHp = DataSheetManager.GuildWar:GetDataByID(GuildWarId).GuildWarBaseHplmt for i,v in DataSheetManager.GuildWarElement:GetEnumerator() do for _,element in ipairs(v.Element_Table) do table.insert(bigMapItemIds,element) end end for i,v in DataSheetManager.GuildWarKillBroadcast:GetEnumerator() do KillMaxTitleId = v.ID end GuildWar_Model.RevivePanelIsOpen = false --记录复活界面应该是什么状态(显示、隐藏) end -----------网络信息发送-------------------- -- 登录下发势力战跨服活动开启预告 function GuildWar_Model.SyncGuildWarCrossOpen(msg) private.UpdateCrossInfo(msg) end function GuildWar_Model.SyncPlayerChangeCrossOpen(msg) private.UpdateCrossInfo(msg) EventSystem.Dispatch(EventID.UI_GuildAuctionTabRefresh) private.TryTriggerPushInterface() end function private.TryTriggerPushInterface() local isShow = CTL.GuildWar.IsGuildWarCrossServerPushInterface() CTL.PushInterface.TriggerUnlockPushInterface(Const_UI_Lua.UIEnum.UIPushInterfaceGuildWar, isShow) end function GuildWar_Model.SendGetGuildWarInfo() if MDL.Guild.IsHasGuild() then local msg = guild_war_pb.C2GGetGuildWarInfo() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarInfo,msg) end end function GuildWar_Model.EnterGuild() if not CTL.TeamMatch.IsCanGoOtherScene(LuaConst.LevelType.SyncGuildBoss) then return end local msg = guild_war_pb.EnterGuildWarReq() NetManager.SendMessage(MessageEnums.MessageEnterGuildWar,msg) GuildWar_Model.C2GGetGuildWarPrepareInfo() MDL.Guild.GetGuildInfoReq() end function GuildWar_Model.C2GGetGuildWarPlayerScore() local msg = guild_war_pb.C2GGetGuildWarPlayerScore() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarPlayerScore,msg) end function GuildWar_Model.C2GGetGuildWarProductReq() local msg = guild_war_pb.C2GGetGuildWarProductReq() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarProduct,msg) end function GuildWar_Model.GuildWarSignUpReq() if MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildWarSign) then local msg = guild_war_pb.GuildWarSignUpReq() NetManager.SendMessage(MessageEnums.MessageGuildWarSignUp,msg) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end end function GuildWar_Model.C2GGetGuildWarPrepareInfo() local msg = guild_war_pb.C2GGetGuildWarPrepareInfo() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarPrepareInfo,msg) end --收听 function GuildWar_Model.SendGuildWarListen(acid) local msg = guild_war_pb.C2GGuildWarListen() msg.acid=acid NetManager.SendMessage(MessageEnums.MessageC2GGuildWarListen,msg) end --取消收听 function GuildWar_Model.SendGuildWarCancelListen(acid) local msg = guild_war_pb.C2GGuildWarCancelListen() msg.acid=acid NetManager.SendMessage(MessageEnums.MessageC2GGuildWarCancelListen,msg) end --召集队员 function GuildWar_Model.SendGuildWarConvene() local msg = guild_war_pb.C2GGuildWarConvene() NetManager.SendMessage(MessageEnums.MessageC2GGuildWarConvene,msg) end --获取斥候列表 function GuildWar_Model.SendGetGuildWarScoutsList() local msg = guild_war_pb.C2GGetGuildWarScoutsList() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarScoutsList,msg) end --任命斥候 function GuildWar_Model.SendAppointGuildWarScouts(acid) local msg = guild_war_pb.C2GAppointGuildWarScouts() msg.acid=acid NetManager.SendMessage(MessageEnums.MessageC2GAppointGuildWarScouts,msg) end --取消任命 function GuildWar_Model.SendCancelGuildWarScouts(acid) local msg = guild_war_pb.C2GCancelGuildWarScouts() msg.acid=acid NetManager.SendMessage(MessageEnums.MessageC2GCancelGuildWarScouts,msg) end function GuildWar_Model.ChangeSelfPosForWar(opt, roomType, newPosId) local msg = guild_war_pb.C2GGuildWarPrepareForWar() msg.opt = opt msg.roomType = roomType msg.newPosId = newPosId - 1 NetManager.SendMessage(MessageEnums.MessageC2GGuildWarPrepareForWar,msg) end function GuildWar_Model.ChangeLimitGs(roomType,value) local msg = guild_war_pb.C2GGuildWarPrepareForWar() msg.opt = GuildWar_Model.PrepareOperate.SetLimit msg.roomType = roomType msg.fightScoreLimit = value NetManager.SendMessage(MessageEnums.MessageC2GGuildWarPrepareForWar,msg) end function GuildWar_Model.KickLowScorePlayer(roomType) local msg = guild_war_pb.C2GGuildWarPrepareForWar() msg.opt = GuildWar_Model.PrepareOperate.KickLowScorePlayer msg.roomType = roomType NetManager.SendMessage(MessageEnums.MessageC2GGuildWarPrepareForWar,msg) end function GuildWar_Model.BeginEdit() local msg = guild_war_pb.C2GGuildWarPrepareForWar() msg.opt = GuildWar_Model.PrepareOperate.Lock NetManager.SendMessage(MessageEnums.MessageC2GGuildWarPrepareForWar,msg) end function GuildWar_Model.EndEdit() local msg = guild_war_pb.C2GGuildWarPrepareForWar() msg.opt = GuildWar_Model.PrepareOperate.UnLock NetManager.SendMessage(MessageEnums.MessageC2GGuildWarPrepareForWar,msg) end function GuildWar_Model.SaveEdit() local msg = guild_war_pb.C2GGuildWarPrepareForWar() msg.opt = GuildWar_Model.PrepareOperate.LockSave for i,v in ipairs(groupInfos) do table.insert( msg.groupInfo,v) end --msg.groupInfo = groupInfos NetManager.SendMessage(MessageEnums.MessageC2GGuildWarPrepareForWar,msg) end function GuildWar_Model.RequestHonorWall() local msg = guild_war_pb.C2GGetGuildWarHistoryHonorWall() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarHistoryHonorWall,msg) end function GuildWar_Model.RequestHistoryRecord() local msg = guild_war_pb.C2GGetGuildWarHistoryMatch() msg.issueInfosVersion = private.GetProtoVersion(ProtoOptID.GuildWarHistoryRecordProto) NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarHistoryMatch, msg) end function GuildWar_Model.C2GGuildWarCommandTeam(teamId,targetId,name) local msg = guild_war_pb.C2GGuildWarCommandTeam() msg.commad.teamId = teamId msg.commad.targetId = targetId msg.commad.roomType = GuildWar_Model.GetRoomTypeByLevelType() if targetId > 0 then local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_Team,teamId) msg.tips = string.FormatByIdsId(Const_IDS.IDS_GuildWar_BattleReportText9, name,str,GuildWar_Model.GetElementNameByIndex(targetId)) else msg.tips = "" end NetManager.SendMessage(MessageEnums.MessageC2GGuildWarCommandTeam,msg) end function GuildWar_Model.C2GGetGuildWarMapInfo() local msg = guild_war_pb.C2GGetGuildWarMapInfo() NetManager.SendMessage(MessageEnums.MessageC2GGetGuildWarMapInfo,msg) end function GuildWar_Model.GuildWarReduceResourceReq(productId,level) local msg = guild_war_pb.GuildWarReduceResourceReq() msg.productId = productId msg.level = level NetManager.SendMessage(MessageEnums.MessageGuildWarReduceResource, msg) end -------------------------------------------- function GuildWar_Model.GetWarInfo() return guildWarInfo end function GuildWar_Model.GetGroupInfos() return groupInfos end function GuildWar_Model.GetGuildWarKillInfo() return guildWarKillInfo end function GuildWar_Model.GetBattleInfo() return battleInfo end function GuildWar_Model.GetCrossServerInfo() return crossServerInfo end function GuildWar_Model.InBattleTime(isEdit) local info = MDL.GuildWar.GetWarInfo() if isEdit then local time = info.battleOpenTime - DataSheetManager.ConstData:GetDataByID("GuildWarPrepareDeadlineTime").IntValue if UTL.Time.GetServerTimestamp() - time >= 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotInSignTime) return false end else local time = info.battleOpenTime - DataSheetManager.ConstData:GetDataByID("GuildWarMemberPrepareDeadlineTime").IntValue if UTL.Time.GetServerTimestamp() - time >= 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotInEditTime) return false end end return true end function GuildWar_Model.GetReadyStageTime() return readyStageTime end function GuildWar_Model.GetRoomTypeByLevelType() local levelType = BattleDataGetter.GetCurLevelType() if levelType == LuaConst.LevelType.SyncGuildWarMapLeft then --军团战左战场 return GuildWar_Model.RoomTypes.RoomLeft elseif levelType == LuaConst.LevelType.SyncGuildWarMapMiddle then --军团战中战场 return GuildWar_Model.RoomTypes.RoomMiddle elseif levelType == LuaConst.LevelType.SyncGuildWarMapRight then --军团战中战场 return GuildWar_Model.RoomTypes.RoomRight elseif levelType == LuaConst.LevelType.SyncGuildWarMapResources then --军团战中战场 return GuildWar_Model.RoomTypes.RoomResource end end function GuildWar_Model.IsBattleLeader(acid)--15人团长 local teamInfo = nil for i,v in ipairs(groupInfos) do local player = v.players[1] if player.isHasPlayer and player.headInfo.acid == acid then return true end end return false end function GuildWar_Model.ShowWallHpReportTips(isSelf , percent) local rate = percent * 10 local ids = nil if isSelf then ids = MyCampDmgTips else ids = OtherCampDmgTips end local str = string.FormatByIdsId(Const_IDS[ids], rate) CTL.GuildWar.ShowTips_BattleReport(str) end function GuildWar_Model.GetElementName(levelType,id) local data = DataSheetManager.GuildWarElement:GetDataByID(levelType) for _,element in ipairs(data.Element_Table) do if element.ElementID == id then return UIUtils.GetLocalizedTxt(Const_IDS[element.ElementName]) end end end function GuildWar_Model.GetElementNameByIndex(index) if index == GuildWar_Model.MapItemIndex.LeftBoss or index == GuildWar_Model.MapItemIndex.RightBoss then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp7) elseif index == GuildWar_Model.MapItemIndex.LeftEnemyCity or index == GuildWar_Model.MapItemIndex.MiddleEnemyCity or index == GuildWar_Model.MapItemIndex.RightEnemyCity then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp6) elseif index == GuildWar_Model.MapItemIndex.LeftMyCity or index == GuildWar_Model.MapItemIndex.MiddleMyCity or index == GuildWar_Model.MapItemIndex.RightMyCity then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp5) elseif index == GuildWar_Model.MapItemIndex.RightTouShi or index == GuildWar_Model.MapItemIndex.LeftTouShi then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp2) elseif index == GuildWar_Model.MapItemIndex.MiddleChongChe then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp1) elseif index == GuildWar_Model.MapItemIndex.MiddleLeftTouShi then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp3) elseif index == GuildWar_Model.MapItemIndex.MiddleRightTouShi then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Element_Camp4) end end function GuildWar_Model.GetElements() return bigMapItemIds end function GuildWar_Model.GetKillMaxTitleId() return KillMaxTitleId end function GuildWar_Model.IsHasPlayer(index) if groupInfos then local startIndex = (index - 1) * 3 + 1 local roomIndex = nil local players = nil for i, v in ipairs(groupInfos) do for _, player in ipairs(v.players) do if player.isHasPlayer and player.headInfo.acid == BattleDataGetter.GetAcID() then players = v.players break end end end for i = startIndex, startIndex + 1 do if players[i].isHasPlayer then return true end end end return false end -- 网络消息接收 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ function private.UpdateCrossInfo(msg) if IsServerDataNotNil(msg) then crossServerInfo.startTime = msg.startTime crossServerInfo.isFirst = msg.isFirst crossServerInfo.noticeTime = msg.noticeTime end end function private.OnG2CPushGuildWarResource(msg) local resourcesCount = msg.resources logging.log(LTAG.LOG , "get GuildWarResource msg : " ,resourcesCount) --todo:刷新资源数界面 end function private.OnG2CPushGuildWarMapInfo(msg) local mapInfoLeft = guild_war_pb.GuildWarMapInfos() mapInfoLeft:ParseFromString(msg.mapInfoLeft) local mapInfoRight = guild_war_pb.GuildWarMapInfos() mapInfoRight:ParseFromString(msg.mapInfoRight) local mapInfoMiddle = guild_war_pb.GuildWarMapInfos() mapInfoMiddle:ParseFromString(msg.mapInfoMiddle) local mapInfoResource = guild_war_pb.GuildWarMapInfos() mapInfoResource:ParseFromString(msg.mapInfoResource) bigMapInfo.mapInfoLeft = mapInfoLeft or nil bigMapInfo.mapInfoMiddle = mapInfoMiddle or nil bigMapInfo.mapInfoRight = mapInfoRight or nil bigMapInfo.mapInfoResource = mapInfoResource or nil EventSystem.Dispatch(EventID.UI_GuildWarBigMapUpdate,msg.commands, bigMapInfo, msg.playerInfos) end function private.SetBigMapInfo(info,msg) info.levelItemId = msg.levelItemId info.state = msg.state info.campId = msg.campId info.progress = msg.progress end function private.OnG2CPushGuildWarResult(msg) MDL.Level.TrySendBattleEvent() UIManager.CloseAllBase() UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleSummaryLogo, {msg = msg, summaryType = MDL.GuildWar.SummaryType.GuildWar}) battleInfo.selfCamp.hpValue = nil battleInfo.selfCamp.killNum = 0 battleInfo.enemyCamp.hpValue = nil battleInfo.enemyCamp.killNum = 0 guildWarKillInfo = {} end function private.OnG2CPushGuildWarHpInfo(msg) if battleInfo.selfIsRed then battleInfo.selfCamp.hpValue = msg.redHp battleInfo.selfCamp.killNum = msg.redKillNum battleInfo.enemyCamp.hpValue = msg.blueHp battleInfo.enemyCamp.killNum = msg.blueKillNum private.guildWarResourceCount = msg.redResource EventSystem.Dispatch(EventID.UI_GuildWarResourceUpdate, msg.redResource) else battleInfo.enemyCamp.hpValue = msg.redHp battleInfo.selfCamp.killNum = msg.blueKillNum battleInfo.selfCamp.hpValue = msg.blueHp battleInfo.enemyCamp.killNum = msg.redKillNum private.guildWarResourceCount = msg.redResource EventSystem.Dispatch(EventID.UI_GuildWarResourceUpdate, msg.blueResource) end if private.blueBossExpEntity and private.redBossExpEntity then private.blueBossExpEntity:SetModelUI_HP(battleInfo.selfCamp.hpValue, 0, GuildWar_Model.MaxGuildWarBaseHp) private.redBossExpEntity:SetModelUI_HP(battleInfo.enemyCamp.hpValue, 0, GuildWar_Model.MaxGuildWarBaseHp) end EventSystem.Dispatch(EventID.UI_GuildWarHpUpdate,battleInfo ,private.blueBossExpEntity ,private.redBossExpEntity) end function private.OnGuildWarReduceResourceResp(msg) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed1) end end function private.OnG2CPushGuildWarKillInfo(msg) table.insert(guildWarKillInfo,1, msg) EventSystem.Dispatch(EventID.UI_GuildWarKillInfoNotice, msg) end function private.OnGuildWarUploadKillInfoResp(msg) --msg.Resp end function private.OnG2CPushGuildWarInfo(msg) guildWarInfo = msg private.SetBattleInfo() CTL.GuildWar.CalNextStageTime(guildWarInfo) CTL.Guild.RefreshRedPoint() end function private.OnPushGuildWarPlayerScore(msg) -- if battleInfo.selfIsRed then -- battleInfo.selfCamp.rankInfo = msg.redRank -- battleInfo.enemyCamp.rankInfo = msg.blueRank -- else -- battleInfo.enemyCamp.rankInfo = msg.redRank -- battleInfo.selfCamp.rankInfo = msg.blueRank -- end EventSystem.Dispatch(EventID.UI_GuildWarInfoUpdate,msg) end function private.OnGetGuildWarProduct(msg) EventSystem.Dispatch(EventID.UI_GuildWarResourcesShopUpdate,msg) if private.lastLevel ~= msg.level or private.lastEnemyLevel ~= msg.enemyLevel then private.lastLevel = msg.level private.lastEnemyLevel = msg.enemyLevel local list = BattleDataGetter.GetEntityList_Sync() for i, entity in ipairs(list) do if entity:IsHero() then if entity:GetCampID() == BattleDataGetter.GetMyCampID() then EventSystem.Dispatch(EventID.UIBattle_Element_UpdateLevel, entity.ExpEntity.RenderEntity, msg.level) else EventSystem.Dispatch(EventID.UIBattle_Element_UpdateLevel, entity.ExpEntity.RenderEntity, msg.enemyLevel) end end end end CTL.GuildWar.RefreshShopRp(msg.product, msg.resources) end function GuildWar_Model.GetGuildWarLevel() return private.lastLevel or 1 end function GuildWar_Model.GetGuildWarEnemyLevel() return private.lastEnemyLevel or 1 end function private.OnGuildWarSignUp(msg) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_SignedSucceed) GuildWar_Model.SendGetGuildWarInfo() end end function private.OnPushGuildWarPrepareInfo(msg) groupInfos = msg.groupInfos EventSystem.Dispatch(EventID.UI_GuildWarGroupInfosUpdate,groupInfos) end function private.SetBattleInfo() if guildWarInfo.Stage >= GuildWar_Model.Stages.StageTypePrepare then local isFirst = guildWarInfo.Stage == GuildWar_Model.Stages.StageTypePrepare or (guildWarInfo.Stage == GuildWar_Model.Stages.StageTypeBattle and guildWarInfo.fightStage <= GuildWar_Model.FightStages.FirstEnd) for i,v in ipairs(guildWarInfo.groupMatchInfo) do if isFirst then for _,guildInfo in ipairs(v.matchInfoFirst) do if guildInfo.guildRed.guildId == MDL.Guild.GetMyGuildInfo().guildId then battleInfo.selfCamp.guildInfo = guildInfo.guildRed battleInfo.enemyCamp.guildInfo = guildInfo.guildBlue battleInfo.selfIsRed = true elseif guildInfo.guildBlue.guildId == MDL.Guild.GetMyGuildInfo().guildId then battleInfo.selfCamp.guildInfo = guildInfo.guildBlue battleInfo.enemyCamp.guildInfo = guildInfo.guildRed battleInfo.selfIsRed = false end end else for _,guildInfo in ipairs(v.matchInfoSecond) do if guildInfo.guildRed.guildId == MDL.Guild.GetMyGuildInfo().guildId then battleInfo.selfCamp.guildInfo = guildInfo.guildRed battleInfo.enemyCamp.guildInfo = guildInfo.guildBlue battleInfo.selfIsRed = true elseif guildInfo.guildBlue.guildId == MDL.Guild.GetMyGuildInfo().guildId then battleInfo.selfCamp.guildInfo = guildInfo.guildBlue battleInfo.enemyCamp.guildInfo = guildInfo.guildRed battleInfo.selfIsRed = false end end end end end end function private.RemovePlayer(msg) if groupInfos then for i, v in ipairs(groupInfos) do for pos,player in ipairs(v.players) do if player.isHasPlayer and player.headInfo.acid == msg.optPlayer.acid then player.isHasPlayer = false end end end end end function private.AddPlayer(msg) for i, v in ipairs(groupInfos) do if v.roomType == msg.roomType then if IsServerDataNotNil(msg.groupInfo) then groupInfos[i] = msg.groupInfo else if IsServerDataNotNil(msg.optPlayer) then for pos,player in ipairs(v.players) do if player.isHasPlayer and player.headInfo.acid == msg.optPlayer.acid then player.isHasPlayer = false elseif pos - 1 == msg.newPosId then player.isHasPlayer = true player.headInfo.acid = msg.optPlayer.acid player.headInfo.name = msg.optPlayer.name player.headInfo.level = msg.optPlayer.level player.headInfo.teamRankID = msg.optPlayer.teamRankID player.headInfo.mainHeroId = msg.optPlayer.mainHeroId player.headInfo.gsSum = msg.optPlayer.gsSum player.headInfo.PortraitId = msg.optPlayer.PortraitId player.headInfo.FrameId = msg.optPlayer.FrameId end end end end break end end end function private.SetGs(msg) for i, v in ipairs(groupInfos) do if v.roomType == msg.roomType then v.fightScoreLimit = msg.fightScoreLimit break end end end function private.OnPushGuildWarPrepareForWar(msg) logging.log(LTAG.LOG," OnPushGuildWarPrepareForWar ",msg) if msg.opt == GuildWar_Model.PrepareOperate.SetLimit then private.SetGs(msg) if msg.optPlayer.acid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed1) end elseif msg.opt == GuildWar_Model.PrepareOperate.Leave then private.RemovePlayer(msg) if msg.optPlayer.acid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_LeaveSucceed) end elseif msg.opt >= GuildWar_Model.PrepareOperate.Lock then GuildWar_Model.C2GGetGuildWarPrepareInfo() return end if msg.opt == GuildWar_Model.PrepareOperate.Join then if groupInfos then private.RemovePlayer(msg) private.AddPlayer(msg) end if msg.optPlayer.acid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_JoinTeamSucceed) end end EventSystem.Dispatch(EventID.UI_GuildWarGroupInfosUpdate,groupInfos) end function private.OnPushHistoryRecord(msg) local protoID = ProtoOptID.GuildWarHistoryRecordProto local isDataDirty = private.UpdateProtoVersion(protoID, msg.issueInfosVersion) if isDataDirty then private.guildWarProtoDataCache[protoID] = msg.issueInfos end EventSystem.Dispatch(EventID.UI_GuildWarPastScoreList_Refresh, private.guildWarProtoDataCache[protoID]) end function private.OnPushHonorWall(msg) EventSystem.Dispatch(EventID.UI_GuildWarWallOfFame_Refresh, msg.honorwalls) end function private.OnBattleTips(msg) local tipsMsg = guild_war_base_pb.GuildWarBattleTips() tipsMsg:ParseFromString(msg.battleTips) for i,tip in ipairs(tipsMsg.tips) do private.HandleBattleTip(tip) end end function private.HandleBattleTip(tip)-- 这个解析需要参照 SyncGuildWarBaseLevelFunction table.insert(self.BroadcastTips 的数据结构 if tip.type == BattleTipsType.Occupy then -- 【谁】占领【xx战场】【XX营地】 local campid = tip.intParam1 -- 谁 local name = UIUtils.GetLocalizedTxt(Const_IDS[tip.stringParam1]) -- 营地 local levelInfoData = DataSheetManager.LevelInfoData:GetDataByLevelID(tip.intParam2) local battlefield = UIUtils.GetLocalizedTxt(Const_IDS[levelInfoData.LevelNameIDS]) -- 战场 local ids = nil if BattleDataGetter.GetMyCampID() == campid then ids = OccupyMyTips else ids = OccupyOtherTips end local str = string.FormatByIdsId(Const_IDS[ids], battlefield ,name) CTL.GuildWar.ShowTips_BattleReport(str) elseif tip.type == BattleTipsType.KillHero then -- 杀人统计 local killerName = tip.stringParam1 if tip.intParam1 == 0 and tip.intParam2 == 0 then killerName = UIUtils.GetLocalizedTxt(Const_IDS[tip.stringParam1]) end local info = { killNums = tip.intParam1 ,firstBlood = tip.intParam2 ,playerNameA = killerName, guildIdA = tip.stringParam2 , playerNameB = tip.stringParam3, guildIdB = tip.stringParam4 , playerHeroIdA = tip.intParam3, playerHeroIdB = tip.intParam4, killNumsB = tip.intParam5} private.OnG2CPushGuildWarKillInfo(info) elseif tip.type == BattleTipsType.KillBoss then -- 击杀boss local campid = tip.intParam1 -- 哪方 local name = tip.stringParam1 -- bossnameIDS local levelInfoData = DataSheetManager.LevelInfoData:GetDataByLevelID(tip.intParam2) local battlefield = UIUtils.GetLocalizedTxt(Const_IDS[levelInfoData.LevelNameIDS]) -- 战场 local bossID = tip.intParam3 -- 标识哪个boss local ids = nil local normalTips = nil local data = DataSheetManager.MonsterResourcePoint:GetDataByMonsterID(bossID) local resourceNum = 0 if data ~= nil then resourceNum = data.Amount end if BattleDataGetter.GetMyCampID() == campid then ids = MyCampKillBossTips normalTips = DragonBuffTips.self else ids = OtherCampKillBossTips normalTips = DragonBuffTips.enemy end local str = string.FormatByIdsId(Const_IDS[ids], battlefield ,UIUtils.GetLocalizedTxt(Const_IDS[name])) --【X方】击败【战场名】【BOSS名】 CTL.GuildWar.ShowTips_BattleReport(str) local killerName = tip.stringParam2 -- 屠boss者 CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS[normalTips]), killerName ,battlefield ,UIUtils.GetLocalizedTxt(Const_IDS[name]) ,resourceNum) end end function private.OnPushGuildWarStageInfo(msg) --准备阶段结束时间 readyStageTime = msg.stageEndTimeStamp EventSystem.Dispatch(EventID.UI_RefresGuildWarReadyStageTime, readyStageTime) end function private.OnPushStringTips(msg) local roomType = GuildWar_Model.GetRoomTypeByLevelType() local players = groupInfos[roomType].players local index = (msg.commad.teamId - 1)*3 + 1 for i=index,index+2 do if players[i].isHasPlayer and players[i].headInfo.acid == BattleDataGetter.GetAcID() then EventSystem.Dispatch(EventID.UI_GuildWarCommandTeam, msg.commad.targetId) if not string.isNilOrEmpty(msg.tips) then CTL.Tips.AddTipsMsg(msg.tips) end end end end --同步收听人数 function private.OnPushGuildWarListenInfo(msg) CTL.ChannelChat.SetGuildWarListenCount(msg.num,msg.totalNum) end --召集队员 function private.OnPushGuildWarConvene(msg) --在战场内,且未收听玩家提示 if CTL.ChannelChat.IsCanShowGuildWarChannel() and not CTL.VoiceRoom.IsEnabledListener() then local func=function() CTL.VoiceRoom.EnableListener(MDL.VoiceRoom.VoiceRoomType.GuildWar, true) MDL.GuildWar.SendGuildWarListen(PlayerInfoManager.AcID) end UTL.MessageBox.ShowOKCancelBox("", UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_CallupReceiveConfirm),func, nil) end end --斥候列表 function private.OnPushGuildWarScoursList(msg) ScoutsList =msg.Infos if ScoutsList ~=nil then CTL.ChannelChat.SetGuildWarScoutsCount(#ScoutsList) end end --任命斥候 function private.OnPushAppointGuildWarScouts(msg) local info=msg.info table.insert(ScoutsList,info) CTL.ChannelChat.SetGuildWarScoutsCount(#ScoutsList) --如果是玩家自己收到消息,有提示 if info.headInfo.acid==PlayerInfoManager.AcID then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_AppointScoutReminder),msg.name) end end --取消任命 function private.OnPushCancelGuildWarScouts(msg) local acid=msg.acid for i,v in ipairs(ScoutsList) do if acid==v.headInfo.acid then table.remove(ScoutsList,i) CTL.ChannelChat.SetGuildWarScoutsCount(#ScoutsList) --如果是玩家自己收到消息,有提示,取消任命斥候时,闭麦 if acid==PlayerInfoManager.AcID then CTL.VoiceRoom.EnableMicrophone(MDL.VoiceRoom.VoiceRoomType.GuildWar, false) CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_DismissScoutReminder),msg.name) end return end end end -- 网络消息接收 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ --基地出生 function private.OnWallBorn(entity) local campid = entity:GetCampID() if campid == LevelPlayerManager.MainEntityCampID then private.blueBossExpEntity = entity.ExpEntity else private.redBossExpEntity = entity.ExpEntity end entity.ExpEntity.IgnoreUIHpChange = true end --EventSystem ↓↓↓↓↓↓↓↓↓↓----------------------- function private.SendGuildWarResult(msg) NetManager.SendMessage(MessageEnums.MessageC2GUploadGuildWarResult, msg) MDL.FrameCmdStatistic.SetCacheFrame2CmdInfo() end function private.OnInitLevel() GuildWar_Model.ClearData() end --EventSystem ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑----------------------- function private.ShowTips_InteractGetRes(amount) CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildWar_GatherResourceSucceed"], amount) CTL.Sound.PlayGameSound("UI_obtain") end function private.ShowTips_HandInRes(amount) CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildWar_CommitResourceSucceed"], amount) end function private.ShowTips_DropRes(amount) CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildWar_DeathLostResource"], amount) end function private.ShowTips_TouchGetRes(amount) CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildWar_LootResourceSucceed"], amount) end function GuildWar_Model.ClearData() private.heroKilledCount = 0 end --斥候列表 function GuildWar_Model.GetScoutsList() return ScoutsList end --斥候满员 function GuildWar_Model.IsScoutsReachMax() if ScoutsList~= nil then return #ScoutsList>=10 end return false end --是否为斥候 function GuildWar_Model.IsScouts(acid) if ScoutsList~= nil then for i2, v2 in ipairs(ScoutsList) do if acid ==v2.headInfo.acid then return true end end end return false end --是否为战场指挥 function GuildWar_Model.IsBattleCommand(jobTitle) return jobTitle== MDL.Guild.JobEnum.Leader or jobTitle== MDL.Guild.JobEnum.JunshiElder end --获取成员的战场 function GuildWar_Model.GetRoomTypeByAcid(acid) if groupInfos~=nil then for i, v in ipairs(groupInfos) do local roomType= v.roomType for i2,v2 in ipairs(v.players) do if acid==v2.headInfo.acid then return roomType end end end end return 0 end -- 当前战场是否为势力战 function GuildWar_Model.IsGuildWarBattle() return BattleDataGetter.IsGuildWarLevel() end ----------------------------------- 势力战地图资源获取 ------------------------------- -- 攻城车 function GuildWar_Model.GetBatteringRamImageResource(isGetFriendly, isSuper) if isSuper then return isGetFriendly and ImageResource_BatteringRamSuperPoint.My or ImageResource_BatteringRamSuperPoint.Enemy else return isGetFriendly and ImageResource_BatteringRamPoint.My or ImageResource_BatteringRamPoint.Enemy end end -- 投石车 function GuildWar_Model.GetMangonelImageResource(isGetFriendly) return isGetFriendly and ImageResource_MangonelPoint.My or ImageResource_MangonelPoint.Enemy end -- 其他玩家 function GuildWar_Model.GetPlayerImageResource(entity) if not entity then return nil end local bombPropId = 30 --势力战炸弹的道具id为30 local isCarryBomb = entity.components.battleProp:GetBattlePropNum(bombPropId) ~= 0 --是否携带炸弹(通过身上炸弹道具的数量来确定) if BattleDataGetter.GetMyCampID() == entity:GetCampID() then if isCarryBomb then return ImageResource_Player.CampBomb end return BattleDataGetter.GetCurEntity():GetTeamID() == entity:GetTeamID() and ImageResource_Player.Team or ImageResource_Player.Camp, PlayerNormalPointWidthAndHeight end if isCarryBomb then return ImageResource_Player.EnemyBomb end return ImageResource_Player.Enemy, PlayerNormalPointWidthAndHeight end -- 投石车据点 function GuildWar_Model.GetMangonelCampImageResource() return ImageResource_Camp_Mangonel end -- 攻城车据点 function GuildWar_Model.GetBatteringRamCampImageResource() return ImageResource_Camp_BatteringRam end -- 据点血条 function GuildWar_Model.GetOccupationBarImageResource(isGetFriendly) return isGetFriendly and ImageResource_OccupationBar.My or ImageResource_OccupationBar.Enemy end -- 可驾驶弩车 function GuildWar_Model.GetDrivableBallistaImageResource(entity) if BattleDataGetter.GetCurEntity().EntityID == entity.EntityID then return ImageResource_Drivable_Ballista.My end if BattleDataGetter.GetMyCampID() == entity:GetCampID() then return ImageResource_Drivable_Ballista.Friend end return ImageResource_Drivable_Ballista.Enemy end -- 可驾驶投石车 function GuildWar_Model.GetDrivableMangonelImageResource(entity) if BattleDataGetter.GetCurEntity().EntityID == entity.EntityID then return ImageResource_Drivable_Mangonel.My end if BattleDataGetter.GetMyCampID() == entity:GetCampID() then return ImageResource_Drivable_Mangonel.Friend end return ImageResource_Drivable_Mangonel.Enemy end -- 军需官 function GuildWar_Model.GetQuartermasterImageResource(entity) return entity:GetCampID() == BattleDataGetter.GetMyCampID() and ImageResource_Quartermaster.Friend or ImageResource_Quartermaster.Enemy end --获取敌对势力的公会Id function GuildWar_Model.GetEnemyGuildId() local data = MDL.GuildWar.GetBattleInfo() if data.enemyCamp.guildInfo~=nil then local guildId= data.enemyCamp.guildInfo.guildId return guildId end return 0 end function GuildWar_Model.GetOccupationBarImageResourceById(id) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncGuildWarMapMiddle) then if MiddleMapChongcheId == id then return ImageResource_Camp_BatteringRam end end return ImageResource_Camp_Mangonel end function GuildWar_Model.IsMiddleChongcheId(id) return BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncGuildWarMapMiddle) and id == MiddleMapChongcheId end function GuildWar_Model.GetToushicheEntity(id) local levelId = BattleDataGetter.GetLevelID() local ids = StrongHoldToMonter[levelId][id] for i,v in ipairs(ids) do local entity = LevelItemManager.GetMonsterByItemID(v) if entity then return entity end end end --对实时语音音量和背景音进行处理 function GuildWar_Model.SetVolume() local isListening=CTL.VoiceRoom.IsEnabledListener() if not isListening then return end _lastSetVolumeTime=UTL.Time.GetServerTimestamp() if not _hasSetVolume then --logging.error(LTAG.ERROR,"GuildWar_Model.SetVolume") --压低背景音 CTL.Sound.SetRTPCValue("Voice_Bus", 0) --放大实时语音音量 SDKUtil.SetChatVolume(130,130) _hasSetVolume=true end end function GuildWar_Model.ResetVolume() local isListening=CTL.VoiceRoom.IsEnabledListener() if not isListening then return end --设置过声音,且CD时间到了 if _hasSetVolume then if not private.CheckCD(_lastSetVolumeTime) then return end --logging.error(LTAG.ERROR,"GuildWar_Model.ResetVolume") --恢复背景音 CTL.Sound.SetRTPCValue("Voice_Bus", 100) _hasSetVolume=false end end --3秒CD function private.CheckCD(cdtime) local isCanChange = false --3秒cd if cdtime == 0 then isCanChange = true else local currentTime = UTL.Time.GetServerTimestamp() --3秒cd if (currentTime - cdtime) > 3 then isCanChange = true end end return isCanChange end function GuildWar_Model.RecordRevivePanelState(isShow) GuildWar_Model.RevivePanelIsOpen = isShow end function GuildWar_Model.GetRevivePanelState() return GuildWar_Model.RevivePanelIsOpen end function GuildWar_Model.SetPersonGuildWarInfo(msg) guildWarInfo = msg CTL.GuildWar.CalNextStageTime(guildWarInfo) CTL.Guild.RefreshRedPoint() if guildWarInfo.Stage == nil then logging.error(LTAG.ERROR, "服务器数据错误 势力战赛程信息错误 战区内各个服的时间不一致导致 具体信息可以找延增") return end if guildWarInfo.Stage >= GuildWar_Model.Stages.StageTypePrepare then local isFirst = guildWarInfo.Stage == GuildWar_Model.Stages.StageTypePrepare or (guildWarInfo.Stage == GuildWar_Model.Stages.StageTypeBattle and guildWarInfo.fightStage <= GuildWar_Model.FightStages.FirstEnd) local guildInfo = guildWarInfo.curMatchInfo if guildInfo.guildRed.guildId == MDL.Guild.GetMyGuildInfo().guildId then battleInfo.selfCamp.guildInfo = guildInfo.guildRed battleInfo.enemyCamp.guildInfo = guildInfo.guildBlue battleInfo.selfIsRed = true private.guildWarResourceCount = 0 elseif guildInfo.guildBlue.guildId == MDL.Guild.GetMyGuildInfo().guildId then battleInfo.selfCamp.guildInfo = guildInfo.guildBlue battleInfo.enemyCamp.guildInfo = guildInfo.guildRed battleInfo.selfIsRed = false private.guildWarResourceCount = 0 end end CTL.GuildWar.OnGuildWarGetGuildInfo() end --是否是第一期并且军团战没有开启 function GuildWar_Model.GuildWarIsFirstSign() local info = MDL.GuildWar.GetWarInfo() if info and info.issue == 1 and not info.IsCross then if info.Stage < MDL.GuildWar.Stages.StageTypeBattle then local timeValue = info.signUpOpenTime - UTL.Time.GetServerTimestamp() if timeValue > 0 then return timeValue end end end return nil end function private.GetProtoVersion(protoOptID) if not private.guildWarProtoVersion[protoOptID] then private.guildWarProtoVersion[protoOptID] = 0 return 0 else return private.guildWarProtoVersion[protoOptID] end end function private.UpdateProtoVersion(protoOptID, newVersionNum) local curVersionNum = private.GetProtoVersion(protoOptID) if curVersionNum == newVersionNum then return false, curVersionNum else private.guildWarProtoVersion[protoOptID] = newVersionNum return true, newVersionNum end end function GuildWar_Model.GuildWarSendCommandTipsReq(id) local msg = guild_war_pb.GuildWarSendCommandTipsReq() msg.index = id NetManager.SendMessage(MessageEnums.MessageGuildWarSendCommandTips, msg) end function private.OnG2CGuildWarCommandTips(msg) local comandData = DataSheetManager.GuildWarCommand:GetDataByID(msg.index) local str = UIUtils.GetLocalizedTxt(Const_IDS[comandData.CommandText]) local jobData = DataSheetManager.GuildJob:GetDataByID(msg.officialJob) local jobName = UIUtils.GetLocalizedTxt(Const_IDS[jobData.JobName]) local name = msg.playerName local title = jobName local tipsData = { heroId = msg.hero, heroAwaken = msg.heroAwaken, commandStr = str, titile = title, name = name, type = comandData.ID } EventSystem.Dispatch(EventID.UI_ShowCommonCommandTips, tipsData) end function private.OnG2CGuildWarResourceCostNotify(msg) EventSystem.Dispatch(EventID.UI_GuildWarResourceCostNotify, msg.params) end function GuildWar_Model.GetGuildWarResourceCount() return private.guildWarResourceCount or 0 end function private.OnG2CGuildWarSomeThingCanBuyNotify(msg) EventSystem.Dispatch(EventID.UI_GuildWarCanBuyNotify, msg.canBuy) GuildWar_Model.SetCanBuyNotify(msg.canBuy) end function GuildWar_Model.SetCanBuyNotify(value) private.canBuyNotify = value end function GuildWar_Model.GetCanBuyNotify() return private.canBuyNotify and MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle, MDL.Guild.AuthorityEnum.GuildWarCommander) end function GuildWar_Model.SetClickCommandBtn(value) private.clickCommandBtn = value end function GuildWar_Model.GetClickCommandBtn() return private.clickCommandBtn end function GuildWar_Model.IsMirrorMap() return private.isMirrorMap end function GuildWar_Model.SetIsMirrorMap(value) private.isMirrorMap = value end function GuildWar_Model.GetLastSelectReviveIndex(type) return lastSelectReviveIndex[type] or 1 end function GuildWar_Model.SetLastSelectReviveIndex(type, value) lastSelectReviveIndex[type] = value end return GuildWar_Model