GuildCarDelayManager = {}; local this = GuildCarDelayManager this.ChallengeCdTime = 0 this.LootCdTime = 0 function this.Initialize() end --后端更新车迟进度 function this.SetProgressData(msg) this.progress = msg.progress--阶段 -1:未开 1 : 挑战 2 空挡期 3:抢夺 this.endTime = msg.endTime--结束时间 this.bossIndexId = msg.bossIndexId--boss索引id this.battleStartTime = msg.battleStartTime--挑战boss开启时间 this.grabStartTime = msg.grabStartTime--抢夺开启时间 --LogError("progress "..this.progress.." endTime "..this.endTime.." bossIndexId "..this.bossIndexId.." this.battleStartTime "..this.battleStartTime) if this.timer2 then this.timer2:Stop() this.timer2 = nil end this.ChallengeCdTime = 0 this.LootCdTime = 0 Game.GlobalEvent:DispatchEvent(GameEvent.Guild.CarDelayProgressChanged) CheckRedPointStatus(RedPointType.Guild_CarDeleay) end --开始战斗 this.score = 0 this.hurt = 0 this.heroDidData = {}--抢夺是向后端传的id function this.SetheroDid(_heroDidData) this.heroDidData = _heroDidData end function this.FightBattle( callBack) local type = 0 local fightType = 0 local monsterId = 0 -- LogGreen("this.progress "..this.progress) if this.progress == GuildCarDelayProType.Challenge then local worldBossConfig = ConfigManager.GetConfigData(ConfigName.WorldBossConfig,GuildCarDelayManager.bossIndexId) if worldBossConfig and worldBossConfig.MonsterId then monsterId = worldBossConfig.MonsterId end fightType = 0 type = 1 elseif this.progress == GuildCarDelayProType.Loot then monsterId = this.heroDidData.uid fightType = 1 type = 2 end -- if monsterId then -- LogGreen("type "..type.." monsterId "..monsterId) -- else -- LogGreen("type "..type.." monsterId nil") -- end if type <= 0 or not monsterId then PopupTipPanel.ShowTip(Language[12150]) return else if this.progress == GuildCarDelayProType.Challenge then PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_CHALLENGE, 1) elseif this.progress == GuildCarDelayProType.Loot then PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_LOOT, 1) end end NetManager.FastFightChallengeRequest(type,monsterId,function (msg) this.score = msg.score this.hurt = msg.hurt local fightData = BattleManager.GetBattleServerData(msg,fightType) if (this.progress == GuildCarDelayProType.Loot and this.heroDidData and this.heroDidData.teamInfo and #this.heroDidData.teamInfo > 0) or this.progress == GuildCarDelayProType.Challenge then UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.GUILD_CAR_DELAY, callBack) else--抢夺目标阵容为空时 --车迟抢夺cd计时 GuildCarDelayManager.SetCdTime(GuildCarDelayProType.Loot) -- "抢夺成功,获得XXXX积分!""需先领取上一奖励!" PopupTipPanel.ShowTip(string.format(Language[11022], this.score)) if callBack then callBack() callBack = nil end end end) end function this.SetCdTime(progress) if progress == GuildCarDelayProType.Challenge then this.ChallengeCdTime = ConfigManager.GetConfigData(ConfigName.WorldBossSetting,1).CDTime[1] this.RemainTimeDown2(this.ChallengeCdTime) Game.GlobalEvent:DispatchEvent(GameEvent.Guild.CarDelayChallengeCdStar) elseif progress == GuildCarDelayProType.Loot then this.LootCdTime = ConfigManager.GetConfigData(ConfigName.WorldBossSetting,1).CDTime[2] this.RemainTimeDown2(this.LootCdTime) Game.GlobalEvent:DispatchEvent(GameEvent.Guild.CarDelayLootCdStar) end CheckRedPointStatus(RedPointType.Guild_CarDeleay) end this.timer2 = Timer.New() --刷新倒计时显示 function this.RemainTimeDown2(timeDown) if timeDown > 0 then if this.timer2 then this.timer2:Stop() this.timer2 = nil end this.timer2 = Timer.New(function() if GuildCarDelayManager.progress == GuildCarDelayProType.Challenge then GuildCarDelayManager.ChallengeCdTime = timeDown elseif GuildCarDelayManager.progress == GuildCarDelayProType.Loot then GuildCarDelayManager.LootCdTime = timeDown end if timeDown < 0 then this.timer2:Stop() this.timer2 = nil CheckRedPointStatus(RedPointType.Guild_CarDeleay) end timeDown = timeDown - 1 end, 1, -1, true) this.timer2:Start() end end function this.RefreshAllRedPoint() --LogError(" RefreshAllRedPoint "..tostring(this.RefreshRedPoint(GuildCarDelayProType.Challenge) or this.RefreshRedPoint(GuildCarDelayProType.Loot))) return this.RefreshRedPoint(GuildCarDelayProType.Challenge) or this.RefreshRedPoint(GuildCarDelayProType.Loot) end --红点检测 function this.RefreshRedPoint(progress) if progress ~= GuildCarDelayManager.progress then return false end if GuildCarDelayManager.progress == GuildCarDelayProType.Challenge then if PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_CHALLENGE) > 0 and this.ChallengeCdTime <= 0 then return true else return false end elseif GuildCarDelayManager.progress == GuildCarDelayProType.Loot then if PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_LOOT) > 0 and this.LootCdTime <= 0 then return true else return false end end end function this.SetCarPlayTimeData(time) if this.progress == GuildCarDelayProType.Challenge then this.ChallengeCdTime = (time + ConfigManager.GetConfigData(ConfigName.WorldBossSetting,1).CDTime[1]) - GetTimeStamp() this.RemainTimeDown2(this.ChallengeCdTime) Game.GlobalEvent:DispatchEvent(GameEvent.Guild.CarDelayChallengeCdStar) elseif this.progress == GuildCarDelayProType.Loot then this.LootCdTime = (time + ConfigManager.GetConfigData(ConfigName.WorldBossSetting,1).CDTime[1]) - GetTimeStamp() this.RemainTimeDown2(this.LootCdTime) Game.GlobalEvent:DispatchEvent(GameEvent.Guild.CarDelayLootCdStar) end CheckRedPointStatus(RedPointType.Guild_CarDeleay) end return this