ExploreManager = {} local this = ExploreManager local ExploreConfig = ConfigManager.GetConfig(ConfigName.Explore) local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local SpecialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig,141) this.ExploreMapData = {} this.FormationData = {} function this.Initialize() for k,v in ConfigPairs(ExploreConfig) do this.ExploreMapData[v.Id] = {} this.ExploreMapData[v.Id].mapId = v.Id this.ExploreMapData[v.Id].name = v.Name this.ExploreMapData[v.Id].iconName = v.Icon this.ExploreMapData[v.Id].exploreMapId = v.Map this.ExploreMapData[v.Id].openLevel = v.Level this.ExploreMapData[v.Id].mainRewardId = v.MainReward this.ExploreMapData[v.Id].reward = v.RewardShow this.ExploreMapData[v.Id].force = v.Force this.ExploreMapData[v.Id].cost = v.Cost this.ExploreMapData[v.Id].formations = {} this.ExploreMapData[v.Id].state = 0 end local strs = string.split(SpecialConfig.Value,"|") for i = 1,#strs do local data = string.split(strs[i],"#") local formationId = tonumber(data[1]) this.FormationData[formationId] = {} this.FormationData[formationId].formationId = formationId this.FormationData[formationId].index = i this.FormationData[formationId].formationName = "队伍"..i this.FormationData[formationId].openLv = tonumber(data[2]) this.FormationData[formationId].state = -1 -- -1 未开启 0 未探索 1 探索中 2 休眠中 this.FormationData[formationId].hp = 0 this.FormationData[formationId].exploreTime = 0 this.FormationData[formationId].mapId = 0 this.FormationData[formationId].dropReward = {} end Game.GlobalEvent:AddEvent(GameEvent.Player.OnLevelChange, this.OnLevelChange) end function this.OnLevelChange() local isCheckRed = false for k,v in pairs(this.FormationData) do if v.state < 0 then if PlayerManager.level >= v.openLv then v.state = 0 isCheckRed = true end end end this.UpdateMapsState() if isCheckRed then CheckRedPointStatus(RedPointType.ExploreFunc) end end function this.UpdateMapsState() for k,v in pairs(this.ExploreMapData) do if PlayerManager.level >= v.openLevel then v.state = 1 end end end --刷新编队信息 function this.UpdateFormationsData(_data) for i = 1,#_data do this.UpdateFormationData(_data[i]) end end --刷新编队 function this.UpdateFormationData(team) if this.FormationData[team.teamId] then this.FormationData[team.teamId].hp = team.hp this.FormationData[team.teamId].exploreTime = team.exploreTime this.FormationData[team.teamId].dropReward = team.dropReward --这个编队是否开启 if PlayerManager.level < this.FormationData[team.teamId].openLv then this.FormationData[team.teamId].state = -1 this.UpdateMapFormationData(this.FormationData[team.teamId].mapId,team.teamId,-1) this.FormationData[team.teamId].mapId = 0 else --探索剩余时间小于0 if team.exploreTime - GetTimeStamp() <= 0 then this.FormationData[team.teamId].state = 0 this.UpdateMapFormationData(this.FormationData[team.teamId].mapId,team.teamId,-1) this.FormationData[team.teamId].mapId = 0 else this.FormationData[team.teamId].state = 1 if this.FormationData[team.teamId].hp <= 0 then this.FormationData[team.teamId].state = 2 end this.UpdateMapFormationData(team.mapId,team.teamId,1) end end else LogGreen(string.format("%s编队不属于探索玩法",team.teamId)) end CheckRedPointStatus(RedPointType.ExploreFunc) end -- 刷新地图编队 function this.UpdateMapFormationData(mapId,teamId,updateType) if not this.ExploreMapData[mapId] then return end if updateType > 0 then if not this.ExploreMapData[mapId].formations[teamId] then this.ExploreMapData[mapId].formations[teamId] = teamId end else if this.ExploreMapData[mapId].formations[teamId] then this.ExploreMapData[mapId].formations[teamId] = nil end end end function this.GetMapInfoByMapId(mapId) return this.ExploreMapData[mapId] end function this.GetExploreMapTipData(mapId) local data = this.ExploreMapData[mapId] local data1 = {} data1.name = data.name data1.showData = {} local singleShowData = {} singleShowData.tips = {} table.insert(singleShowData.tips,string.format("推荐战力:%s",data.force)) table.insert(data1.showData,singleShowData) local singleShowData = {} singleShowData.tips = {} table.insert(singleShowData.tips,string.format("消耗%s:%s/分",ItemConfig[data.cost[1]].Name,data.cost[2])) table.insert(data1.showData,singleShowData) local singleShowData = {} singleShowData.tips = {} table.insert(singleShowData.tips,"探索产出:") singleShowData.reward = data.reward table.insert(data1.cost,singleShowData) table.insert(data1.showData,singleShowData) end function this.InitMapUserInfosData(data) end --index 1 有未开启的返回一个未开启的 0返回 所有已开启的 function this.GetFormationData(index) local datas = {} local add = index local strs = string.split(SpecialConfig.Value,"|") for i = 1,#strs do local data = string.split(strs[i],"#") local formationId = tonumber(data[1]) if this.FormationData[formationId].state >= 0 then table.insert(datas, this.FormationData[formationId]) else if add > 0 then table.insert(datas, this.FormationData[formationId]) add = add - 1 end end end return datas end --获取已开启的地图 function this.GetMapsData() local datas = {} for k,v in pairs(this.ExploreMapData) do if v.state == 1 then table.insert(datas,v) end end return datas end function this.GetFormationDataByMapId(mapId) local datas = {} for k,v in pairs(this.ExploreMapData[mapId].formations) do table.insert(datas, this.FormationData[v]) end return datas end --红点检测 function this.CheckRedPoint() for k,v in pairs(this.FormationData) do if v.state == 0 then return true end end end return this