199 lines
6.2 KiB
Lua
199 lines
6.2 KiB
Lua
|
|
MapTrialManager = {};
|
|||
|
|
local this = MapTrialManager
|
|||
|
|
local trailSetting = ConfigManager.GetConfig(ConfigName.TrialSetting)
|
|||
|
|
local trailConfig = ConfigManager.GetConfig(ConfigName.TrialConfig)
|
|||
|
|
function this.Initialize()
|
|||
|
|
this.resetLevel = 0 -- 重置到的层数
|
|||
|
|
this.resetCount = 0 -- 已经重置的次数
|
|||
|
|
this.bossType = 0 -- 召唤的boss 类型
|
|||
|
|
this.bossId = 0 -- 召唤的boss怪物ID
|
|||
|
|
this.highestLevel = 0 -- 历史最高层
|
|||
|
|
this.doneTime = 0 -- 完成当前层数所用的时间
|
|||
|
|
this.curTowerLevel = 0 -- 当前所在层数
|
|||
|
|
this.fightCount=0 -- 已战斗次数
|
|||
|
|
this.towerShopInfos ={} -- 爬塔副本商店信息
|
|||
|
|
this.powerValue = 0 -- 精气值
|
|||
|
|
this.canCallBoss = false -- 是否可以召唤地图首领
|
|||
|
|
this.isHaveBoss = false -- 是否Boss已经召唤出来
|
|||
|
|
this.trailBufferInfo = {} -- 试炼副本Buff数信息, 进图的时候赋值
|
|||
|
|
this.isCanReset=0
|
|||
|
|
this.bossDeadTime = 0 -- 完成最后一层的时间
|
|||
|
|
this.leftLife = 0 -- 剩余复活次数
|
|||
|
|
this.rolePos = Vector2.zero
|
|||
|
|
this.canMove = true -- 服务器返回精气值100时不可寻路
|
|||
|
|
this.isChangeLevel = false -- 换层时不可寻路
|
|||
|
|
this.gotRewardLevel = {} -- 已经领取奖励的层数
|
|||
|
|
this.firstEnter = false -- 试炼副本重置后进图
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function this.RefreshTrialInfo(towerCopyInfo)
|
|||
|
|
--试炼副本数据初始化
|
|||
|
|
this.curTowerLevel=towerCopyInfo.tower
|
|||
|
|
this.highestLevel=towerCopyInfo.highestTower
|
|||
|
|
this.resetCount=PrivilegeManager.GetPrivilegeRemainValue(17)
|
|||
|
|
this.fightCount=towerCopyInfo.towerCopyInfo
|
|||
|
|
this.powerValue = towerCopyInfo.essenceValue
|
|||
|
|
this.isCanReset=towerCopyInfo.mapIntoReset
|
|||
|
|
this.doneTime = towerCopyInfo.towerUseTime
|
|||
|
|
|
|||
|
|
-- 最后一层需要赋值
|
|||
|
|
this.bossDeadTime = towerCopyInfo.towerUseTime
|
|||
|
|
|
|||
|
|
|
|||
|
|
Log("towerUseTime ============" .. towerCopyInfo.towerUseTime)
|
|||
|
|
Log("111111111111111111111111111111是" .. this.resetCount)
|
|||
|
|
this.SetBossState(this.powerValue)
|
|||
|
|
Log("已经有的精气值" .. this.powerValue)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
|
|||
|
|
-- 试炼副本可复活次数, 随着VIP改变
|
|||
|
|
function this.GetRelifeTimes()
|
|||
|
|
local limitDeadTimes = trailSetting[1].RebornTimes
|
|||
|
|
return limitDeadTimes
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 取得最初的服务器精气值
|
|||
|
|
function this.UpdatePowerValue(value)
|
|||
|
|
this.powerValue = value
|
|||
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TrialMap.OnPowerValueChanged)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 设置标志位
|
|||
|
|
function this.SetBossState(value)
|
|||
|
|
if value < 0 then
|
|||
|
|
this.isHaveBoss = true
|
|||
|
|
else
|
|||
|
|
this.isHaveBoss = false
|
|||
|
|
end
|
|||
|
|
this.canCallBoss = value >= 100
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 进入下一层
|
|||
|
|
function this.GoNextLevel()
|
|||
|
|
local curMapId = trailConfig[MapTrialManager.curTowerLevel + 1].MapId
|
|||
|
|
this.isChangeLevel = true
|
|||
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out, curMapId, 1)
|
|||
|
|
this.bossType = 0
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 是否是试炼副本的最后一层
|
|||
|
|
function this.IsFinalLevel()
|
|||
|
|
local isFinalLevel = false
|
|||
|
|
if CarbonManager.difficulty == 2 then
|
|||
|
|
local curMapData = trailConfig[MapTrialManager.curTowerLevel + 1]
|
|||
|
|
if not curMapData or curMapData.MapId == 0 then
|
|||
|
|
isFinalLevel = true
|
|||
|
|
Log("试炼副本的最后一层")
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return isFinalLevel
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 设置补给点数据
|
|||
|
|
function this.SetBuffList(buffs)
|
|||
|
|
this.trailBufferInfo = {}
|
|||
|
|
for _, buff in ipairs(buffs) do
|
|||
|
|
table.insert(this.trailBufferInfo, buff)
|
|||
|
|
end
|
|||
|
|
table.sort(this.trailBufferInfo, function (a, b)
|
|||
|
|
return a.towerLevel < b.towerLevel
|
|||
|
|
end)
|
|||
|
|
return this.trailBufferInfo
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 获取buff列表
|
|||
|
|
function this.GetBuffList()
|
|||
|
|
return this.trailBufferInfo
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 删除某补给点
|
|||
|
|
function this.RemoveBuff(level, eventId)
|
|||
|
|
local removeIndex
|
|||
|
|
for index, buff in ipairs(this.trailBufferInfo) do
|
|||
|
|
if buff.towerLevel == level and buff.eventId == eventId then
|
|||
|
|
removeIndex = index
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if removeIndex then
|
|||
|
|
table.remove(this.trailBufferInfo, removeIndex)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
function this.SetRolePos(u, v)
|
|||
|
|
local pos = Map_UV2Pos(u, v)
|
|||
|
|
--local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(u, v))
|
|||
|
|
--v2 = v2 / math.min(Screen.width/1080, Screen.height/1920)
|
|||
|
|
--v2.x = Screen.width/1080 > 1 and v2.x - 180 or v2.x
|
|||
|
|
this.rolePos = SetObjPosByUV(pos)
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 登录时试炼副本的层级数据
|
|||
|
|
function this.InitTrialRewardData(gotLevelData)
|
|||
|
|
this.gotRewardLevel = {}
|
|||
|
|
if gotLevelData and #gotLevelData > 0 then
|
|||
|
|
for i = 1, #gotLevelData do
|
|||
|
|
Log("已经领取的奖励层数" .. gotLevelData[i])
|
|||
|
|
this.gotRewardLevel[gotLevelData[i]] = gotLevelData[i]
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 某一层的奖励领取状态
|
|||
|
|
-- 0 已经领取,1 可领取,2不能领取
|
|||
|
|
function this.GetRewardState(levelNum)
|
|||
|
|
if this.gotRewardLevel[levelNum] and this.gotRewardLevel[levelNum] > 0 then
|
|||
|
|
return 0
|
|||
|
|
elseif not this.gotRewardLevel[levelNum] then
|
|||
|
|
if levelNum > this.highestLevel then
|
|||
|
|
return 2
|
|||
|
|
elseif levelNum <= this.highestLevel then
|
|||
|
|
return 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 获得试炼副本的层数奖励数据
|
|||
|
|
function this.GetLevelReward()
|
|||
|
|
local dataList = {}
|
|||
|
|
-- 遍历这个表看看
|
|||
|
|
for i, v in ConfigPairs(trailConfig) do
|
|||
|
|
local rewardData = v.FloorReward
|
|||
|
|
if rewardData and rewardData[1][1] > 0 then
|
|||
|
|
local info = {}
|
|||
|
|
info.rewardInfo = v
|
|||
|
|
info.state = this.GetRewardState(v.Id)
|
|||
|
|
dataList[#dataList + 1] = info
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if #dataList > 1 then
|
|||
|
|
-- 数据大于1时重新排序
|
|||
|
|
table.sort(dataList, function(a, b)
|
|||
|
|
if a.state == 0 and b.state ~= 0 then
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
if a.state ~= 0 and b.state == 0 then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if a.state ~= b.state then
|
|||
|
|
return a.state < b.state
|
|||
|
|
else
|
|||
|
|
return a.rewardInfo.Id < b.rewardInfo.Id
|
|||
|
|
end
|
|||
|
|
end)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return dataList
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--Vip等级提升时刷新数据,5点时刷新数据
|
|||
|
|
function this.RefreshAttachVipData()
|
|||
|
|
this.resetCount=PrivilegeManager.GetPrivilegeRemainValue(trailSetting[1].DailyReset)
|
|||
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Carbon.RefreshCarbonData)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return this
|