miduo_client/Assets/ManagedResources/~Lua/Modules/linglongbaojing/LingLongBaoJingManager.lua

134 lines
3.8 KiB
Lua

LingLongBaoJingManager = {}
local this = LingLongBaoJingManager
local hitList = {} --已经抽取了的
local rewardList = {}
--初始化
function this.Initialize()
Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityOpenOrClose,this.RefreshData)
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold,function()CheckRedPointStatus(RedPointType.linglongBaojing)end)
end
function this.RefreshData()
this.CheckRedPointLingLong()
this.InitData(nil)
end
function this.InitData(func)
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.lingLongBaoJing)
if not id or id < 1 then
hitList = {}
rewardList = {}
if func then
func()
end
return
end
this.InitDataList(id)
NetManager.QiMenDunJiaHitListRequest(id,function(msg)
hitList = msg.hitList
if not msg.hitList or #msg.hitList < 1 then
else
-- LogGreen("msg.hitList:"..#msg.hitList)
-- for i = 1,#msg.hitList do
-- LogGreen("msg.hitList:"..msg.hitList[i])
-- end
this.SetDataListState(hitList)
end
if func then
func()
end
end)
end
function this.InitDataList(id)
rewardList = {}
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.LingLongPool,"ActivityId",id)
if configs then
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
else
LogError("LingLongPool 中未找到 ActivityId :".. id)
end
end
function this.GetRewardList()
return rewardList
end
function this.SetDataListState(list,typeIndex)
if list and #list > 0 then
for i = 1,#list do
if rewardList[list[i]] then
rewardList[list[i]].state = 1
end
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.typeIndex == 1 and v.state == 0 then
index = index + 1
end
end
return index < 1
end
function this.QiMenDunJiaDrawRequest(id,num,func)
NetManager.QiMenDunJiaDrawRequest(id,num,function(msg)
-- for i = 1,#msg.idList do
-- LogGreen("msg.idList:"..msg.idList[i])
-- end
if func then
func(msg.idList,msg.drop)
end
end)
end
function this.CheckRedPointLingLong()
local id = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.lingLongBaoJing)
if not id or id < 1 then
return false
end
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,117)
local strs = string.split(config.Value,"|")
local costId = tonumber(strs[1])
if BagManager.GetItemCountById(costId) > 0 then
return true
end
local state=PlayerPrefs.GetInt(PlayerManager.uid.."lingShouBaoGe")
if state==0 then
return true
end
local isBuy=OperatingManager.IsBuyGift(20017)
if not isBuy then
return true
end
local actconfigs = ActivityGiftManager.GetActivityInfoByType(id)
for i = 1,#actconfigs.mission do
local config = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig,actconfigs.mission[i].missionId)
if actconfigs.mission[i].progress >= config.Values[1][1] and actconfigs.mission[i].state == 0 then
return true
end
end
return false
end
return this