miduo_client/Assets/ManagedResources/~Lua/Modules/Explore/ExploreManager.lua

242 lines
8.4 KiB
Lua
Raw Normal View History

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
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
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)
2021-12-23 17:23:02 +08:00
LogGreen("team.teamId:"..team.teamId.." team.hp:"..team.hp.." team.exploreTime:"..team.exploreTime)
2021-12-22 12:07:00 +08:00
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-24 00:14:32 +08:00
LogGreen("this.FormationData[team.teamId].state:"..this.FormationData[team.teamId].state.." team.exploreTime - GetTimeStamp():"..team.exploreTime - GetTimeStamp())
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
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 = {}
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
singleUserData.precticelevel = data[i].practiceLevel
singleUserData.lv = data[i].level
singleUserData.formationId = i
singleUserData.hp = 0
table.insert(datas,singleUserData)
end
for k,v in pairs(this.ExploreMapData[mapId.Id].formations) do
for i = 1,#datas do
if datas[i].uid == PlayerManager.uid then
datas[i].formationId = k
end
end
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()
for k,v in pairs(this.FormationData) do
if v.state == 0 then
return true
end
end
end
return this