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

244 lines
8.3 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.

MapTrialManager = {};
local this = MapTrialManager
local trailSetting = ConfigManager.GetConfig(ConfigName.TrialSetting)
local trailConfig = ConfigManager.GetConfig(ConfigName.TrialConfig)
local trialwelfareConfig=ConfigManager.GetConfig(ConfigName.TrialwelfareConfig)
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 -- 试炼副本重置后进图
this.selectHeroDid="" --已选择英雄的动态id
this.cell=nil --传送门位置
-- this.isFirstIn=false --是否第一次进入副本 退出副本时置为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.GoSurprisedLevel()
LogPink("问号????????????????")
local mapId=0
for i = 1, LengthOfTable(trialwelfareConfig) do
if MapTrialManager.curTowerLevel>=trialwelfareConfig[i].Section[1] and MapTrialManager.curTowerLevel<=trialwelfareConfig[i].Section[2] then
mapId= trialwelfareConfig[i].MapId
end
end
this.isChangeLevel = true
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out, mapId, 1)
this.bossType = 0
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
--设置英雄血量数据 data剩余血量
function this.SetHeroHp(data,func)
for i, v in ipairs(MapManager.trialHeroInfo) do
if v.heroId==this.selectHeroDid then
v.heroHp=data[1]
end
end
Game.GlobalEvent:DispatchEvent(GameEvent.Map.RefreshHeroHp,false)
if func then func() end
end
return this