miduo_client/Assets/ManagedResources/~Lua/Modules/HomeLand/HomeLandManager.lua

72 lines
3.1 KiB
Lua
Raw Normal View History

2021-12-20 16:50:51 +08:00
HomeLandManager = {}
local this = HomeLandManager
2021-12-23 14:38:02 +08:00
local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand)
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel)
local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask)
2021-12-28 11:54:08 +08:00
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
2021-12-20 16:50:51 +08:00
function this.Initialize()
2021-12-23 14:38:02 +08:00
this.BuildData = {}
for _, configData in ConfigPairs(HomeLand) do
this.BuildData[configData.Id] = {}
this.BuildData[configData.Id].dataMain = configData--HomeLand中数据
if configData.LvupCostPool > 0 then
this.BuildData[configData.Id].level = 1 --等级
local singledata = ConfigManager.GetConfigDataByDoubleKey(ConfigName.HomeLandLevel,"PoolID",configData.Id,"level",this.BuildData[configData.Id].level)
this.BuildData[configData.Id].dataSingle = singledata--HomeLandLevel中数据
this.BuildData[configData.Id].startTime = 0 --资源开始积攒的时间
this.BuildData[configData.Id].endTime = 0 --建筑升级的结束时间
end
end
end
--接收服务器信息
function this.GetServerData(msg,func)
2021-12-24 18:20:18 +08:00
if msg.infos and #msg.infos > 0 then
for index, value in ipairs(msg.infos) do
2021-12-28 11:54:08 +08:00
LogGreen("Id:"..tostring(value.id).." startTime:"..tostring(TimeStampToDateStr4(value.productionStartTime)).." endTime:"..tostring(TimeStampToDateStr4(value.upLvEndTime)))
2021-12-24 18:20:18 +08:00
if value.id and value.id > 0 then
local data = HomeLandLevel[value.id]
this.BuildData[data.PoolID].level = data.level
this.BuildData[data.PoolID].startTime = value.productionStartTime
this.BuildData[data.PoolID].endTime = value.upLvEndTime
this.BuildData[data.PoolID].dataSingle = HomeLandLevel[value.id]
end
2021-12-23 14:38:02 +08:00
end
end
if msg.drop then
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1)
end
if func then
func()
end
2021-12-20 16:50:51 +08:00
end
2021-12-28 11:54:08 +08:00
--升级材料和前置浮生殿等级检测
function this.ResumeCost(_data,_str,func)
if _data.Rule and this.BuildData[_data.Rule[1]].level < _data.Rule[2] then
PopupTipPanel.ShowTip(string.format("%s到达%s级可升级",this.BuildData[_data.Rule[1]].dataMain.Name,_data.Rule[2]))
return
end
local data = {}
for i = 1, #_data.Cost do
if not data[_data.Cost[i][1]] then
data[_data.Cost[i][1]] = 0
end
data[_data.Cost[i][1]] = data[_data.Cost[i][1]] + _data.Cost[i][2]
end
if _str then--立即完成
2021-12-28 18:27:31 +08:00
LogGreen(tostring(_data.Time).." "..tostring(tonumber(_str[1])).." "..tonumber(_str[3]))
data[16] = math.ceil(_data.Time/tonumber(_str[1]))*tonumber(_str[3])
2021-12-28 11:54:08 +08:00
end
for key, value in pairs(data) do
LogGreen(string.format("需要%s: %s,现有:%s",key,value,BagManager.GetTotalItemNum(key)))
if BagManager.GetTotalItemNum(key) < value then
PopupTipPanel.ShowTip(string.format("%s不足",ItemConfig[key].Name))
return
end
end
2021-12-28 18:27:31 +08:00
func(data[16])
2021-12-28 11:54:08 +08:00
end
2021-12-20 16:50:51 +08:00
return HomeLandManager