2021-04-20 13:58:00 +08:00
|
|
|
|
MonsterCampManager = {};
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local this = MonsterCampManager
|
|
|
|
|
local monsterCampConfig = ConfigManager.GetConfig(ConfigName.FloodConfig)
|
|
|
|
|
local monsterGroupConfig = ConfigManager.GetConfig(ConfigName.MonsterGroup)
|
|
|
|
|
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
|
|
|
local monterViewConfig = ConfigManager.GetConfig(ConfigName.MonsterViewConfig)
|
|
|
|
|
local heroViewConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
local resConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
2021-01-28 11:12:22 +08:00
|
|
|
|
this.isMaxMonsterWave = false
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function this.Initialize()
|
2021-01-28 11:12:22 +08:00
|
|
|
|
this.isMaxMonsterWave = false
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.monsterWave = 0 -- 当前妖兽波次
|
|
|
|
|
this.m_Jump = false -- 跳过战斗设置
|
2021-01-07 19:24:04 +08:00
|
|
|
|
this.getRewardWave = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.SetRewardWave(waves)
|
|
|
|
|
if not this.getRewardWave then
|
|
|
|
|
this.getRewardWave = {}
|
|
|
|
|
end
|
|
|
|
|
for i = 1 ,#waves do
|
|
|
|
|
if not this.getRewardWave[waves[i]] then
|
|
|
|
|
this.getRewardWave[waves[i]] = waves[i]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 返回5个大虾的信息, 显示怪物的第一个,
|
|
|
|
|
function this.GetNextWaveMonsterInfo()
|
|
|
|
|
local curWave = this.monsterWave
|
|
|
|
|
local monsterInfo = {}
|
|
|
|
|
--遇到表格的结尾处,则停止
|
|
|
|
|
for i = curWave + 1, curWave + 5 do
|
|
|
|
|
if not monsterCampConfig[i] then break end
|
|
|
|
|
local data = {}
|
|
|
|
|
data.rewardShow = monsterCampConfig[i].RewardShow
|
|
|
|
|
local monsterGroupId = monsterCampConfig[i].Monster
|
|
|
|
|
-- 默认显示第一只怪
|
|
|
|
|
local id = monsterGroupConfig[monsterGroupId].Contents[1][1]
|
|
|
|
|
local monsterId = monsterConfig[id].MonsterId
|
|
|
|
|
local resId = 0
|
|
|
|
|
if monsterId > 10000 then -- 这是人类
|
|
|
|
|
resId = heroViewConfig[monsterId].Icon
|
|
|
|
|
else -- 这是妖精
|
|
|
|
|
resId = monterViewConfig[monsterId].MonsterIcon
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local resPath = GetResourcePath(resId)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
local icon = resPath
|
2020-05-09 13:31:21 +08:00
|
|
|
|
data.icon = icon
|
2021-01-26 17:08:39 +08:00
|
|
|
|
data.name = GetLanguageStrById(resConfig[resId].Desc)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
monsterInfo[i] = data
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return monsterInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 返回当前怪物阵容信息
|
|
|
|
|
function this.GetCurMonsterInfo()
|
|
|
|
|
local curWave = this.monsterWave
|
|
|
|
|
local monsterInfo = {}
|
|
|
|
|
local mainMonsterInfo = {}
|
|
|
|
|
local data = {}
|
|
|
|
|
data.icon = {}
|
|
|
|
|
data.level={}
|
|
|
|
|
data.rewardShow = monsterCampConfig[curWave].RewardShow
|
|
|
|
|
local monsterGroupId = monsterCampConfig[curWave].Monster
|
|
|
|
|
|
|
|
|
|
local ids = monsterGroupConfig[monsterGroupId].Contents
|
|
|
|
|
for i = 1, #ids do
|
|
|
|
|
for j = 1, #ids[i] do
|
|
|
|
|
-- 所有怪信息
|
|
|
|
|
local monsterId = monsterConfig[ids[i][j]].MonsterId
|
|
|
|
|
local resId = 0
|
|
|
|
|
if monsterId > 10000 then -- 这是人类
|
|
|
|
|
resId = heroViewConfig[monsterId].Icon
|
|
|
|
|
else -- 这是妖精
|
|
|
|
|
resId = monterViewConfig[monsterId].MonsterIcon
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local resPath = GetResourcePath(resId)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
local icon = resPath
|
2020-05-09 13:31:21 +08:00
|
|
|
|
data.icon[#data.icon + 1] = icon
|
|
|
|
|
data.level[j]= monsterConfig[ids[i][j]].Level
|
|
|
|
|
-- 主怪信息
|
|
|
|
|
if i == 1 and j == 1 then
|
2021-01-26 17:08:39 +08:00
|
|
|
|
mainMonsterInfo.name = GetLanguageStrById(resConfig[resId].Desc)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
mainMonsterInfo.live2dPath = resConfig[resId].Name
|
|
|
|
|
mainMonsterInfo.monsterId = monsterId
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
monsterInfo = data
|
|
|
|
|
return monsterInfo, mainMonsterInfo
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 消耗道具上限值
|
|
|
|
|
function this.GetMaxCostItem()
|
|
|
|
|
return PrivilegeManager.GetPrivilegeNumber(23)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 是否需要回复
|
|
|
|
|
function this.IsNeedSupply()
|
|
|
|
|
return BagManager.GetItemCountById(53) < this.GetMaxCostItem()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--返回当前的怪物组Id
|
|
|
|
|
function this.GetCurWaveMonsterGroupId()
|
2021-01-28 11:12:22 +08:00
|
|
|
|
if not monsterCampConfig[this.monsterWave] and this.monsterWave > MonsterCampManager.GetMaxNum() then
|
|
|
|
|
this.monsterWave = MonsterCampManager.GetMaxNum()
|
|
|
|
|
this.isMaxMonsterWave = true
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return monsterCampConfig[this.monsterWave].Monster
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 通过怪物ID返回头像
|
|
|
|
|
function this.GetIconByMonsterId(monsterId)
|
|
|
|
|
local resId = 0
|
|
|
|
|
local level = 0
|
|
|
|
|
local icon
|
|
|
|
|
local liveId = monsterConfig[monsterId].MonsterId
|
|
|
|
|
if liveId > 10000 then -- 这是人类
|
|
|
|
|
resId = heroViewConfig[liveId].Icon
|
|
|
|
|
else -- 这是妖精
|
|
|
|
|
resId = monterViewConfig[liveId].MonsterIcon
|
|
|
|
|
end
|
|
|
|
|
level = monsterConfig[monsterId].Level
|
2021-04-21 13:12:04 +08:00
|
|
|
|
icon = GetResourcePath(resId)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return icon, level
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取表的上限值
|
|
|
|
|
function this.GetMaxNum()
|
|
|
|
|
local max = 0
|
|
|
|
|
for k, v in ConfigPairs(monsterCampConfig) do
|
|
|
|
|
max = max > k and max or k
|
|
|
|
|
end
|
|
|
|
|
return max
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 跳过战斗设置
|
|
|
|
|
function this.GetBattleJump()
|
2020-06-13 11:47:13 +08:00
|
|
|
|
return false
|
|
|
|
|
-- if not this.CheckBattleJump() then
|
|
|
|
|
-- return false
|
|
|
|
|
-- end
|
|
|
|
|
-- return this.m_Jump
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.SetBattleJump(state)
|
|
|
|
|
this.m_Jump = state
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.CheckBattleJump()
|
|
|
|
|
local isOpen = PrivilegeManager.GetPrivilegeOpenStatus(PRIVILEGE_TYPE.MonsterCampJump)
|
|
|
|
|
return isOpen
|
|
|
|
|
end
|
|
|
|
|
|
2021-01-07 19:24:04 +08:00
|
|
|
|
-- 0 已经领取,1 可领取,2不能领取·
|
|
|
|
|
function this.GetTrialRewardState(id)
|
2021-01-12 19:21:20 +08:00
|
|
|
|
if id < this.monsterWave then
|
2021-01-07 19:24:04 +08:00
|
|
|
|
if this.getRewardWave[id] and this.getRewardWave[id] > 0 then
|
|
|
|
|
return 0
|
|
|
|
|
else
|
|
|
|
|
return 1
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return 2
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function this.SetRewardData()
|
|
|
|
|
local dataList = {}
|
|
|
|
|
for k,v in ConfigPairs(ConfigManager.GetConfig(ConfigName.FloodConfig)) do
|
|
|
|
|
if v.SpecialReward and #v.SpecialReward > 0 then
|
|
|
|
|
local data = {}
|
|
|
|
|
data.Id = v.Id
|
2021-03-02 16:53:12 +08:00
|
|
|
|
data.info = string.format(Language[12166],v.Id)
|
2021-01-07 19:24:04 +08:00
|
|
|
|
data.BoxReward = v.SpecialReward
|
|
|
|
|
data.state = this.GetTrialRewardState(v.Id)
|
|
|
|
|
table.insert(dataList,data)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return dataList
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-05-25 14:51:26 +08:00
|
|
|
|
--新心魔试炼
|
|
|
|
|
-- 获取剩余挑战次数 特权
|
|
|
|
|
function this.GetCanBattleCount()
|
|
|
|
|
return PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.MONSTERCAMP_BATTLENUM)
|
|
|
|
|
end
|
|
|
|
|
-- 获取剩余挑战购买次数 特权
|
|
|
|
|
function this.GetCanBuyBattleCount()
|
|
|
|
|
return PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM)
|
|
|
|
|
end
|
|
|
|
|
--心魔试炼特权购买信息
|
|
|
|
|
function this.MonsterCampGetCost()
|
|
|
|
|
local buyTimeId = PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM
|
|
|
|
|
local storeData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig, "StoreId", 7, "Limit", buyTimeId)
|
|
|
|
|
--商店表数据
|
|
|
|
|
local buyTimes = (PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId) + 1) > PrivilegeManager.GetPrivilegeNumber(buyTimeId)
|
|
|
|
|
and PrivilegeManager.GetPrivilegeNumber(buyTimeId) or (PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId) + 1)
|
|
|
|
|
return storeData.Id, storeData.Cost[1][1],storeData.Cost[2][buyTimes]
|
|
|
|
|
end
|
2021-05-25 20:50:23 +08:00
|
|
|
|
--心魔试炼特权一键扫荡购买信息
|
|
|
|
|
function this.MonsterCampGetYJGMCost()
|
|
|
|
|
local buyTimeId = PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM
|
|
|
|
|
local storeData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig, "StoreId", 7, "Limit", buyTimeId)
|
|
|
|
|
--商店表数据
|
|
|
|
|
local allNum = PrivilegeManager.GetPrivilegeNumber(buyTimeId)
|
|
|
|
|
local useNum = PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId)
|
|
|
|
|
local shengNum = allNum - useNum
|
|
|
|
|
local maNum = 0
|
|
|
|
|
for i = 1, shengNum do
|
|
|
|
|
local buyTimes = (PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId) + i) > PrivilegeManager.GetPrivilegeNumber(buyTimeId)
|
|
|
|
|
and PrivilegeManager.GetPrivilegeNumber(buyTimeId) or (PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId) + i)
|
|
|
|
|
maNum = maNum + storeData.Cost[2][buyTimes]
|
|
|
|
|
end
|
|
|
|
|
return storeData.Id, storeData.Cost[1][1],maNum,shengNum
|
|
|
|
|
end
|
2021-05-25 14:51:26 +08:00
|
|
|
|
--获取心魔试炼表数据
|
|
|
|
|
function this.GetMonstersInfo()
|
|
|
|
|
local datas = {}
|
2021-05-25 20:50:23 +08:00
|
|
|
|
local i = 10
|
2021-05-25 14:51:26 +08:00
|
|
|
|
for _, configInfo in ConfigPairs(monsterCampConfig) do
|
2021-05-25 20:50:23 +08:00
|
|
|
|
if i <= 0 then
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
if configInfo.Id > this.monsterWave then
|
|
|
|
|
i = i - 1
|
|
|
|
|
end
|
2021-05-25 14:51:26 +08:00
|
|
|
|
table.insert(datas,configInfo)
|
|
|
|
|
end
|
|
|
|
|
return datas
|
|
|
|
|
end
|
|
|
|
|
--扫荡
|
|
|
|
|
function this.MonsterCampBattle(id,type,func)
|
|
|
|
|
NetManager.FourChallengeDoRequest(id,type,function(msg)
|
|
|
|
|
if type == 0 then
|
|
|
|
|
local fightData = BattleManager.GetBattleServerData(msg,0)
|
|
|
|
|
this.drop = msg.drop
|
|
|
|
|
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.FOURELEMENT,function(result)
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
|
|
|
|
if result.result == 0 then
|
|
|
|
|
elseif result.result == 1 then
|
|
|
|
|
this.fourMonsterData[curType].monsterWave = id
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
|
|
|
|
|
if func then
|
|
|
|
|
func()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2021-05-26 11:48:44 +08:00
|
|
|
|
function this.CarbonRedCheck()
|
|
|
|
|
return this.GetCanBattleCount() > 0
|
|
|
|
|
end
|
2021-05-25 14:51:26 +08:00
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|