78 lines
2.0 KiB
Lua
78 lines
2.0 KiB
Lua
LingLongBaoJingManager = {}
|
|
local this = LingLongBaoJingManager
|
|
local hitList = {} --已经抽取了的
|
|
local rewardList = {}
|
|
--初始化
|
|
function this.Initialize()
|
|
Game.GlobalEvent.AddEvent(GameEvent.Activity.OnActivityOpenOrClose,this.InitData)
|
|
end
|
|
|
|
function this.InitData(func)
|
|
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.lingLongBaoJing)
|
|
if not id or id < 1 then
|
|
hitList = {}
|
|
rewardList = {}
|
|
return
|
|
end
|
|
this.InitDataList(id)
|
|
NetManager.QiMenDunJiaHitListRequest(id,function(msg)
|
|
hitList = msg.hitList
|
|
this.SetDataListState(hitList)
|
|
if func then
|
|
func()
|
|
end
|
|
end)
|
|
end
|
|
|
|
function this.InitDataList(id)
|
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.LingLongPool,"ActivityId",id)
|
|
for i = 1 ,#configs do
|
|
local data = {}
|
|
data.id = configs[i].Id
|
|
data.reward = configs[i].ItemId
|
|
data.rate = configs[i].FakeRate
|
|
data.typeIndex = configs[i].Position
|
|
data.address = configs[i].Address
|
|
data.sort = configs[i].Sort
|
|
data.state = 0
|
|
rewardList[configs[i].Id] = data
|
|
end
|
|
end
|
|
|
|
function this.SetDataListState(list,typeIndex)
|
|
if list and #list > 0 then
|
|
for i = 1,#list do
|
|
rewardList[list[i]].state = 1
|
|
end
|
|
else
|
|
for k,v in pairs(rewardList) do
|
|
if not typeIndex or (typeIndex == v.typeIndex) then
|
|
v.state = 0
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function this.IsAllGet()
|
|
local index = 0
|
|
for k,v in pairs(rewardList) do
|
|
if v.state == 0 then
|
|
index = index + 1
|
|
end
|
|
end
|
|
if index < 1 then
|
|
this.SetDataListState()
|
|
end
|
|
return index < 1
|
|
end
|
|
|
|
function this.QiMenDunJiaDrawRequest(id,func)
|
|
NetManager.QiMenDunJiaDrawRequest(id,function(msg)
|
|
this.SetDataListState(msg.idList)
|
|
if func then
|
|
func(msg.idList,msg.drop)
|
|
end
|
|
end)
|
|
end
|
|
|
|
return this |