HomeLandManager = {} local this = HomeLandManager local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand) local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel) local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask) local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local EquipStrengthen = ConfigManager.GetConfig(ConfigName.EquipStrengthen) local EquipRankUp = ConfigManager.GetConfig(ConfigName.EquipRankUp) function this.Initialize() 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 this.EquipData = {} this.levelProId = 0 for i = 1, 4 do this.EquipData[i] = {} this.EquipData[i].Id = 1001 end this.curEquip = 1--当前停留的装备 this.activePrivilege = false this.priviLeftTime = 0 end --获取家园和装备强化信息 function this.GetData(func) NetManager.HomeInfoRequest() NetManager.EquipIntensifyRequset(-1) if func then func() end end --接收服务器信息 function this.GetServerData(msg,func) if msg.infos and #msg.infos > 0 then for index, value in ipairs(msg.infos) do LogGreen("Id:"..tostring(value.id).." startTime:"..tostring(TimeStampToDateStr4(value.productionStartTime)).." endTime:"..tostring(TimeStampToDateStr4(value.upLvEndTime))) 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 end end if msg.drop then UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1) end if func then func() end end --获取服务器装备信息 function this.GetServerEquipData(msg,func) this.levelProId = msg.equipRankUp -- this.levelProId = msg.equipRankUp + 1 -- 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 --升级材料和前置浮生殿等级检测 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--立即完成 LogGreen(tostring(_data.Time).." "..tostring(tonumber(_str[1])).." "..tonumber(_str[3])) data[16] = math.ceil(_data.Time/tonumber(_str[1]))*tonumber(_str[3]) 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 func(data[16]) end --设置任务 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 --检测当前停留 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 --通过两个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 function this.CheckPrivilege(func) 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 if func then func() end end --烦人的红点检测(我决定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 if data[i].dataMain.IsOpen == 1 and (this.singleUpgrade(i) or this.singleGet(i)) then LogRed("5") return true end end LogRed("6") return false end --1-5建筑的单个升级 function this.singleUpgrade(id) local data = this.BuildData[id].dataSingle LogGreen("建筑Id:"..tostring(data.Id)) 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--到达升级条件 LogRed("7") return true end end LogRed("8") return false end --1-4建筑的单个领取 function this.singleGet(id) local data = this.BuildData[id] if data.dataMain.Type == 1 and data.dataSingle.Gain then LogRed("9:"..tostring((GetTimeStamp() - data.startTime)/60*data.dataSingle.Gain[2] >= data.dataSingle.Storage[1][2])) return (GetTimeStamp() - data.startTime)/60*data.dataSingle.Gain[2] >= data.dataSingle.Storage[1][2] end LogRed("10") return false end --检测任务 function this.CheckMission() local data = this.SetRewardData() for index, value in ipairs(data) do if value.state == 1 then LogRed("11") return true end end LogRed("12") return false end --摘星阁 function this.CheckEquipUpgrade() for i = 1, 4 do if this.CheckSingleEquipUpgrade(i) then LogRed("13") return true end end LogRed("14") return false end --摘星阁单个装备检测 function this.CheckSingleEquipUpgrade(id) local bool = false local data = this.EquipData[id] 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--到达升级条件 bool = true end end LogRed("15:"..tostring(bool)) return bool end return HomeLandManager