miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/CarDelay/GuildCarDelayManager.lua

142 lines
6.0 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
GuildCarDelayManager = {};
2020-05-09 13:31:21 +08:00
local this = GuildCarDelayManager
2020-05-15 16:52:35 +08:00
this.ChallengeCdTime = 0
this.LootCdTime = 0
2020-05-09 13:31:21 +08:00
function this.Initialize()
end
--后端更新车迟进度
function this.SetProgressData(msg)
2020-05-11 09:38:52 +08:00
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--抢夺开启时间
2020-06-12 18:04:22 +08:00
--LogError("progress "..this.progress.." endTime "..this.endTime.." bossIndexId "..this.bossIndexId.." this.battleStartTime "..this.battleStartTime)
2020-05-25 19:16:23 +08:00
if this.timer2 then
this.timer2:Stop()
this.timer2 = nil
end
2020-05-15 16:52:35 +08:00
this.ChallengeCdTime = 0
this.LootCdTime = 0
2020-05-09 13:31:21 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.CarDelayProgressChanged)
2020-05-15 16:52:35 +08:00
CheckRedPointStatus(RedPointType.Guild_CarDeleay)
2020-05-09 13:31:21 +08:00
end
--开始战斗
this.score = 0
this.hurt = 0
this.heroDidData = 0--抢夺是向后端传的id
function this.SetheroDid(_heroDidData)
this.heroDidData = _heroDidData
2020-05-09 13:31:21 +08:00
end
function this.FightBattle( callBack)
local type = 0
local fightType = 0
local monsterId = 0
2020-05-15 16:52:35 +08:00
if this.progress == GuildCarDelayProType.Challenge then
2020-05-09 13:31:21 +08:00
local worldBossConfig = ConfigManager.GetConfigData(ConfigName.WorldBossConfig,GuildCarDelayManager.bossIndexId)
if worldBossConfig and worldBossConfig.MonsterId then
monsterId = worldBossConfig.MonsterId
end
fightType = 0
type = 1
2020-05-11 09:38:52 +08:00
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_CHALLENGE, 1)
2020-05-15 16:52:35 +08:00
elseif this.progress == GuildCarDelayProType.Loot then
monsterId = this.heroDidData.uid
2020-05-09 13:31:21 +08:00
fightType = 1
type = 2
2020-05-11 09:38:52 +08:00
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.GUILD_CAR_DELEAY_LOOT, 1)
2020-05-09 13:31:21 +08:00
end
-- LogGreen("type "..type.." monsterId "..monsterId)
2020-05-09 13:31:21 +08:00
NetManager.FastFightChallengeRequest(type,monsterId,function (msg)
this.score = msg.score
this.hurt = msg.hurt
2020-06-03 19:09:01 +08:00
local fightData = BattleManager.GetBattleServerData(msg,fightType)
if this.heroDidData and this.heroDidData.teamInfo and #this.heroDidData.teamInfo > 0 then
2020-06-03 19:09:01 +08:00
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.GUILD_CAR_DELAY, callBack)
else--抢夺目标阵容为空时
--车迟抢夺cd计时
GuildCarDelayManager.SetCdTime(GuildCarDelayProType.Loot)
-- "抢夺成功获得XXXX积分"Language[10027]
PopupTipPanel.ShowTip(string.format(Language[12391], this.score))
if callBack then
callBack()
callBack = nil
end
end
2020-05-09 13:31:21 +08:00
end)
end
2020-05-15 16:52:35 +08:00
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
2020-05-25 19:16:23 +08:00
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
2020-05-09 13:31:21 +08:00
return this