2021-12-22 12:07:00 +08:00
|
|
|
|
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 = {}
|
2021-12-23 17:23:02 +08:00
|
|
|
|
this.curFormationIndex = 0
|
2021-12-22 12:07:00 +08:00
|
|
|
|
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
|
2021-12-23 17:23:02 +08:00
|
|
|
|
this.ExploreMapData[v.Id].pos = Vector3.New(v.Position[1],v.Position[2],v.Position[3])
|
2021-12-22 12:07:00 +08:00
|
|
|
|
this.ExploreMapData[v.Id].formations = {}
|
2021-12-23 13:09:34 +08:00
|
|
|
|
this.ExploreMapData[v.Id].state = 0
|
2021-12-22 12:07:00 +08:00
|
|
|
|
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
|
2021-12-23 13:09:34 +08:00
|
|
|
|
this.FormationData[formationId].index = i
|
|
|
|
|
this.FormationData[formationId].formationName = "队伍"..i
|
2021-12-22 12:07:00 +08:00
|
|
|
|
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
|
2021-12-23 13:09:34 +08:00
|
|
|
|
this.FormationData[formationId].dropReward = {}
|
|
|
|
|
end
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Player.OnLevelChange, this.OnLevelChange)
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-28 14:50:45 +08:00
|
|
|
|
function this.OnLevelChange()
|
2021-12-23 13:09:34 +08:00
|
|
|
|
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
|
2021-12-29 10:02:22 +08:00
|
|
|
|
if k == 3101 then
|
|
|
|
|
FormationManager.CopyStoryFormationToCurFormation(k)
|
2021-12-28 14:50:45 +08:00
|
|
|
|
end
|
2021-12-23 13:09:34 +08:00
|
|
|
|
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
|
2021-12-22 12:07:00 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新编队信息
|
|
|
|
|
function this.UpdateFormationsData(_data)
|
|
|
|
|
for i = 1,#_data do
|
|
|
|
|
this.UpdateFormationData(_data[i])
|
|
|
|
|
end
|
2021-12-24 17:49:54 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Explore.UpdateFormation)
|
2021-12-22 12:07:00 +08:00
|
|
|
|
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
|
2021-12-23 13:09:34 +08:00
|
|
|
|
this.FormationData[team.teamId].dropReward = team.dropReward
|
2021-12-22 12:07:00 +08:00
|
|
|
|
--这个编队是否开启
|
|
|
|
|
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
|
2021-12-24 11:18:03 +08:00
|
|
|
|
this.FormationData[team.teamId].mapId = team.mapId
|
2021-12-22 12:07:00 +08:00
|
|
|
|
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
|
2021-12-23 13:09:34 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.ExploreFunc)
|
2021-12-22 12:07:00 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-24 11:18:03 +08:00
|
|
|
|
function this.ResetTeamByTeamId(teamId)
|
|
|
|
|
if this.FormationData[teamId] then
|
|
|
|
|
this.FormationData[teamId].hp = 0
|
|
|
|
|
this.FormationData[teamId].exploreTime = 0
|
|
|
|
|
this.FormationData[teamId].dropReward = {}
|
|
|
|
|
this.FormationData[teamId].state = 0
|
|
|
|
|
this.UpdateMapFormationData(this.FormationData[teamId].mapId,teamId,-1)
|
|
|
|
|
this.FormationData[teamId].mapId = 0
|
|
|
|
|
end
|
2021-12-28 13:30:27 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Explore.UpdateFormation)
|
|
|
|
|
CheckRedPointStatus(RedPointType.ExploreFunc)
|
2021-12-24 11:18:03 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-22 12:07:00 +08:00
|
|
|
|
-- 刷新地图编队
|
|
|
|
|
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.showData,singleShowData)
|
2021-12-23 17:23:02 +08:00
|
|
|
|
return data1
|
2021-12-22 12:07:00 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-24 11:18:03 +08:00
|
|
|
|
function this.InitMapUserInfosData(data,mapId)
|
|
|
|
|
local datas = {}
|
2021-12-28 13:30:27 +08:00
|
|
|
|
local myData
|
2021-12-24 11:18:03 +08:00
|
|
|
|
for i = 1,#data do
|
|
|
|
|
local singleUserData = {}
|
|
|
|
|
singleUserData.userName = data[i].name
|
|
|
|
|
singleUserData.sex = data[i].gender
|
|
|
|
|
singleUserData.uid = data[i].uid
|
|
|
|
|
singleUserData.userSkin = data[i].userSkin
|
|
|
|
|
singleUserData.userTitle = data[i].userTitle
|
|
|
|
|
singleUserData.userMount = data[i].userMount
|
2021-12-28 13:30:27 +08:00
|
|
|
|
singleUserData.practiceLevel = data[i].practiceLevel
|
2021-12-24 11:18:03 +08:00
|
|
|
|
singleUserData.lv = data[i].level
|
|
|
|
|
singleUserData.formationId = i
|
2021-12-28 13:30:27 +08:00
|
|
|
|
singleUserData.hp = 0
|
|
|
|
|
if singleUserData.uid == PlayerManager.uid then
|
|
|
|
|
myData = singleUserData
|
|
|
|
|
else
|
|
|
|
|
table.insert(datas,singleUserData)
|
|
|
|
|
end
|
2021-12-24 11:18:03 +08:00
|
|
|
|
end
|
2021-12-28 13:30:27 +08:00
|
|
|
|
|
2021-12-27 15:48:09 +08:00
|
|
|
|
for k,v in pairs(this.ExploreMapData[mapId].formations) do
|
2021-12-28 13:30:27 +08:00
|
|
|
|
local singleUserData = {}
|
|
|
|
|
singleUserData.userName = myData.userName
|
|
|
|
|
singleUserData.sex = myData.sex
|
|
|
|
|
singleUserData.uid = myData.uid
|
|
|
|
|
singleUserData.userSkin = myData.userSkin
|
|
|
|
|
singleUserData.userTitle = myData.userTitle
|
|
|
|
|
singleUserData.userMount = myData.userMount
|
|
|
|
|
singleUserData.practiceLevel = myData.practiceLevel
|
|
|
|
|
singleUserData.lv = myData.lv
|
|
|
|
|
singleUserData.formationId = k
|
|
|
|
|
singleUserData.hp = this.FormationData[k].hp
|
|
|
|
|
table.insert(datas,singleUserData)
|
2021-12-24 11:18:03 +08:00
|
|
|
|
end
|
|
|
|
|
return datas
|
2021-12-22 12:07:00 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-23 13:09:34 +08:00
|
|
|
|
--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
|
|
|
|
|
|
2021-12-24 14:09:48 +08:00
|
|
|
|
function this.GetHpById(id)
|
|
|
|
|
return this.FormationData[id].hp
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-22 12:07:00 +08:00
|
|
|
|
--红点检测
|
|
|
|
|
function this.CheckRedPoint()
|
2021-12-28 14:50:45 +08:00
|
|
|
|
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.Explore) then
|
|
|
|
|
return false
|
|
|
|
|
end
|
2021-12-22 12:07:00 +08:00
|
|
|
|
for k,v in pairs(this.FormationData) do
|
|
|
|
|
if v.state == 0 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-12-28 14:50:45 +08:00
|
|
|
|
return false
|
2021-12-22 12:07:00 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return this
|