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-29 20:17:45 +08:00
|
|
|
|
local EquipStrengthen = ConfigManager.GetConfig(ConfigName.EquipStrengthen)
|
|
|
|
|
local EquipRankUp = ConfigManager.GetConfig(ConfigName.EquipRankUp)
|
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
|
2021-12-29 20:17:45 +08:00
|
|
|
|
this.EquipData = {}
|
|
|
|
|
this.levelProId = 0
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
this.EquipData[i] = {}
|
|
|
|
|
this.EquipData[i].Id = 1001
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
this.curEquip = 1--当前停留的装备
|
2021-12-31 18:13:10 +08:00
|
|
|
|
this.activePrivilege = false
|
2021-12-31 18:58:04 +08:00
|
|
|
|
this.priviLeftTime = 0
|
2021-12-29 20:17:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取家园和装备强化信息
|
|
|
|
|
function this.GetData(func)
|
|
|
|
|
NetManager.HomeInfoRequest()
|
|
|
|
|
NetManager.EquipIntensifyRequset(-1)
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
2021-12-23 14:38:02 +08:00
|
|
|
|
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-29 20:17:45 +08:00
|
|
|
|
--获取服务器装备信息
|
|
|
|
|
function this.GetServerEquipData(msg,func)
|
|
|
|
|
this.levelProId = msg.equipRankUp
|
2021-12-30 11:00:27 +08:00
|
|
|
|
-- this.levelProId = msg.equipRankUp + 1
|
2021-12-29 20:17:45 +08:00
|
|
|
|
-- this.levelProId = 1
|
|
|
|
|
if msg.infos and #msg.infos > 0 then
|
|
|
|
|
for index, value in ipairs(msg.infos) do
|
|
|
|
|
-- value.lvId = 1022
|
|
|
|
|
LogYellow("Location:"..tostring(value.location).." lvId:"..tostring(value.lvId).." 突破等级Id:"..tostring(this.levelProId))
|
|
|
|
|
if value.location and value.location > 0 and value.location < 5 then
|
|
|
|
|
this.EquipData[value.location].Id = value.lvId
|
|
|
|
|
this.EquipData[value.location].configData = EquipStrengthen[value.lvId]
|
|
|
|
|
this.EquipData[value.location].configPro = EquipRankUp[this.levelProId]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
|
|
|
|
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-29 14:03:16 +08:00
|
|
|
|
--设置任务
|
|
|
|
|
function this.SetRewardData()
|
|
|
|
|
local dataList = {}
|
|
|
|
|
local transform = {
|
|
|
|
|
[0] = 2,
|
|
|
|
|
[1] = 1,
|
|
|
|
|
[2] = 0,
|
|
|
|
|
}
|
|
|
|
|
for k,v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HomeLandTask)) do
|
|
|
|
|
local data = {}
|
|
|
|
|
data.Id = v.Id
|
|
|
|
|
local taskData = TaskManager.GetTypeTaskInfo(TaskTypeDef.HomeLandTask,v.Id)
|
|
|
|
|
data.info = string.format("%s(%s/%s)",v.ContentsShow,taskData.progress,v.Values[2][1])
|
|
|
|
|
data.BoxReward = v.Reward
|
|
|
|
|
data.state = transform[taskData.state]
|
|
|
|
|
table.insert(dataList,data)
|
|
|
|
|
end
|
|
|
|
|
return dataList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--等级总和
|
|
|
|
|
-- function this.GetLevelNum()
|
|
|
|
|
-- local num = 0
|
|
|
|
|
-- for index, value in ipairs(this.BuildData) do
|
|
|
|
|
-- if value.level then
|
|
|
|
|
-- num = num + value.level
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- LogYellow("等级总和:"..num)
|
|
|
|
|
-- return num
|
|
|
|
|
-- end
|
|
|
|
|
|
2021-12-29 20:17:45 +08:00
|
|
|
|
--检测当前停留
|
|
|
|
|
function this.GetCurIndex()
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
if this.EquipData[i].configData.Limit2 == EquipRankUp[this.levelProId].Level then
|
|
|
|
|
this.curEquip = i
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测按钮显示
|
|
|
|
|
function this.GetCurIndexBtnsShow()
|
|
|
|
|
-- LogBlue("this.curEquip:"..tostring(this.curEquip))
|
|
|
|
|
-- LogBlue("Limit2:"..tostring(this.EquipData[this.curEquip].configData.Limit2))
|
|
|
|
|
-- LogBlue("this.levelProLevel:"..tostring(EquipRankUp[this.levelProId].Level))
|
|
|
|
|
return this.EquipData[this.curEquip].configData.Limit2 == EquipRankUp[this.levelProId].Level
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测是否全部可以突破
|
|
|
|
|
function this.GetAllCanUpgrade()
|
|
|
|
|
local num = 0
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
if this.EquipData[i].configData.Limit2 > EquipRankUp[this.levelProId].Level then
|
|
|
|
|
num = num + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if num == 4 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测是否全部可以突破并提示
|
|
|
|
|
function this.GetAllCanUpgradeWithPopup()
|
|
|
|
|
local TEXT = {
|
|
|
|
|
[1] = {"武器","r_Equip_GuardianWeapon_0004"},
|
|
|
|
|
[2] = {"战甲","r_Equip_Coat_0005"},
|
|
|
|
|
[3] = {"头饰","r_Equip_HeadAccessory_0005"},
|
|
|
|
|
[4] = {"战靴","r_equip_Shoes_0005"},
|
|
|
|
|
}
|
|
|
|
|
local num = 0
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
if this.EquipData[i].configData.Limit2 == EquipRankUp[this.levelProId].Level then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("%s未达到最大等级,不可突破!",TEXT[i][1]))
|
|
|
|
|
this.curEquip = i
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-31 13:44:11 +08:00
|
|
|
|
--通过两个id计算两个等级
|
|
|
|
|
function this.IdToLevel(id1,id2)
|
|
|
|
|
return {EquipStrengthen[id1].Level,EquipRankUp[id2].Level}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.LevelToId()
|
|
|
|
|
local num1 = ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen,"Level",self.equipData.homeEquipLv[1]).Id
|
|
|
|
|
local num2 = ConfigManager.GetConfigDataByKey(ConfigName.EquipRankUp,"Level",self.equipData.homeEquipLv[2]).Id
|
|
|
|
|
return {num1,num2}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--通过两个等级计算加成
|
|
|
|
|
function this.LevelToValue(ids,position)
|
|
|
|
|
local num1 = ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen,"Level",ids[1]).Rate
|
|
|
|
|
local num2 = ConfigManager.GetConfigDataByKey(ConfigName.EquipRankUp,"Level",ids[2]).Rate[position]
|
|
|
|
|
return num1 + num2
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-31 18:13:10 +08:00
|
|
|
|
function this.CheckPrivilege(func)
|
2021-12-31 18:58:04 +08:00
|
|
|
|
local data = PrivilegeManager.GetSerData(4022)
|
|
|
|
|
if data and data.endTime - GetTimeStamp() > 0 then
|
|
|
|
|
this.activePrivilege = true
|
|
|
|
|
this.priviLeftTime = PrivilegeManager.GetPrivilegeRemainValue(4021)
|
|
|
|
|
else
|
|
|
|
|
this.activePrivilege = false
|
|
|
|
|
this.priviLeftTime = 0
|
|
|
|
|
end
|
2021-12-31 18:13:10 +08:00
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-01-04 15:10:35 +08:00
|
|
|
|
|
|
|
|
|
--烦人的红点检测(我决定1-4写一个、5写一个,6写一个、任务写一个、7移植过来,然后写个总的检测跑一遍所有)
|
|
|
|
|
function this.CheckRedMain()
|
|
|
|
|
if this.Check1to5Building() then
|
|
|
|
|
LogRed("1")
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if this.CheckMission() then
|
|
|
|
|
LogRed("2")
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if this.CheckEquipUpgrade() then
|
|
|
|
|
LogRed("3")
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
LogRed("4")
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.Check1to5Building()
|
|
|
|
|
local data = this.BuildData
|
|
|
|
|
for i = 1, 5 do
|
2022-01-05 10:12:23 +08:00
|
|
|
|
if data[i].dataMain.IsOpen == 1 and (this.singleUpgrade(i) or this.singleGet(i)) then
|
|
|
|
|
LogRed("5")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("6")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--1-5建筑的单个升级
|
|
|
|
|
function this.singleUpgrade(id)
|
|
|
|
|
local data = this.BuildData[id].dataSingle
|
2022-01-04 18:58:34 +08:00
|
|
|
|
LogGreen("建筑Id:"..tostring(data.Id))
|
2022-01-04 15:10:35 +08:00
|
|
|
|
if BagManager.GetTotalItemNum(data.Cost[1][1]) >= data.Cost[1][2] then--所需材料够
|
|
|
|
|
if not data.Rule or (this.BuildData[data.Rule[1]].level >= data.Rule[2]) then--到达升级条件
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("7")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("8")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--1-4建筑的单个领取
|
|
|
|
|
function this.singleGet(id)
|
|
|
|
|
local data = this.BuildData[id]
|
2022-01-04 18:58:34 +08:00
|
|
|
|
if data.dataMain.Type == 1 and data.dataSingle.Gain then
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("9:"..tostring((GetTimeStamp() - data.startTime)/60*data.dataSingle.Gain[2] >= data.dataSingle.Storage[1][2]))
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return (GetTimeStamp() - data.startTime)/60*data.dataSingle.Gain[2] >= data.dataSingle.Storage[1][2]
|
|
|
|
|
end
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("10")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测任务
|
|
|
|
|
function this.CheckMission()
|
|
|
|
|
local data = this.SetRewardData()
|
|
|
|
|
for index, value in ipairs(data) do
|
|
|
|
|
if value.state == 1 then
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("11")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("12")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--摘星阁
|
|
|
|
|
function this.CheckEquipUpgrade()
|
|
|
|
|
for i = 1, 4 do
|
|
|
|
|
if this.CheckSingleEquipUpgrade(i) then
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("13")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("14")
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--摘星阁单个装备检测
|
|
|
|
|
function this.CheckSingleEquipUpgrade(id)
|
|
|
|
|
local bool = false
|
|
|
|
|
local data = this.EquipData[id]
|
2022-01-04 18:58:34 +08:00
|
|
|
|
LogBlue("装备Id:"..tostring(data.Id))
|
|
|
|
|
if BagManager.GetTotalItemNum(data.configData.Cost[1][1]) >= data.configData.Cost[1][2] then--所需材料够
|
|
|
|
|
if this.BuildData[data.configData.Limit[1]].level >= data.configData.Limit[2] then--到达升级条件
|
2022-01-04 15:10:35 +08:00
|
|
|
|
bool = true
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-01-05 10:12:23 +08:00
|
|
|
|
LogRed("15:"..tostring(bool))
|
2022-01-04 15:10:35 +08:00
|
|
|
|
return bool
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-20 16:50:51 +08:00
|
|
|
|
return HomeLandManager
|