miduo_client/Assets/ManagedResources/~Lua/Modules/MonsterCamp/MonsterCampManager.lua

1040 lines
40 KiB
Lua
Raw Normal View History

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)
2020-12-14 09:54:50 +08:00
local CampTowerConfig = ConfigManager.GetConfig(ConfigName.CampTowerConfig)
2020-12-22 20:33:35 +08:00
local campTowerSetting = ConfigManager.GetConfig(ConfigName.CampTowerSetting)
2021-01-04 11:39:58 +08:00
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
2021-02-07 14:09:05 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
2021-03-11 18:47:56 +08:00
this.oldpower = 0
2020-12-14 09:54:50 +08:00
--四灵试炼数据
this.fourMonsterData = {}
2021-03-10 17:31:40 +08:00
this.CurOffsetIndex = -1
2020-05-09 13:31:21 +08:00
function this.Initialize()
2021-08-31 11:08:12 +08:00
this.allTreasures = {}
this.friendHelpHeros = {}
this.isMaxMonsterWave = false
2020-05-09 13:31:21 +08:00
this.monsterWave = 0 -- 当前妖兽波次
this.m_Jump = false -- 跳过战斗设置
2020-12-21 09:51:08 +08:00
----------------------------------------------------------------------四灵试炼------------------------------------------------------------------
2020-12-14 09:54:50 +08:00
local config = {}
for i = 1 ,4 do
this.fourMonsterData[i] = {}
2020-12-22 20:33:35 +08:00
this.fourMonsterData[i].freeTimeId = campTowerSetting[1].FlashTimesPrice[i][1]
this.fourMonsterData[i].buyTimeId = campTowerSetting[1].FlashTimesPrice[i][2]
this.fourMonsterData[i].teamId = campTowerSetting[1].Formation[i]
2020-12-21 09:51:08 +08:00
this.fourMonsterData[i].monsterWave = 0
--0 未开 1已开
2020-12-22 20:33:35 +08:00
this.fourMonsterData[i].openState = 1
2020-12-21 09:51:08 +08:00
this.fourMonsterData[i].freeTime = 0
this.fourMonsterData[i].buyTime = 0
2020-12-22 20:33:35 +08:00
this.fourMonsterData[i].canFightTime = 10
2020-12-21 09:51:08 +08:00
this.fourMonsterData[i].fourElementType = i
2020-12-14 09:54:50 +08:00
end
2021-09-01 14:17:21 +08:00
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionOpen, function(fightId)
if fightId == FUNCTION_OPEN_TYPE.FourElementTrail then
CheckRedPointStatus(RedPointType.PersonTrail)
CheckRedPointStatus(RedPointType.BuddishTrail)
CheckRedPointStatus(RedPointType.DemonTrail)
CheckRedPointStatus(RedPointType.TaoistTrail)
CheckRedPointStatus(RedPointType.PersonTrailHelp)
CheckRedPointStatus(RedPointType.BuddishTrailHelp)
CheckRedPointStatus(RedPointType.DemonTrailHelp)
CheckRedPointStatus(RedPointType.TaoistTrailHelp)
end
end)
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionClose, function(fightId)
if fightId == FUNCTION_OPEN_TYPE.FourElementTrail then
CheckRedPointStatus(RedPointType.PersonTrail)
CheckRedPointStatus(RedPointType.BuddishTrail)
CheckRedPointStatus(RedPointType.DemonTrail)
CheckRedPointStatus(RedPointType.TaoistTrail)
CheckRedPointStatus(RedPointType.PersonTrailHelp)
CheckRedPointStatus(RedPointType.BuddishTrailHelp)
CheckRedPointStatus(RedPointType.DemonTrailHelp)
CheckRedPointStatus(RedPointType.TaoistTrailHelp)
end
end)
2020-12-14 09:54:50 +08:00
end
function this.InitFourMonsterData(msg)
2020-12-21 09:51:08 +08:00
for i = 1 , #msg.info do
local index = msg.info[i].type
this.fourMonsterData[index].monsterWave = msg.info[i].currentFloor
this.fourMonsterData[index].canFightTime = msg.info[i].remainTimes
this.fourMonsterData[index].openState = msg.info[i].overTime
2021-03-10 17:31:40 +08:00
this.GetTimeTip(index)
2020-12-14 09:54:50 +08:00
end
2021-02-05 17:57:59 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.FourEle.RefreshView)
-- 四灵试炼层数变化会导致神将宝物属性变化
HeroPropManager.SetAllHeroDirtyByType(Hero_Prop_Type.EquipTreasure)
-- 重新计算宝物评分
EquipTreasureManager.SetAllTreasureDirty()
2020-12-14 09:54:50 +08:00
end
--设置扫荡剩余次数
function this.GetTimeTip(campId)
this.fourMonsterData[campId].buyTime = PrivilegeManager.GetPrivilegeRemainValue(this.fourMonsterData[campId].buyTimeId)
this.fourMonsterData[campId].freeTime= PrivilegeManager.GetPrivilegeRemainValue(this.fourMonsterData[campId].freeTimeId) --免费次数
2021-03-01 18:35:35 +08:00
if campId == 1 then
CheckRedPointStatus(RedPointType.PersonTrail)
elseif campId == 2 then
CheckRedPointStatus(RedPointType.BuddishTrail)
elseif campId == 3 then
CheckRedPointStatus(RedPointType.DemonTrail)
elseif campId == 4 then
CheckRedPointStatus(RedPointType.TaoistTrail)
end
2020-12-14 09:54:50 +08:00
return this.fourMonsterData[campId].freeTime,this.fourMonsterData[campId].buyTime
end
2020-12-21 20:24:36 +08:00
function this.GetCost(campId)
local buyTimeId = this.fourMonsterData[campId].buyTimeId
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
2020-12-14 09:54:50 +08:00
--获取当前通过的总层数
function this.GetFourElementTotalWave()
local waves = 0
for k,v in pairs(this.fourMonsterData) do
2020-12-21 09:51:08 +08:00
waves = waves + v.monsterWave
2020-12-14 09:54:50 +08:00
end
return waves
2020-05-09 13:31:21 +08:00
end
2021-12-10 17:37:07 +08:00
-- 当前兽潮层数
function this.GetMonsterCampCurWave()
return this.monsterWave
end
function this.SetMonsterCampCurWave(wave)
this.monsterWave = wave
end
2020-12-21 09:51:08 +08:00
function this.GetCurFourElementMonsterInfo(index)
return this.fourMonsterData[index]
end
2020-12-22 20:33:35 +08:00
--得到从第1层到当前层的数据
2020-12-21 09:51:08 +08:00
function this.GetFourElementMonstersInfo(curType,curWave)
local monsterInfo = {}
2021-08-31 19:03:29 +08:00
local data = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.CampTowerConfig,"CampId",curType,"FloorId",curWave)
if not data then
data = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.CampTowerConfig,"CampId",curType,"FloorId",curWave - 1)
end
2020-12-21 09:51:08 +08:00
for i = 1, curWave + data.UpLimitWave do
local tempData = this.GetFourElementMonsterInfoByWave(curType,i)
if tempData then
table.insert(monsterInfo,tempData)
end
2020-12-21 09:51:08 +08:00
end
return monsterInfo
end
function this.GetFourElementMonsterInfoByWave(curType,wave)
2021-08-31 19:03:29 +08:00
local tempConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.CampTowerConfig,"CampId",curType,"FloorId",wave)
2020-12-21 09:51:08 +08:00
if not tempConfig then
return nil
end
local data = {}
2020-12-21 20:24:36 +08:00
data.id = tempConfig.Id
2020-12-21 09:51:08 +08:00
data.wave = tempConfig.FloorId
--战力
data.power = tempConfig.Force
data.firstReward = {}
--首通奖励
if tempConfig.FirstReward and #tempConfig.FirstReward > 0 then
for i = 1, #tempConfig.FirstReward do
table.insert(data.firstReward,{id = tempConfig.FirstReward[i][1],num = tempConfig.FirstReward[i][2]})
end
end
data.commonReward = {}
--首通奖励
if tempConfig.CommonReward and #tempConfig.CommonReward > 0 then
for i = 1, #tempConfig.CommonReward do
table.insert(data.commonReward,{id = tempConfig.CommonReward[i][1],num = tempConfig.CommonReward[i][2]})
end
end
local monsterGroupId = tempConfig.Monster
-- 默认显示第一只怪
local id = monsterGroupConfig[monsterGroupId].Contents[1][1]
2020-12-22 20:33:35 +08:00
data.monster = monsterGroupConfig[monsterGroupId].Contents[1]
2020-12-21 09:51:08 +08:00
data.monsterConfig = monsterConfig[id]
data.herodata = this.SetSingleMonster(data.monsterConfig.MonsterId)
return data
end
function this.SetSingleMonster(id)
local herodata = {}
local _configData = ConfigManager.GetConfigData(ConfigName.HeroConfig,id)
2021-02-07 16:36:54 +08:00
herodata.heroConfig = _configData
2021-01-04 11:39:58 +08:00
herodata.heroViewConfig = _configData
2020-12-21 09:51:08 +08:00
herodata.live = GetResourcePath(_configData.Live)
herodata.painting = GetResourcePath(_configData.Painting)
herodata.icon = GetResourcePath(_configData.Icon)
herodata.scale = _configData.Scale
herodata.position = _configData.Position
herodata.profession = _configData.Profession
herodata.ProfessionResourceId = _configData.ProfessionResourceId
if GetJobSpriteStrByJobNum(_configData.Profession) then
herodata.professionIcon = GetJobSpriteStrByJobNum(_configData.Profession)
else
herodata.professionIcon = GetJobSpriteStrByJobNum(1)
end
herodata.name = _configData.ReadingName
herodata.property = _configData.PropertyName
return herodata
end
2020-12-21 20:24:36 +08:00
function this.GetMonsterTeamInfo(monsterGroupId)
local bossTeamsInfo = {}
local bossIds = monsterGroupConfig[monsterGroupId].Contents[1]
for i = 1, #bossIds do
local monsterData = {}
if bossIds[i] > 0 then
monsterData.monsterConfig = monsterConfig[bossIds[i]]
monsterData.herodata = this.SetSingleMonster(monsterData.monsterConfig.MonsterId)
end
table.insert(bossTeamsInfo,monsterData)
2020-12-21 09:51:08 +08:00
end
end
2020-12-21 20:24:36 +08:00
2021-08-30 14:21:41 +08:00
function this.StraightBattle(id,type,func,curType,isQuick)
2021-03-11 18:47:56 +08:00
this.oldpower = FormationManager.GetFormationPower(FormationManager.curFormationIndex)
LogGreen("oldpower:"..this.oldpower)
2021-02-22 18:42:26 +08:00
this.curType = curType
2021-02-03 14:29:22 +08:00
local fightId = ConfigManager.GetConfigDataByDoubleKey(ConfigName.CampTowerConfig,"FloorId",id,"CampId",curType).Id
NetManager.FourChallengeDoRequest(fightId,type,function(msg)
2021-08-30 14:21:41 +08:00
if isQuick then
local result = {}
result.drop = msg.drop
-- 设置战斗数据用于统计战斗
local _fightData = BattleManager.GetBattleServerData(msg,0)
this.drop = msg.drop
BattleRecordManager.SetBattleRecord(_fightData)
--用一个变量接收最近的战斗结果
this.lastBattleResult = {
result = msg.result,
hpList = {},
drop = msg.drop,
}
BattleManager.SetLastBattleResult(this.lastBattleResult,BATTLE_TYPE.FOURELEMENT)
if not msg.drop or ((not msg.drop.itemlist or #msg.drop.itemlist < 1)
and (not msg.drop.equipId or #msg.drop.equipId < 1)
and (not msg.drop.Hero or #msg.drop.Hero < 1)
and (not msg.drop.soulEquip or #msg.drop.soulEquip < 1)
and (not msg.drop.pokemon or #msg.drop.pokemon < 1)) then
2021-08-31 13:59:03 +08:00
UIManager.OpenPanel(UIName.BattleFailPopup, nil, true, nil,BATTLE_TYPE.FOURELEMENT)
Game.GlobalEvent:DispatchEvent(GameEvent.FourEle.RefreshView)
2021-08-30 14:21:41 +08:00
else
this.fourMonsterData[curType].monsterWave = id
UIManager.OpenPanel(UIName.BattleWinPopup, nil, false, BATTLE_TYPE.FOURELEMENT, result, true, true,function()
Game.GlobalEvent:DispatchEvent(GameEvent.FourEle.RefreshView)
end)
-- 四灵试炼层数变化会导致神将宝物属性变化
HeroPropManager.SetAllHeroDirtyByType(Hero_Prop_Type.EquipTreasure)
-- 重新计算宝物评分
EquipTreasureManager.SetAllTreasureDirty()
2021-08-30 14:21:41 +08:00
end
2020-12-21 20:24:36 +08:00
else
2021-08-30 14:21:41 +08:00
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
-- 四灵试炼层数变化会导致神将宝物属性变化
HeroPropManager.SetAllHeroDirtyByType(Hero_Prop_Type.EquipTreasure)
-- 重新计算宝物评分
EquipTreasureManager.SetAllTreasureDirty()
2021-08-30 14:21:41 +08:00
end
end)
else
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
if func then
func()
end
end)
end
end
2020-12-21 20:24:36 +08:00
end)
end
2021-01-04 11:39:58 +08:00
2021-02-22 18:42:26 +08:00
--开始战斗
2021-08-30 14:21:41 +08:00
function this.ExecuteFightBattle(id,type,func,curType,isQuick)
this.StraightBattle(id,type,func,curType,isQuick)
2021-02-22 18:42:26 +08:00
-- -- 请求战斗结果
-- NetManager.GetMonsterFightResult(MonsterCampManager.monsterWave, FormationTypeDef.FORMATION_NORMAL, function (msg)
-- if msg.result == 0 then
-- UIManager.OpenPanel(UIName.BattleFailPopup, nil, false, UIName.MonsterCampPanel)
-- else
-- local result = {}
-- result.drop = msg.enventDrop
-- UIManager.OpenPanel(UIName.BattleWinPopup, nil, false, BATTLE_TYPE.FOURELEMENT, result, true, true)
2021-12-10 17:37:07 +08:00
-- MonsterCampManager.SetMonsterCampCurWave(MonsterCampManager.monsterWave + 1)
2021-02-22 18:42:26 +08:00
-- end
-- end)
end
2021-02-07 17:54:48 +08:00
function this.SaveFormation(curType)
2021-09-02 17:29:44 +08:00
local curFormation = FormationManager.GetFormationByID(3000 + curType)
2021-02-07 17:54:48 +08:00
local data = this.GetFriendHelpHero(curType)
--上阵列表赋值
local choosedList ={}
if data then
for j = 1, #curFormation.teamHeroInfos do
local teamInfo = curFormation.teamHeroInfos[j]
-- 加空判断避免不知名错误
if teamInfo and teamInfo.heroId == data.hero.dynamicId then
data.player.state = 1
else
table.insert(choosedList, {heroId = teamInfo.heroId,position=teamInfo.position})
end
end
FormationManager.SaveFormation(
2021-09-02 17:29:44 +08:00
(3000 + curType),
2021-02-07 17:54:48 +08:00
choosedList,
2021-09-02 17:29:44 +08:00
FormationManager.formationList[(3000 + curType)].teamPokemonInfos
2021-02-07 17:54:48 +08:00
)
end
end
2021-01-04 11:39:58 +08:00
------------------------------四灵试炼 助战---------------------------------------
--创建一个英雄信息
2021-03-11 11:35:56 +08:00
function this.UpdateHeroDatas(_msgHeroData,_msgPlayerData)
2021-01-04 11:39:58 +08:00
local heroData = {}
heroData.soulPrintList={}
heroData.heroBackData=_msgHeroData
heroData.dynamicId = _msgHeroData.id
local _id = _msgHeroData.heroId
heroData.id = _id
heroData.star = _msgHeroData.star
heroData.lv = _msgHeroData.level--30
heroData.breakId=_msgHeroData.breakId
heroData.upStarId=_msgHeroData.starBreakId
heroData.createTime=_msgHeroData.createTimelocal
heroData.lockState = _msgHeroData.lockState
heroData.createtype = _msgHeroData.createtype
local _configData = heroViewConfig[_id]
heroData.skinId = _msgHeroData.skinId or 0
if heroData.skinId == 0 then
heroData.skinConfig = _configData
heroData.live = GetResourcePath(_configData.Live)
heroData.painting = GetResourcePath(_configData.Painting)
heroData.icon = GetResourcePath(_configData.Icon)
heroData.scale = _configData.Scale
heroData.position = _configData.Position
else
heroData.skinConfig = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",heroData.skinId)
heroData.live = GetResourcePath(heroData.skinConfig.Live)
heroData.painting = GetResourcePath(heroData.skinConfig.Painting)
heroData.icon = GetResourcePath(heroData.skinConfig.Icon)
heroData.scale = heroData.skinConfig.Scale
heroData.position = heroData.skinConfig.Position
end
heroData.heroViewConfig=heroViewConfig[_id]
heroData.maxStar=_configData.MaxRank
local actionPowerRormula= gameSetting[1].ActionPowerRormula
heroData.actionPower=heroData.heroViewConfig.ActionPower+math.floor(((actionPowerRormula[1] * math.pow(heroData.lv, 3) + actionPowerRormula[2] * math.pow(heroData.lv, 2) + actionPowerRormula[3] * heroData.lv + actionPowerRormula[4])))--_msgHeroData.actionPower
heroData.equipIdList=_msgHeroData.equipIdList
2021-02-07 14:09:05 +08:00
for i = 1 , #heroData.equipIdList do
EquipManager.SetEquipUpHeroDid(heroData.equipIdList[i],heroData.dynamicId)
end
2021-12-30 19:02:52 +08:00
-- heroData.homeEquipLv=_msgHeroData.homeEquipLv
2021-01-04 11:39:58 +08:00
heroData.jewels=_msgHeroData.jewels
2021-03-15 19:14:30 +08:00
this.InitBaoDatas(_msgPlayerData.jewels,_msgPlayerData.fourTotal,_msgPlayerData.treeLevel)
2021-02-07 14:09:05 +08:00
for i = 1 , #heroData.jewels do
this.SetEquipTreasureUpHeroDid(heroData.jewels[i],heroData.dynamicId)
end
2021-01-04 11:39:58 +08:00
heroData.talismanList = _msgHeroData.especialEquipLevel --法宝等级
if(#_msgHeroData.soulPos>=1) then
local soulPrintList = {}
for i,v in ipairs(_msgHeroData.soulPos) do
local soulPrint = { equipId = v.equipId, position = v.position}
-- SoulPrintManager.AddSoulPrintUpHeroDynamicId(v.equipId,heroData.dynamicId)
2021-01-04 11:39:58 +08:00
table.insert(soulPrintList, soulPrint)
end
heroData.soulPrintList= soulPrintList
end
2021-02-05 17:57:59 +08:00
heroData.heroConfig = heroViewConfig[_id]
2021-01-04 11:39:58 +08:00
heroData.skillIdList={}--主动技
HeroManager.UpdateSkillIdList(heroData)
heroData.passiveSkillList = {}--被动技
HeroManager.UpdatePassiveHeroSkill(heroData)
heroData.hp = _configData.Hp
heroData.attack = _configData.Attack
heroData.pDef = _configData.PhysicalDefence
heroData.mDef = _configData.MagicDefence
heroData.speed = _configData.Speed
heroData.live = GetResourcePath(_configData.Live)
heroData.profession = _configData.Profession
heroData.ProfessionResourceId= _configData.ProfessionResourceId
if GetJobSpriteStrByJobNum(_configData.Profession) then
heroData.professionIcon = GetJobSpriteStrByJobNum(_configData.Profession)
else
heroData.professionIcon = GetJobSpriteStrByJobNum(1)
end
heroData.name = _configData.ReadingName
heroData.property = _configData.PropertyName
2021-02-05 17:57:59 +08:00
heroData.createtype = 1
2021-03-15 19:14:30 +08:00
heroData.warPower = 0
2021-10-26 16:00:31 +08:00
heroData.godSoulLv = _msgHeroData.godSoulLv or 0
heroData.GetStar = function(index)
if heroData.godSoulLv and heroData.godSoulLv > 0 then
return heroData.godSoulLv,3
2021-11-03 10:13:44 +08:00
elseif heroData.star > 9 then
return heroData.star,2
2021-10-26 16:00:31 +08:00
end
return heroData.star,index
end
2021-01-04 11:39:58 +08:00
return heroData
end
2021-02-07 14:09:05 +08:00
--宝器
local jewelConfig = ConfigManager.GetConfig(ConfigName.JewelConfig)
2021-03-15 19:14:30 +08:00
function this.InitBaoDatas(_soulEquips,_fourTotal,_treeLevel)
2021-02-07 14:09:05 +08:00
if not this.allTreasures then
this.allTreasures = {}
end
if not _soulEquips then return end
for i = 1, #_soulEquips do
2021-03-15 19:14:30 +08:00
this.InitSingleTreasureData(_soulEquips[i],_fourTotal,_treeLevel)
2021-02-07 14:09:05 +08:00
end
end
--初始化单个宝物的数据
2021-03-15 19:14:30 +08:00
function this.InitSingleTreasureData(_singleData,_fourTotal,_treeLevel)
2021-02-07 15:52:52 +08:00
if not _singleData or not _singleData.equipId then
2021-02-07 14:09:05 +08:00
return
end
local single={}
local staticId=_singleData.equipId
local currJewel=jewelConfig[staticId]
single.id=staticId
single.idDyn=_singleData.id
single.lv=_singleData.exp
single.refineLv=_singleData.rebuildLevel
single.maxLv=currJewel.Max[1]
single.maxRefineLv=currJewel.Max[2]
single.upHeroDid=""
2021-03-11 14:44:48 +08:00
single.maxTreeLv = currJewel.GodHoodMaxlv
2021-03-15 19:14:30 +08:00
single.treeLv = _treeLevel
2021-08-30 18:09:06 +08:00
single.treePool = currJewel.GodHoodPool
2021-03-15 19:14:30 +08:00
single.fourTotal = _fourTotal
2021-02-07 14:09:05 +08:00
local quantity=currJewel.Level
single.quantity=quantity
single.frame=GetQuantityImageByquality(quantity)
single.name=itemConfig[staticId].Name
single.itemConfig=itemConfig[staticId]
single.levelPool=currJewel.LevelupPool
single.proIcon=GetProStrImageByProNum(currJewel.Race)
single.refinePool=currJewel.RankupPool
single.equipType=currJewel.Location
if currJewel.Location==1 then
single.type=Language[10505]
else
single.type=Language[10506]
end
single.icon=GetResourcePath(itemConfig[staticId].ResourceID)
single.strongConfig=this.GetCurrTreasureLvConfig(1,currJewel.LevelupPool,_singleData.exp)
single.refineConfig=this.GetCurrTreasureLvConfig(2,currJewel.RankupPool,_singleData.rebuildLevel)
this.allTreasures[_singleData.id]=single
end
local jewerLevelUpConfig = ConfigManager.GetConfig(ConfigName.JewelRankupConfig)
--获取当前宝物升级数据
function this.GetCurrTreasureLvConfig(_type,_id,_lv)
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
if configInfo.Type==_type and configInfo.PoolID==_id and configInfo.Level==_lv then
return configInfo
end
end
end
--根据动态id获取宝物
function this.GetSingleTreasureByIdDyn(_idDyn)
if not this.allTreasures[_idDyn] == nil then
return nil
end
return this.allTreasures[_idDyn]
end
--设置装备穿戴的英雄
function this.SetEquipTreasureUpHeroDid(_equipTreasureDid,_heroDid)
if this.allTreasures[_equipTreasureDid] then
this.allTreasures[_equipTreasureDid].upHeroDid=_heroDid
end
end
-----
2021-02-04 15:12:37 +08:00
---好友助战 界面数据
function this.GetFriendHelpHeros(trailType,func)
this.friendHelpHeros = {}
2021-01-04 11:39:58 +08:00
local x = function(msg)
for k,v in ipairs(msg.helpHeros) do
if not this.friendHelpHeros[v.trailType] then
this.friendHelpHeros[v.trailType] = {}
end
local tempdata = {}
2021-02-07 14:09:05 +08:00
tempdata.player = v
2021-03-11 11:35:56 +08:00
tempdata.hero = this.UpdateHeroDatas(v.hero,v)
2021-01-04 11:39:58 +08:00
table.insert(this.friendHelpHeros[v.trailType],tempdata)
local power = HeroPowerManager.GetHeroPower(tempdata.hero.dynamicId)
-- local allAddProVal = HeroManager.CalculateHeroAllProValList(1, tempdata.hero, false)
tempdata.hero.warPower = power--allAddProVal[HeroProType.WarPower]
2021-02-05 17:57:59 +08:00
end
if func then
func(this.friendHelpHeros[trailType])
2021-01-04 11:39:58 +08:00
end
end
--发消息获取信息 然后调用回调函数x
2021-02-03 18:40:26 +08:00
if trailType and trailType > 0 then
NetManager.HelpFightListRequest(trailType,x)
2021-02-04 15:12:37 +08:00
end
2021-01-04 11:39:58 +08:00
end
--设置好友帮助我的英雄 以试炼类型为键
2021-02-04 15:12:37 +08:00
function this.SetFriendHelpHero(helpFightList,trailType)
2021-01-04 11:39:58 +08:00
if not trailType then
2021-09-18 18:19:45 +08:00
for i = 1,4 do
local team = FormationManager.GetFormationByID(i + 3000)
if this.friendHelpHero and this.friendHelpHero[i] and this.friendHelpHero[i].hero then
2021-09-18 18:19:45 +08:00
local newteam = {}
for k,v in ipairs(team.teamHeroInfos) do
if v.heroId == this.friendHelpHero[i].hero.dynamicId then
2021-09-18 18:19:45 +08:00
else
table.insert(newteam,v)
end
end
if LengthOfTable(newteam) ~= LengthOfTable(team.teamHeroInfos) then
FormationManager.SaveFormation(
i + 3000,
2021-09-18 18:19:45 +08:00
newteam,
FormationManager.formationList[i + 3000].teamPokemonInfos)
2021-09-18 18:19:45 +08:00
end
end
end
2021-01-04 11:39:58 +08:00
this.friendHelpHero = {}
2021-09-22 20:47:13 +08:00
if helpFightList then
for k,v in ipairs(helpFightList) do
if not this.friendHelpHero[v.trailType] then
this.friendHelpHero[v.trailType] = {}
end
this.friendHelpHero[v.trailType].player = v
this.friendHelpHero[v.trailType].hero = this.UpdateHeroDatas(v.hero,v)
local allAddProVal = HeroManager.CalculateHeroAllProValList(1, this.friendHelpHero[v.trailType].hero, false)
this.friendHelpHero[v.trailType].hero.warPower = allAddProVal[HeroProType.WarPower]
2021-01-04 11:39:58 +08:00
end
end
2021-09-18 18:55:07 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Formation.OnFormationChange1)
2021-01-04 11:39:58 +08:00
else
if not this.friendHelpHero then
this.friendHelpHero = {}
2021-02-07 14:09:05 +08:00
end
2021-01-04 11:39:58 +08:00
if not this.friendHelpHero[trailType] then
this.friendHelpHero[trailType] = {}
end
2021-08-31 20:22:59 +08:00
2021-09-02 17:29:44 +08:00
local team = FormationManager.GetFormationByID(trailType + 3000)
2021-08-31 20:22:59 +08:00
if this.friendHelpHero[trailType].hero then
local newteam = {}
for k,v in ipairs(team.teamHeroInfos) do
if v.heroId == this.friendHelpHero[trailType].hero.dynamicId then
else
table.insert(newteam,v)
end
end
if LengthOfTable(newteam) ~= LengthOfTable(team.teamHeroInfos) then
FormationManager.SaveFormation(
2021-09-02 17:29:44 +08:00
trailType + 3000,
2021-09-01 10:08:25 +08:00
newteam,
2021-09-02 17:29:44 +08:00
FormationManager.formationList[trailType + 3000].teamPokemonInfos)
2021-08-31 20:22:59 +08:00
end
end
2021-02-04 15:12:37 +08:00
if helpFightList then
2021-08-31 20:22:59 +08:00
if this.friendHelpHero[trailType].hero then
local newteam = {}
for k,v in ipairs(team.teamHeroInfos) do
if v.heroId == this.friendHelpHero[trailType].hero.dynamicId then
else
table.insert(newteam,v)
end
end
if LengthOfTable(newteam) ~= LengthOfTable(team.teamHeroInfos) then
FormationManager.SaveFormation(
2021-08-31 20:22:59 +08:00
this.root.curFormationIndex,
this.root.choosedList,
FormationManager.formationList[this.root.curFormationIndex].teamPokemonInfos)
end
end
2021-02-04 15:12:37 +08:00
this.friendHelpHero[trailType].player = helpFightList
2021-03-11 11:35:56 +08:00
this.friendHelpHero[trailType].hero = this.UpdateHeroDatas(helpFightList.hero,helpFightList)
-- local allAddProVal = HeroManager.CalculateHeroAllProValList(1, this.friendHelpHero[trailType].hero, false)
2021-09-29 09:19:53 +08:00
local power = HeroPowerManager.GetHeroPower(helpFightList.hero.id)
this.friendHelpHero[trailType].hero.warPower = power -- allAddProVal[HeroProType.WarPower]
2021-01-04 11:39:58 +08:00
else
this.friendHelpHero[trailType] = nil
end
end
end
--获取当前试炼我选取的好友的助战
2021-02-05 17:57:59 +08:00
function this.GetFriendHelpHero(trailType,heros)
if heros then
local lvLimit = 0
if trailType then lvLimit = trailType end
for i, v in pairs(this.friendHelpHero) do
if v and v.hero and v.hero.lv > lvLimit then
table.insert(heros,v.hero)
end
end
return heros
else
if this.friendHelpHero[trailType] then
return this.friendHelpHero[trailType]
end
2021-01-04 11:39:58 +08:00
end
return nil
end
--设置助战
2021-02-04 15:12:37 +08:00
function this.SetMyHelpHeroData(trail,_data,func)
2021-01-04 11:39:58 +08:00
if not trail then
this.myHelpHeroData = {}
local x = function(msg)
2021-02-04 15:12:37 +08:00
for k,v in ipairs(msg.helpHeros) do
2021-01-04 11:39:58 +08:00
if not this.myHelpHeroData[v.trailType] then
this.myHelpHeroData[v.trailType] = {}
end
this.myHelpHeroData[v.trailType] = HeroManager.GetSingleHeroData(v.hero.id)
end
CheckRedPointStatus(RedPointType.PersonTrail)
CheckRedPointStatus(RedPointType.BuddishTrail)
CheckRedPointStatus(RedPointType.DemonTrail)
CheckRedPointStatus(RedPointType.TaoistTrail)
CheckRedPointStatus(RedPointType.PersonTrailHelp)
CheckRedPointStatus(RedPointType.BuddishTrailHelp)
CheckRedPointStatus(RedPointType.DemonTrailHelp)
CheckRedPointStatus(RedPointType.TaoistTrailHelp)
2021-01-04 11:39:58 +08:00
end
--发协议获取 调用x
2021-02-04 15:12:37 +08:00
NetManager.HelpFightListRequest(0,x)
2021-01-04 11:39:58 +08:00
else
if not this.myHelpHeroData then
this.myHelpHeroData = {}
end
if not this.myHelpHeroData[trail] then
this.myHelpHeroData[trail] = {}
end
this.myHelpHeroData[trail] = _data
2021-03-01 18:35:35 +08:00
if trail == 1 then
2021-03-08 17:54:22 +08:00
CheckRedPointStatus(RedPointType.PersonTrail)
2021-03-01 18:35:35 +08:00
elseif trail == 2 then
2021-03-08 17:54:22 +08:00
CheckRedPointStatus(RedPointType.BuddishTrail)
2021-03-01 18:35:35 +08:00
elseif trail == 3 then
2021-03-08 17:54:22 +08:00
CheckRedPointStatus(RedPointType.DemonTrail)
2021-03-01 18:35:35 +08:00
elseif trail == 4 then
2021-03-08 17:54:22 +08:00
CheckRedPointStatus(RedPointType.TaoistTrail)
2021-03-01 18:35:35 +08:00
end
2021-01-04 11:39:58 +08:00
end
2021-02-04 15:12:37 +08:00
if func then
func()
end
2021-01-04 11:39:58 +08:00
end
2021-02-04 15:12:37 +08:00
2021-01-04 11:39:58 +08:00
--获取我的助战
2021-02-05 17:57:59 +08:00
function this.GetMyHelpHero(trailType)
2021-01-04 11:39:58 +08:00
if this.myHelpHeroData[trailType] then
return this.myHelpHeroData[trailType]
end
return nil
end
2021-02-05 17:57:59 +08:00
--获取一个英雄信息
function this.GetSingleHeroData(did)
2021-03-10 18:03:36 +08:00
if not this.friendHelpHeros then
this.friendHelpHeros = {}
end
for _,v in pairs(this.friendHelpHeros) do
for i = 1 ,#v do
if v[i] and v[i].hero and v[i].hero.dynamicId == did then
return v[i].hero
end
2021-02-05 17:57:59 +08:00
end
end
2021-09-01 10:08:25 +08:00
for _,v in pairs(this.friendHelpHero) do
if v and v.hero and v.hero.dynamicId == did then
return v.hero
end
end
2021-02-05 17:57:59 +08:00
return nil
end
2021-01-04 11:39:58 +08:00
------------------------------四灵试炼 红点---------------------------------------
2021-03-01 18:35:35 +08:00
-- 红点检测方法
function this.FourElementRedCheck(redType)
if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.FourElementTrail) then
return false
end
2021-03-10 17:31:40 +08:00
if redType == RedPointType.PersonTrail then
2021-03-01 18:35:35 +08:00
if this.fourMonsterData[1] and this.fourMonsterData[1].openState > 0 then
if this.fourMonsterData[1].freeTime > 0 then
return true
end
end
return this.CheckHelpFightRedPoint(RedPointType.PersonTrailHelp)
elseif redType == RedPointType.BuddishTrail then
if this.fourMonsterData[2] and this.fourMonsterData[2].openState > 0 then
if this.fourMonsterData[2].freeTime > 0 then
return true
end
end
return this.CheckHelpFightRedPoint(RedPointType.BuddishTrailHelp)
elseif redType == RedPointType.DemonTrail then
2021-03-10 17:31:40 +08:00
if this.fourMonsterData[3] and this.fourMonsterData[3].openState > 0 then
2021-03-01 18:35:35 +08:00
if this.fourMonsterData[3].freeTime > 0 then
return true
end
end
return this.CheckHelpFightRedPoint(RedPointType.DemonTrailHelp)
elseif redType == RedPointType.TaoistTrail then
if this.fourMonsterData[4] and this.fourMonsterData[4].openState > 0 then
if this.fourMonsterData[4].freeTime > 0 then
return true
end
end
return this.CheckHelpFightRedPoint(RedPointType.TaoistTrailHelp)
end
return false
2021-01-04 11:39:58 +08:00
end
2021-03-01 18:35:35 +08:00
function this.CheckHelpFightRedPoint(redType)
if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.FourElementTrail) then
return false
end
if redType == RedPointType.PersonTrailHelp then
2021-03-10 17:31:40 +08:00
local heros = HeroManager.GetHeroDataByProperty(1,0)
if not heros or #heros < 1 then
return false
end
if this.fourMonsterData[1] and this.fourMonsterData[1].openState > 0 then
2021-03-01 18:35:35 +08:00
if not this.GetMyHelpHero(1) then
return true
end
end
return false
elseif redType == RedPointType.BuddishTrailHelp then
2021-03-10 17:31:40 +08:00
local heros = HeroManager.GetHeroDataByProperty(2,0)
if not heros or #heros < 1 then
return false
end
2021-03-01 18:35:35 +08:00
if this.fourMonsterData[2] and this.fourMonsterData[2].openState > 0 then
if not this.GetMyHelpHero(2) then
return true
end
end
return false
2021-09-01 14:17:21 +08:00
elseif redType == RedPointType.DemonTrailHelp then
2021-03-10 17:31:40 +08:00
local heros = HeroManager.GetHeroDataByProperty(3,0)
if not heros or #heros < 1 then
return false
end
2021-03-01 18:35:35 +08:00
if this.fourMonsterData[3] and this.fourMonsterData[3].openState > 0 then
if not this.GetMyHelpHero(3) then
return true
end
end
return false
elseif redType == RedPointType.TaoistTrailHelp then
2021-03-10 17:31:40 +08:00
local heros = HeroManager.GetHeroDataByProperty(4,0)
if not heros or #heros < 1 then
return false
end
2021-03-01 18:35:35 +08:00
if this.fourMonsterData[4] and this.fourMonsterData[4].openState > 0 then
if not this.GetMyHelpHero(4) then
return true
end
end
return false
end
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
2021-01-04 11:39:58 +08:00
end
2020-12-21 09:51:08 +08:00
----------------------------------------------------------------------四灵试炼------------------------------------------------------------------
2020-05-09 13:31:21 +08:00
-- 返回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()
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
-- 0 已经领取1 可领取2不能领取·
function this.GetTrialRewardState(id)
if id < this.monsterWave then
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-05-26 14:59:25 +08:00
data.info = string.format("通过心魔试炼第%s层",v.Id)
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
2021-05-25 14:51:26 +08:00
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()
2021-05-26 20:21:55 +08:00
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.MONSTER_COMING) then
return this.GetCanBattleCount() > 0
else
return false
end
2021-05-26 11:48:44 +08:00
end
2021-05-25 14:51:26 +08:00
2020-06-23 18:36:24 +08:00
return this