ExpeditionManager = {}; local this = ExpeditionManager this.nodeInfo = {}--所有节点信息 this.heroInfo = {}--己方英雄信息 this.lay = {}--宝箱 this.allHoly = {}--激活的圣物 this.ResurgenceNum = 0--复活次数 this.curNodeInfo = {}--当前执行逻辑的节点信息 this.NodeInfoIcon = { [ExpeditionNodeType.Jy] = "l_lieyaozhilu_zhandou02",--精英节点 [ExpeditionNodeType.Boss] = "l_lieyaozhilu_zhandou03",--首领节点 [ExpeditionNodeType.Resurgence] = "l_lieyaozhilu_fuhuoshenjing",--复活节点 [ExpeditionNodeType.Reply] = "l_lieyaozhilu_shenminghuifu",-- 回复节点 [ExpeditionNodeType.Common] = "l_lieyaozhilu_zhandou01",--普通节点 [ExpeditionNodeType.Halidom] = "l_lieyaozhilu_shangwubaoxiang",-- 圣物节点 } function this.Initialize() end --初始化远征数据 function this.InitExpeditionData(msg) --Log("服务端推送远征msg.nodeInfo:" .. #msg.nodeInfo) --Log("服务端推送远征msg.heroInfo:" .. #msg.heroInfo) --Log("服务端推送远征msg.lay:" .. #msg.lay) this.nodeInfo = {} for i = 1, #msg.nodeInfo do local singleNodeInfo = {} local nodeInfo = msg.nodeInfo[i] singleNodeInfo.sortId = nodeInfo.sortId--节点id singleNodeInfo.lay = nodeInfo.lay--节点层 singleNodeInfo.type = nodeInfo.type--节点类型 singleNodeInfo.state = nodeInfo.state--节点状态 0未开启 1未通过 2未领取圣物 3已完成 singleNodeInfo.bossTeaminfo = {}--节点队伍信息 singleNodeInfo.bossTeaminfo.hero = {}--节点队伍信息 英雄 --Log("-----||||服务端初始化节点信息 "..singleNodeInfo.sortId.." "..singleNodeInfo.state.." "..singleNodeInfo.lay ) if nodeInfo.bossTeaminfo then --Log("nodeInfo.bossTeaminfo.hero "..#nodeInfo.bossTeaminfo.hero) if nodeInfo.bossTeaminfo.hero and #nodeInfo.bossTeaminfo.hero > 0 then for k = 1, #nodeInfo.bossTeaminfo.hero do local singleHero = {} singleHero.heroTid = nodeInfo.bossTeaminfo.hero[k].heroTid singleHero.star = nodeInfo.bossTeaminfo.hero[k].star singleHero.level = nodeInfo.bossTeaminfo.hero[k].level singleHero.remainHp = nodeInfo.bossTeaminfo.hero[k].remainHp table.insert(singleNodeInfo.bossTeaminfo.hero,singleHero) end end singleNodeInfo.bossTeaminfo.PokemonInfos = {}--节点队伍信息 异妖 if nodeInfo.bossTeaminfo.PokemonInfos and #nodeInfo.bossTeaminfo.PokemonInfos > 0 then --Log("nodeInfo.bossTeaminfo.PokemonInfos "..#nodeInfo.bossTeaminfo.PokemonInfos) for w = 1, #nodeInfo.bossTeaminfo.PokemonInfos do table.insert(singleNodeInfo.bossTeaminfo.PokemonInfos,nodeInfo.bossTeaminfo.PokemonInfos[w]) end end end singleNodeInfo.bossTeaminfo.totalForce = nodeInfo.bossTeaminfo.totalForce--tonumber(1000 .. i)-- singleNodeInfo.holyEquipID = {}--圣物id if nodeInfo.holyEquipID then --Log("nodeInfo.equipIds "..#nodeInfo.holyEquipID) for j = 1, #nodeInfo.holyEquipID do table.insert(singleNodeInfo.holyEquipID,nodeInfo.holyEquipID[j]) end end table.insert(this.nodeInfo,singleNodeInfo) this.SetCurNodeInfo(singleNodeInfo) end --Log("服务端推送远征#msg.heroInfo:" .. #msg.heroInfo) this.heroInfo = {} for i = 1, #msg.heroInfo do local singleHeroInfo = {} singleHeroInfo.heroId = msg.heroInfo[i].heroId--英雄动态id singleHeroInfo.remainHp = msg.heroInfo[i].remainHp--剩余血量 --Log("服务端推送远征singleHeroInfo.remainHp:" .. singleHeroInfo.remainHp) --table.insert(this.heroInfo,singleHeroInfo) this.heroInfo[singleHeroInfo.heroId] =singleHeroInfo --msg.heroInfo[i].remainHp end this.lay = {} if msg.lay then for i = 1, #msg.lay do table.insert(this.lay,msg.lay[i]) end end this.allHoly = {} if msg.equipIds then --Log("#msg.equipIds "..#msg.equipIds) for i = 1, #msg.equipIds do local singleHalidomInfo = {} singleHalidomInfo.id = msg.equipIds[i].id--动态id singleHalidomInfo.equiptId = msg.equipIds[i].equiptId this.allHoly[singleHalidomInfo.id] =singleHalidomInfo end end if UIManager.GetOpenPanel(UIName.ExpeditionMainPanel) then UIManager.OpenPanel(UIName.ExpeditionMainPanel,false) end end --根据层级获取所有节点 function this.GetAllLayNodeList() local layNodeInfo = {} --if #this.nodeInfo <= 0 then -- NetManager.GetExpeditionRequest() --end table.sort(this.nodeInfo, function(a, b) return a.sortId < b.sortId end) for i = 1, #this.nodeInfo do if layNodeInfo[this.nodeInfo[i].lay] == nil then layNodeInfo[this.nodeInfo[i].lay] = {} table.insert(layNodeInfo[this.nodeInfo[i].lay],this.nodeInfo[i]) --Log("远征 主界面获取信息 "..this.nodeInfo[i].lay.." "..this.nodeInfo[i].sortId.." "..this.nodeInfo[i].state) else table.insert(layNodeInfo[this.nodeInfo[i].lay],this.nodeInfo[i]) --Log("远征 主界面获取信息 "..this.nodeInfo[i].lay.." "..this.nodeInfo[i].sortId.." "..this.nodeInfo[i].state) end end return layNodeInfo end --获取宝箱数据 function this.GetAllNodeBoxnfoList() local curPassLay = 0--当前通关的层级 for i = 1, #this.nodeInfo do if this.nodeInfo[i].state == 3 then if curPassLay < this.nodeInfo[i].lay then curPassLay = this.nodeInfo[i].lay end end end --Log("curPassLay "..curPassLay) local layInfo = {} for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.ExpeditionFloorConfig)) do if v.TreasureBox then --Log("v.TreasureBox ".. v.Id) local curlayInfo = {} curlayInfo.ConFigData = v curlayInfo.state = 1-- 1 未达到 if curPassLay >= v.Id then curlayInfo.state = 2--2 达到未领取 end for j = 1, #this.lay do --Log("this.lay[j] == v.Id "..this.lay[j] .."".. v.Id) if this.lay[j] == v.Id then curlayInfo.state = 3--3 已完成 end end table.insert(layInfo,curlayInfo) end end return layInfo , curPassLay end --获取当前节点信息 function this.SetCurNodeInfo(singleNodeInfo) if singleNodeInfo.state == 1 then--刚开启 this.curNodeInfo = singleNodeInfo end if singleNodeInfo.state == 2 then--未选择圣物 this.curNodeInfo = singleNodeInfo end local keys = GameDataBase.SheetBase.GetKeys(ConfigManager.GetConfig(ConfigName.ExpeditionFloorConfig)) if singleNodeInfo.state == 3 and singleNodeInfo.lay == #keys then--全部通关 this.curNodeInfo = singleNodeInfo end end --获取当前节点信息 function this.GetCurNodeInfo() return this.curNodeInfo end --跟新节点信息 function this.UpdateNodeValue(nodeInfo) if nodeInfo then for i = 1, #nodeInfo do local nodeInfo = nodeInfo[i] for o = 1, #this.nodeInfo do if this.nodeInfo[o].sortId == nodeInfo.sortId then --if nodeInfo.lay then this.nodeInfo[o].lay = nodeInfo.lay end --if nodeInfo.type then this.nodeInfo[o].type = nodeInfo.type end if nodeInfo.state then this.nodeInfo[o].state = nodeInfo.state end Log(" ******* 推送更新远征节点信息 "..this.nodeInfo[o].sortId.." "..this.nodeInfo[o].state) if nodeInfo.bossTeaminfo then if nodeInfo.bossTeaminfo.hero and #nodeInfo.bossTeaminfo.hero > 0 then this.nodeInfo[o].bossTeaminfo.hero = {}--节点队伍信息 英雄 for k = 1, #nodeInfo.bossTeaminfo.hero do local singleHero = {} singleHero.heroTid = nodeInfo.bossTeaminfo.hero[k].heroTid singleHero.star = nodeInfo.bossTeaminfo.hero[k].star singleHero.level = nodeInfo.bossTeaminfo.hero[k].level singleHero.remainHp = nodeInfo.bossTeaminfo.hero[k].remainHp table.insert( this.nodeInfo[o].bossTeaminfo.hero,singleHero) end end if nodeInfo.bossTeaminfo.PokemonInfos and #nodeInfo.bossTeaminfo.PokemonInfos > 0 then this.nodeInfo[o].bossTeaminfo.PokemonInfos = {}--节点队伍信息 异妖 for w = 1, #nodeInfo.bossTeaminfo.PokemonInfos do table.insert(this.nodeInfo[o].bossTeaminfo.PokemonInfos,nodeInfo.bossTeaminfo.PokemonInfos[w]) end end if nodeInfo.bossTeaminfo.totalForce and nodeInfo.bossTeaminfo.totalForce > 0 then this.nodeInfo[o].bossTeaminfo.totalForce = nodeInfo.bossTeaminfo.totalForce end end if nodeInfo.holyEquipID and #nodeInfo.holyEquipID > 0 then this.nodeInfo[o].holyEquipID = {} for j = 1, #nodeInfo.holyEquipID do table.insert( this.nodeInfo[o].holyEquipID,nodeInfo.holyEquipID[j]) end end this.SetCurNodeInfo(this.nodeInfo[o]) end end end end end --跟新英雄血量 function this.UpdateHeroHpValue(heroInfo) if heroInfo then for i = 1, #heroInfo do if this.heroInfo[heroInfo[i].heroId] then this.heroInfo[heroInfo[i].heroId].remainHp = heroInfo[i].remainHp --Log(" ******* 推送更新远征英雄血量 "..heroInfo[i].heroId.." "..heroInfo[i].remainHp) else local singleHeroInfo = {} singleHeroInfo.heroId = heroInfo[i].heroId--英雄动态id singleHeroInfo.remainHp = heroInfo[i].remainHp--剩余血量 --Log(" ******* 推送更新远征英雄血量 "..singleHeroInfo.heroId.." "..singleHeroInfo.remainHp) this.heroInfo[singleHeroInfo.heroId] = singleHeroInfo end end end end --初始化英雄血量 function this.InitHeroHpValue(dynamicId) if dynamicId then if this.heroInfo[dynamicId] then else local singleHeroInfo = {} singleHeroInfo.heroId = dynamicId--英雄动态id singleHeroInfo.remainHp = 1--剩余血量 --Log(" ******* 前端获得新英雄添加远征数据 "..singleHeroInfo.heroId.." "..singleHeroInfo.remainHp) this.heroInfo[singleHeroInfo.heroId] = singleHeroInfo end end end --初始化英雄血量 function this.DelHeroHpValue(heroInfo) if heroInfo then if this.heroInfo[heroInfo.dynamicId] then this.heroInfo[heroInfo.dynamicId] = nil end end end --跟新圣物 function this.UpdateHalidomValue(msg) if msg.equipIds then for i = 1, #msg.equipIds do local singleHalidomInfo = {} singleHalidomInfo.id = msg.equipIds[i].id--动态id singleHalidomInfo.equiptId = msg.equipIds[i].equiptId --Log(" ******* 推送更新远征圣物 "..singleHalidomInfo.id.." "..singleHalidomInfo.equiptId) this.allHoly[singleHalidomInfo.id] =singleHalidomInfo end end end --更新宝箱 function this.UpdateBoxValue(layNum) table.insert(this.lay,layNum) end --开始战斗 function this.ExecuteFightBattle(_nodeId,_teamId,_expInfo, callBack) NetManager.StartExpeditionBattleRequest(_nodeId, _teamId, _expInfo,function (msg) local fightData, seed, fightType, maxTime = BattleManager.GetBattleServerData(msg,1) for o = 1, #this.nodeInfo do if this.nodeInfo[o].sortId == _nodeId then this.curNodeInfo = this.nodeInfo[o] end end UIManager.OpenPanel(UIName.BattlePanel, fightData, seed, fightType, maxTime, "execute", 51034, callBack) end) end function this.ExpeditionRrefreshFormation() local teamId = FormationTypeDef.EXPEDITION local newFormation = this.ExpeditionDeleteDeadRole() FormationManager.formationList[teamId] = newFormation end -- 远征删除编队中某一个成员的数据 function this.ExpeditionDeleteDeadRole() -- 死人后重组 local newFormation = {} -- 编队界面的编队数据 local curTeam = FormationManager.GetFormationByID(FormationTypeDef.EXPEDITION) -- 编队界面的数据 newFormation.teamHeroInfos = {} newFormation.teamPokemonInfos = {} newFormation.teamId = FormationTypeDef.EXPEDITION newFormation.teamName = curTeam.teamName newFormation.teamPokemonInfos = curTeam.teamPokemonInfos -- 成员数据 for i = 1, #curTeam.teamHeroInfos do local roleData = curTeam.teamHeroInfos[i] -- 如果队员没死翘翘了 -- local curRoleHp = this.heroInfo[roleData.heroId].remainHp if this.heroInfo[roleData.heroId] and this.heroInfo[roleData.heroId].remainHp and this.heroInfo[roleData.heroId].remainHp > 0 then -- if curRoleHp > 0 then -- 编队界面数据重组 table.insert(newFormation.teamHeroInfos, roleData) end end return newFormation end --获取宝箱红点 function this.GetNodeBoxnIsShowRedPoint() local curPassLay = this.curNodeInfo local layInfo = {} local keys = GameDataBase.SheetBase.GetKeys(ConfigManager.GetConfig(ConfigName.ExpeditionFloorConfig)) if curPassLay and curPassLay.lay then for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.ExpeditionFloorConfig)) do if v.TreasureBox then local curlayInfo = {} if curPassLay.lay > v.Id or (curPassLay.lay == #keys and curPassLay.state == ExpeditionNodeState.Finish) then--打完最后一层 curlayInfo.state = 2--2 达到未领取 end for j = 1, #this.lay do if this.lay[j] == v.Id then curlayInfo.state = 3--3 已完成 end end table.insert(layInfo,curlayInfo) end end for i = 1, #layInfo do if layInfo[i].state == 2 then return true end end end return false end --获取活动刷新红点 function this.GetActivityIsShowRedPoint(isFiveRefresh,value) if isFiveRefresh then if RedPointManager.PlayerPrefsGetStr(PlayerManager.uid.."Expedition") ~= "0" then RedPointManager.PlayerPrefsDeleteStr(PlayerManager.uid.."Expedition") end return true else if ActTimeCtrlManager.SingleFuncState(JumpType.Expedition) then if RedPointManager.PlayerPrefsGetStr(PlayerManager.uid.."Expedition") ~= "0" then return false else if value and value == "1" then RedPointManager.PlayerPrefsSetStr(PlayerManager.uid.."Expedition",value) end return true end end end return false end function this.CalculateallHolyWarPower() local allHolyWarPower = 0--万分比 local allAddWarPowerHoly = {} for i, v in pairs(this.allHoly) do local curHeffect = ConfigManager.GetConfigData(ConfigName.ExpeditionHolyConfig,v.equiptId).effect local curHForceType = ConfigManager.GetConfigData(ConfigName.ExpeditionHolyConfig,v.equiptId).ForceType if allAddWarPowerHoly[curHeffect] then if curHForceType > allAddWarPowerHoly[curHeffect] then allAddWarPowerHoly[curHeffect] = curHForceType --Log("1curHeffect curHForceType "..curHForceType.." "..curHForceType) end else --Log("2curHeffect curHForceType "..curHForceType.." "..curHForceType) allAddWarPowerHoly[curHeffect] = curHForceType end end for i, v in pairs(allAddWarPowerHoly) do allHolyWarPower = allHolyWarPower + v end --Log("allHolyWarPower "..allHolyWarPower) return allHolyWarPower end return this