miduo_client/Assets/ManagedResources/~Lua/Modules/Map/EndLessMapManager.lua

449 lines
15 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

EndLessMapManager = {};
local this = EndLessMapManager
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
local endLessConfig = ConfigManager.GetConfig(ConfigName.EndlessMapConfig)
this.limiteLevel = gameSetting[1].EndlessMinLevel
-- 所有妖灵师的血量数据
this.allHeroBlood = {}
function this.Initialize()
this.isCanNote = false -- 是否进入可标记状态
this.PointNoteDataList = {} -- 标记列表
this.hungery = false -- 没有行动力了
this.leftEnergy = 0 -- 剩余行动力
this.totalEnergy = 0 -- 总行动力
this.targetMapId = 0 -- 传送去的地图Id
this.justEnterMap = false -- 才刚进图伦家
this.srcMapId = 0 -- 传送时上一张地图的ID
this.curMapName = "" -- 当前地图名
this.mapFightTimes = 0 -- 当前地图战斗次数
this.energyCost = 0 -- 当前地图行动力消耗
this.isReset = false -- 是处于复位状态
this.openMapInfo = {} -- 地图的开放消息
this.isTrigger = false -- 检测在是否在触发事件
this.isUpdateOnClose = false -- 检测在MapPanel隐藏时是否更新过 在面板关闭后初始化
this.freshPointData = {}
this.isAddPoint = false -- 是否新增一个刷新点
this.openMapId = 0 -- 开放的地图ID
this.worldLevel = 0 -- 开放的世界等级
this.isOpenedFullPanel = false -- 是否在退出地图前打开过全屏界面
-- 打开过编队界面
this.openedFormat = false
this.isSkipFight = 1 -- 服务器记录的是否跳过战斗
this.EndLessRoleDead = false -- 无尽副本角色进入死亡状态,走一步重置
end
function this.InitHeroHp(msg, func)
Log(Language[11174])
this.allHeroBlood = {}
if msg and #msg.heroInfo > 0 then
for i = 1, #msg.heroInfo do
local heroData = msg.heroInfo[i]
local allEquipAddProVal= HeroManager.CalculateWarAllProVal(heroData.heroId)
local maxHp = allEquipAddProVal[3]
local hp = heroData.hp / 10000
local data = {}
data.percentHp = hp
data.curHp = math.ceil(hp * maxHp)
data.heroId = heroData.heroId
this.allHeroBlood[heroData.heroId] = data
--Log("当前英雄血量" .. heroData.hp)
end
end
-- 请求完妖灵师数据后才打开编队刷新队伍
if func then func() end
end
-- 在地图中更换编队后,更新上阵编队的最大血量值
function this.UpDateTeamMaxHp(info)
-- 不是无尽副本,直接返回
if CarbonManager.difficulty ~= CARBON_TYPE.ENDLESS then return end
-- 替换地图编队的最大血量
local mapTeam = {}
for i = 1, #info do
local roleId = info[i].heroId
local allProp = HeroManager.CalculateWarAllProVal(roleId)
allProp[2] = info[i].heroHp
allProp[3] = info[i].heroMaxHp
--Log(" 更换编队后的剩余血量 == " .. info[i].heroHp)
mapTeam[i] = {
heroId = roleId,
allProVal = allProp,
}
end
MapManager.formationList = mapTeam
LogGreen("indication的编队长度"..#mapTeam)
CallBackOnPanelOpen(UIName.MapPanel, function ()
Game.GlobalEvent:DispatchEvent(GameEvent.Map.FormationHpChange)
end)
end
-- 解析标记点的数据
function this.InitMapNoteData(signs)
LogPink("signs是"..signs)
-- 不是无尽副本,直接返回
if CarbonManager.difficulty ~= CARBON_TYPE.ENDLESS then return end
-- 初始化
for i, v in ConfigPairs (endLessConfig) do
this.PointNoteDataList[v.Id] = {}
end
if #signs > 0 then
for i = 1, #signs do
local data = {}
data.notePos = signs[i].cellId
data.noteInfo = signs[i].info
data.mapId = signs[i].mapId
--Log("标记内容" .. data.noteInfo)
local u, v = Map_Pos2UV(data.notePos)
--Log("标记位置(" ..u .. ", " .. v .. ")")
-- this.PointNoteDataList[data.mapId][data.notePos] = data
this.PointNoteDataList[data.mapId][data.notePos] = data
end
end
LogPink("#PointNoteDataList"..#this.PointNoteDataList)
end
function this.InitRefreshPoint(refreshInfo, func)
--Log("需要刷新点的数量是 == " .. #refreshInfo )
this.freshPointData = {}
for i = 1, #refreshInfo do
local data = refreshInfo[i]
if data.time > math.ceil(PlayerManager.serverTime) then
this.freshPointData[data.cellId] = data.time
--Log("需要等待" .. data.time - math.ceil(PlayerManager.serverTime) .. "秒后刷新")
end
end
if func then func() end
end
-- 登录初始化地图数据
function this.InitMapInfoData(mapInfo)
Log(Language[11175] .. mapInfo.mapId)
Log(Language[11176] .. mapInfo.worldLevel)
this.openMapId = mapInfo.mapId -- 开放的地图ID
this.worldLevel = mapInfo.worldLevel -- 开放的世界等级
local score = 0
if not mapInfo.bloodScore or mapInfo.bloodScore < 0 then
score = 0
else
score = mapInfo.bloodScore
end
MatchDataManager.myScore = mapInfo.bloodScore -- 血战的初始积分
end
-- ================================== 妖灵师状态刷新 ========================================
-- 换人后刷新队伍血量
function this.RefreshTeamInfo()
Log(Language[11177])
local mapTeam = {}
local curTeam = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_ENDLESS_MAP)
for i = 1, #curTeam.teamHeroInfos do
local roleData = curTeam.teamHeroInfos[i]
local allProp = HeroManager.CalculateWarAllProVal(roleData.heroId)
allProp[2] = this.allHeroBlood[roleData.heroId].curHp
mapTeam[i] = {
heroId = roleData.heroId,
allProVal = allProp,
}
end
return mapTeam
end
-- 刷新地图中的队伍数据
function this.RefershMapTeam()
if CarbonManager.difficulty == CARBON_TYPE.ENDLESS and MapManager.isInMap then
--MapManager.formationList = this.RefreshTeamInfo()
end
end
-- 无尽副本中得到某一个妖灵师的血量值, 传入动态ID
function this.GetHeroLeftBlood(heroId)
if CarbonManager.difficulty ~= CARBON_TYPE.ENDLESS then Log(Language[11178]) return end
if this.allHeroBlood[heroId] then
return this.allHeroBlood[heroId].curHp
else
Log(Language[11179])
local allProp = HeroManager.CalculateWarAllProVal(heroId)
return allProp[3]
end
end
-- 无尽副本删除编队中某一个成员的数据
function this.DeleteDeadRole()
if CarbonManager.difficulty ~= CARBON_TYPE.ENDLESS then Log(Language[11180]) return end
Log(Language[11181])
-- 死人后重组
local newMapTeam = {} -- 地图中的编队数据
local newFormation = {} -- 编队界面的编队数据
local curTeam = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_ENDLESS_MAP)
-- 编队界面的数据
newFormation.teamHeroInfos = {}
newFormation.teamPokemonInfos = {}
newFormation.teamId = FormationTypeDef.FORMATION_ENDLESS_MAP
newFormation.teamName = curTeam.teamName
newFormation.teamPokemonInfos = curTeam.teamPokemonInfos
--Log("成员数量 -- " .. #curTeam.teamHeroInfos)
-- 成员数据
for i = 1, #curTeam.teamHeroInfos do
local roleData = curTeam.teamHeroInfos[i]
-- 如果队员没死翘翘了
local curRoleHp = this.GetHeroLeftBlood(roleData.heroId)
if curRoleHp > 0 then
-- 地图数据重组
local allProp = HeroManager.CalculateWarAllProVal(roleData.heroId)
allProp[2] = curRoleHp
newMapTeam[#newMapTeam + 1] = {
heroId = roleData.heroId,
allProVal = allProp,
}
-- 编队界面数据重组
table.insert(newFormation.teamHeroInfos, roleData)
end
end
return newFormation, newMapTeam
end
--编队界面有死亡猎妖师重组编队数据
function this.RoleListFormationNewMapTeam()
local newMapTeam = {} -- 地图中的编队数据
local curTeam = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_ENDLESS_MAP)
-- 成员数据
if curTeam.teamHeroInfos and #curTeam.teamHeroInfos > 0 then
for i = 1, #curTeam.teamHeroInfos do
local roleData = curTeam.teamHeroInfos[i]
local curRoleHp = 0
if this.allHeroBlood[roleData.heroId] then
curRoleHp = this.allHeroBlood[roleData.heroId].curHp
else
local allProp = HeroManager.CalculateWarAllProVal(roleData.heroId)
curRoleHp = allProp[3]
end
if curRoleHp > 0 then
local info = {}
info.position = #newMapTeam+1--curTeam.teamHeroInfos[i].position
info.heroId = roleData.heroId
table.insert(newMapTeam,info)
end
end
end
FormationManager.RefreshFormation(FormationTypeDef.FORMATION_ENDLESS_MAP, newMapTeam, curTeam.teamPokemonInfos)
return newMapTeam
end
-- 角色战斗失败,删除相应的地图队伍
function this.DeleteMapTeam()
for i = 1, #MapManager.formationList do
MapManager.formationList[i].allProVal[2] = 0
local heroId = MapManager.formationList[i].heroId
this.allHeroBlood[heroId].curHp = 0
end
end
-- 判断队伍是否还有活着的人
function this.IsMapTeamAlive()
LogGreen("编队人数:"..#MapManager.formationList)
for i = 1, #MapManager.formationList do
if MapManager.formationList[i].allProVal[2] > 0 then
return true
end
end
return false
end
-- 是否所有都死翘翘
function this.IsAllDead()
for i, v in pairs(this.allHeroBlood) do
if v.curHp > 0 then
return false
end
end
return true
end
-- 刷新编队界面得到的编队以及地图中的编队数据, 只有打开编队界面才刷新地图编队
function this.RrefreshFormation()
if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then
local teamId = FormationTypeDef.FORMATION_ENDLESS_MAP
local newFormation, newMapTeam = this.DeleteDeadRole()
FormationManager.formationList[teamId] = newFormation
Log(Language[11182])
MapManager.formationList = newMapTeam
end
end
-- =============================================================================================
-- ==================== 地图标记 ===============================================================
-- 无尽副本是否进入了可标记状态
function this.IsCanNoteState()
local canNote = false
if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then
if this.isCanNote then
canNote = true
end
end
return canNote
end
-- 进入标记状态点击后保存点击选中的坐标值
function this.SetNotePos(u, v)
local selectedPos = Map_UV2Pos(u, v)
-- 没有标记过打开标记面板
local panelType = 1
panelType = this.IsPointNote(selectedPos) and 2 or 1
UIManager.OpenPanel(UIName.MapNotePopup, selectedPos, panelType)
end
-- 判断某一个点是否已经被标记
function this.IsPointNote(pos)
local isNote = false
if not this.PointNoteDataList[MapManager.curMapId][pos] or this.PointNoteDataList[MapManager.curMapId][pos].notePos == 0 then
isNote = false
else
isNote = true
end
return isNote
end
-- 删除一个已经标记的点, 需要删除的点必定存在,不然判断方法就完蛋了
function this.DeleteNotePoint(pos, func)
local noteData = this.PointNoteDataList[MapManager.curMapId][pos]
local deletePos = pos
local mapId = MapManager.curMapId
local deleteInfo = noteData.noteInfo
local deteType = 2
NetManager.RequestNotePoint(mapId, deletePos, deleteInfo, deteType, function ()
if func then func() end
end)
end
-- ===========================================================================================
-- =================== 消耗行动力 ===================================================
-- 进入当前地图消耗行动力数值
function this.EnergyCostEnterMap(mapId)
-- 只有无尽副本执行
if CarbonManager.difficulty ~= CARBON_TYPE.ENDLESS then return end
local cost = 0
local curCost = endLessConfig[this.srcMapId].TeleportCost
local distCost = endLessConfig[mapId].TeleportCost
cost = math.abs(distCost - curCost)
return cost
end
-- 角色进入鸡儿状态
function this.roleIsHungery()
local isHungery = false
if CarbonManager.difficulty == CARBON_TYPE.ENDLESS then
if this.hungery then
isHungery = true
end
end
return isHungery
end
-- 判断鸡儿状态
function this.isHungery()
local curEnergy = EndLessMapManager.leftEnergy
if curEnergy <= 0 then
EndLessMapManager.hungery = true
else
EndLessMapManager.hungery = false
end
end
-- 是否有足够的行动力给你去浪
function this.IsCanTransport(mapId)
local canTransport = false
canTransport = this.leftEnergy >= this.EnergyCostEnterMap(mapId)
return canTransport
end
-- 向服务器索要剩余行动力
function this.GetLeftEnergy(func)
if CarbonManager.difficulty ~= CARBON_TYPE.ENDLESS then return end
NetManager.ReqeustRefreshEnergy(func)
end
-- 返回行动力上限。跟VIP挂钩
function this.GetTotalEnergy()
return PrivilegeManager.GetPrivilegeNumber(20)
end
--判断当前的行动力是已经是上限
function this.EnergyEnough()
-- 地图里用显示的数据,地图外面用背包的数据
local curEnergy = 0
if CarbonManager.difficulty == CARBON_TYPE.ENDLESS and MapManager.isInMap then
curEnergy = this.leftEnergy
else
curEnergy = BagManager.GetItemCountById(1)
end
local limitValue = this.GetTotalEnergy()
return curEnergy >= limitValue
end
-- 返回剩余行动力
function this.GetLeftMapEnergy()
local curEnergy = 0
if CarbonManager.difficulty == CARBON_TYPE.ENDLESS and MapManager.isInMap then
curEnergy = this.leftEnergy
else
curEnergy = BagManager.GetItemCountById(1)
end
return curEnergy
end
-- =================================================================================
-- ============= 其他杂项处理方法 =====================================================
-- 获取统计数据
function this.OutMapStats(msg)
if msg then
this.mapFightTimes = msg.fightCount
this.energyCost = msg.consumeExecution
end
end
-- 通过传送门传送到想去的地图
function this.TranssportByMapId(mapId)
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out, mapId, 1)
end
-- 获取开放的地图数据
function this.GetOpenMapInfo(openMapId)
for i = 1, #openMapId do
this.openMapInfo[openMapId[i]] = openMapId[i]
end
end
-- 判断无尽副本当前地图是否开放
function this.IsThisMapOpen(mapId)
local isOpen = false
if this.openMapInfo[mapId] and this.openMapInfo[mapId] > 0 then
Log("openMapInfo == " .. this.openMapInfo[mapId])
isOpen = true
else
isOpen = false
end
return isOpen
end
return this