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

340 lines
11 KiB
Lua
Raw Normal View History

2021-04-20 13:58:00 +08:00
MapTrialManager = {};
2020-05-09 13:31:21 +08:00
local this = MapTrialManager
local trailSetting = ConfigManager.GetConfig(ConfigName.TrialSetting)
local trailConfig = ConfigManager.GetConfig(ConfigName.TrialConfig)
2020-06-12 18:04:22 +08:00
local trialKillConfig=ConfigManager.GetConfig(ConfigName.TrialKillConfig)
2020-05-09 13:31:21 +08:00
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 -- 换层时不可寻路
2020-06-12 18:04:22 +08:00
-- this.gotRewardLevel = {} -- 已经领取奖励的层数
2020-05-09 13:31:21 +08:00
this.firstEnter = false -- 试炼副本重置后进图
2020-06-03 19:09:01 +08:00
this.selectHeroDid="" --已选择英雄的动态id
this.cell=nil --传送门位置
-- this.isFirstIn=false --是否第一次进入副本 退出副本时置为false
2020-06-12 18:04:22 +08:00
this.trialRewardInfo={} --试炼领奖信息
this.killCount=0 --已击杀小怪数量
2020-07-16 17:28:48 +08:00
this.bombUsed=0 --炸弹已使用次数
2022-08-17 14:23:45 +08:00
this.towerCleanFloor=0 --可以扫荡的层数
this.isSweep=false --是否可以扫荡
2020-05-09 13:31:21 +08:00
end
2020-12-11 17:21:04 +08:00
-- 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.trialRewardInfo=towerCopyInfo.trialRewardInfo
-- this.InitTrialRewardData(towerCopyInfo.trialRewardInfo)
-- this.killCount=towerCopyInfo.killCount
-- this.bombUsed=towerCopyInfo.bombUsed
2020-05-09 13:31:21 +08:00
2020-12-11 17:21:04 +08:00
-- -- 最后一层需要赋值
-- this.bossDeadTime = towerCopyInfo.towerUseTime
2020-05-09 13:31:21 +08:00
2020-12-11 17:21:04 +08:00
-- Log("towerUseTime ============" .. towerCopyInfo.towerUseTime)
-- Log("111111111111111111111111111111是" .. this.resetCount)
2020-12-11 17:21:04 +08:00
-- this.SetBossState(this.powerValue)
-- Log("已经有的精气值" .. this.powerValue)
2020-12-11 17:21:04 +08:00
-- end
2020-05-09 13:31:21 +08:00
-- 取得最初的服务器精气值
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()
2020-08-18 15:48:41 +08:00
-- local curMapId = trailConfig[MapTrialManager.curTowerLevel + 1].MapId
2020-05-09 13:31:21 +08:00
this.isChangeLevel = true
2020-08-18 21:03:55 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out, 2)
MapTrialManager.isHaveBoss = false
2020-05-09 13:31:21 +08:00
this.bossType = 0
end
2020-07-21 09:38:34 +08:00
-- 是否是试炼副本的最后一层(没有最后一层了,判断是否是问号层)
2020-05-09 13:31:21 +08:00
function this.IsFinalLevel()
local isFinalLevel = false
2020-07-21 09:38:34 +08:00
if MapTrialManager.curTowerLevel > 10000 then
MapTrialManager.curTowerLevel = MapTrialManager.curTowerLevel - 10000
end
2020-05-09 13:31:21 +08:00
if CarbonManager.difficulty == 2 then
local curMapData = trailConfig[MapTrialManager.curTowerLevel + 1]
if not curMapData or curMapData.MapId == 0 then
isFinalLevel = true
Log("试炼副本的最后一层")
2020-05-09 13:31:21 +08:00
end
end
return isFinalLevel
end
2020-06-03 19:09:01 +08:00
-- 黄四郎:三天之后,一定给县长一个惊喜
-- 张麻子:汤师爷,他是胡万的恩人,现在又成了你的恩人。你给翻译翻译,什么叫惊喜?翻译翻译,什么叫惊喜?
-- 汤师爷:这还用翻译,都说了。
-- 张麻子:我让你翻译给我听,什么叫惊喜?
-- 汤师爷:不用翻译,这就是惊喜啊。
-- 黄四郎:难道你听不懂什么叫惊喜?
-- 张麻子:我就想让你翻译翻译,什么叫惊喜!
-- 汤师爷:惊喜嘛
-- 张麻子:翻译出来给我听,什么他妈的 叫惊喜!什么他妈的 叫他妈的 惊喜!
-- 汤师爷:什么他妈的叫惊喜啊?
-- 黄四郎:惊喜就是三天之后,我出一百八十万给你们出城剿匪,接上我的腿!明白了吗?
-- 汤师爷:这就是惊喜啊
-- 张麻子:翻译翻译 翻译翻译!
-- 汤师爷:惊喜就是三天之后,给你一百八十万两银子出城剿匪,接上他的腿!
-- 张麻子:哈,大哥这他妈的惊喜啊,小弟我愿意等你三天
-- 黄四郎:好
function this.GoSurprisedLevel()
2020-08-18 16:36:24 +08:00
-- local mapId = this.GetSurprisedLevelMapId()
2020-06-03 19:09:01 +08:00
this.isChangeLevel = true
2020-08-18 21:03:55 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Map.Out,2)
MapTrialManager.isHaveBoss = false
2020-06-03 19:09:01 +08:00
this.bossType = 0
end
2020-06-18 20:39:29 +08:00
-- 获取惊喜层地图id
function this.GetSurprisedLevelMapId()
2020-07-21 09:38:34 +08:00
if MapTrialManager.curTowerLevel < 10000 then
MapTrialManager.curTowerLevel = MapTrialManager.curTowerLevel + 10000
2020-06-18 20:39:29 +08:00
end
local mId = 0
for mapId, _ in ConfigPairs(trailConfig) do
2020-07-21 09:38:34 +08:00
if mapId >= MapTrialManager.curTowerLevel then
2020-06-18 20:39:29 +08:00
mId = mapId
break
end
end
return trailConfig[mId].MapId
end
2020-05-09 13:31:21 +08:00
-- 设置补给点数据
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
2020-06-13 11:47:13 +08:00
------ 试练副本奖励相关 ------
-- 登录时试炼副本的奖励领取数据
2020-05-09 13:31:21 +08:00
function this.InitTrialRewardData(gotLevelData)
2020-06-12 18:04:22 +08:00
this.trialRewardInfo = {}
2020-05-09 13:31:21 +08:00
if gotLevelData and #gotLevelData > 0 then
for i = 1, #gotLevelData do
-- LogPink("已经领取的奖励层数" .. gotLevelData[i])
2020-06-12 18:04:22 +08:00
this.trialRewardInfo[gotLevelData[i]] = gotLevelData[i]
2020-05-09 13:31:21 +08:00
end
end
end
2020-06-13 11:47:13 +08:00
-- 获取试练奖励领取状态
-- 0 已经领取1 可领取2不能领取·
function this.GetTrialRewardState(id)
if #this.trialRewardInfo>0 then --若存在数据 说明已领取
for i, v in ipairs(this.trialRewardInfo) do
if id==v then
return 0
2020-06-12 18:04:22 +08:00
end
end
2020-05-09 13:31:21 +08:00
end
if this.killCount < trialKillConfig[id].Count then
return 2
elseif this.killCount >= trialKillConfig[id].Count then
return 1
end
2020-06-13 11:47:13 +08:00
end
2020-08-28 13:48:09 +08:00
--任务红点检测
function this.TrialRewardRedPointCheck()
local d={}
for _, configInfo in ConfigPairs(trialKillConfig) do
table.insert(d, configInfo)
end
for i = 1, #d do
local state = MapTrialManager.GetTrialRewardState(d[i].Id)
if state == 1 then
return true
end
end
return false
end
2020-06-13 11:47:13 +08:00
--设置试练奖励信息
function this.SetTrialRewardInfo(v)
table.insert(this.trialRewardInfo,v)
end
--获取试练奖励信息
function this.GetTrialRewardInfo()
return this.trialRewardInfo
end
--重置清空奖励信息
function this.ClearTrialRewardInfo()
this.trialRewardInfo={}
end
--设置试练已杀小怪数量
function this.SetKillCount(v)
2020-08-28 13:48:09 +08:00
CheckRedPointStatus(RedPointType.TrialReward)
2020-08-28 17:29:38 +08:00
CheckRedPointStatus(RedPointType.Trial)
2020-06-13 11:47:13 +08:00
this.killCount=v
end
--获取已杀小怪数量
function this.GetKilCount()
return this.killCount
2020-05-09 13:31:21 +08:00
end
2020-06-13 11:47:13 +08:00
---------------------------------------
2020-05-09 13:31:21 +08:00
-- 获得试炼副本的层数奖励数据
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
2020-06-13 11:47:13 +08:00
info.state = this.GetTrialRewardState(v.Id)
2020-05-09 13:31:21 +08:00
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
2020-06-03 19:09:01 +08:00
2020-06-08 13:57:30 +08:00
--设置英雄血量数据 data剩余血量;did 选中英雄的did
function this.SetHeroHp(data,did,func)
2020-06-03 19:09:01 +08:00
for i, v in ipairs(MapManager.trialHeroInfo) do
2020-06-08 13:57:30 +08:00
if v.heroId==did then
2020-06-03 19:09:01 +08:00
v.heroHp=data[1]
end
end
if func then func() end
end
2020-08-27 13:59:14 +08:00
function this.TrialRedCheck()
2021-01-06 17:30:48 +08:00
local text =PlayerManager.uid.."TrialReset"
local cTime = GetTimeStamp()
local sdata = ActTimeCtrlManager.GetSerDataByTypeId(30)
if not sdata then
return false
end
local freshTime = sdata.endTime
2021-01-06 17:30:48 +08:00
if not PlayerPrefs.HasKey(text) then
PlayerPrefs.SetInt(PlayerManager.uid.."Trial",0)--森罗每两天五点刷新重置红点
PlayerPrefs.SetInt(text,freshTime)
end
if PlayerPrefs.GetInt(text) < cTime then
PlayerPrefs.SetInt(PlayerManager.uid.."Trial",0)--森罗每两天五点刷新重置红点
PlayerPrefs.SetInt(text,freshTime)
end
2020-08-28 17:29:38 +08:00
local var = PlayerPrefs.GetInt(PlayerManager.uid.."Trial")
if var == 0 and ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.TRIAL) then
2020-08-27 13:59:14 +08:00
return true
end
2020-08-28 17:29:38 +08:00
return MapTrialManager.TrialRewardRedPointCheck()
2020-08-27 13:59:14 +08:00
end
function this.SetRewardData()
local dataList = {}
for k,v in ConfigPairs(ConfigManager.GetConfig(ConfigName.TrialKillConfig)) do
local data = {}
data.Id = v.Id
2021-03-02 16:53:12 +08:00
data.info = string.format(Language[11483],v.Count,MapTrialManager.GetKilCount(),v.Count)
data.BoxReward = v.BoxReward
data.state = MapTrialManager.GetTrialRewardState(v.Id)
table.insert(dataList,data)
end
return dataList
end
2020-06-23 18:36:24 +08:00
return this