2021-04-20 13:58:00 +08:00
|
|
|
|
HorseRaceManager = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local this = HorseRaceManager
|
|
|
|
|
|
|
|
|
|
local _GMRaceDeltaTime = 5
|
|
|
|
|
|
|
|
|
|
local _HorseRaceList = {}
|
|
|
|
|
local _RepeatRaceList = {}
|
|
|
|
|
|
|
|
|
|
function this.Initialize()
|
|
|
|
|
Timer.New(this._TimerUpdate, 1, -1, true):Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this._TimerUpdate()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
-- 战斗界面,不显示GM跑马灯
|
|
|
|
|
if UIManager.IsOpen(UIName.BattlePanel) then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
-- 根据剩余次数
|
|
|
|
|
local removeIndex = {}
|
|
|
|
|
for index, race in ipairs(_RepeatRaceList) do
|
|
|
|
|
if race.multiple > 0 then
|
|
|
|
|
local curTimeStamp = GetTimeStamp()
|
|
|
|
|
if curTimeStamp - race.lastTime >= _GMRaceDeltaTime then
|
|
|
|
|
race.lastTime = curTimeStamp
|
|
|
|
|
race.multiple = race.multiple - 1
|
|
|
|
|
table.insert(_HorseRaceList, race)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.HorseRace.ShowHorseRace)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- 播放完了,就删除
|
|
|
|
|
if race.multiple <= 0 then
|
|
|
|
|
table.insert(removeIndex, index)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
-- 删除要删除的
|
|
|
|
|
for i = #removeIndex, 1, -1 do
|
|
|
|
|
table.remove(_RepeatRaceList, i)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 将数据加入
|
|
|
|
|
function this.AddRaceData(data)
|
|
|
|
|
local race = {
|
|
|
|
|
id = data.messageId,
|
|
|
|
|
content = data.msg,
|
|
|
|
|
speed = data.speed,
|
|
|
|
|
multiple = data.multiple,
|
|
|
|
|
lastTime = 0,
|
|
|
|
|
}
|
|
|
|
|
table.insert(_RepeatRaceList, race)
|
|
|
|
|
--Log("新增跑马灯数据 === ")
|
|
|
|
|
--Log(race.content)
|
|
|
|
|
--Log(race.speed)
|
|
|
|
|
--Log(race.multiple)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取第一条数据
|
|
|
|
|
function this.GetRaceData()
|
|
|
|
|
if not _HorseRaceList or #_HorseRaceList == 0 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
return table.remove(_HorseRaceList, 1)
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|