miduo_client/Assets/ManagedResources/~Lua/Modules/FightLevel/FightLevelManager.lua

348 lines
16 KiB
Lua
Raw Normal View History

2021-05-07 20:24:41 +08:00
FightLevelManager = {};
local this = FightLevelManager
2021-05-11 15:12:37 +08:00
local HardStageChapter = ConfigManager.GetConfig(ConfigName.HardStageChapter)
local HardStage = ConfigManager.GetConfig(ConfigName.HardStage)
local HardStageReward = ConfigManager.GetConfig(ConfigName.HardStageReward)
2021-05-13 20:30:10 +08:00
local HardStageBuff = ConfigManager.GetConfig(ConfigName.HardStageBuff)
2021-05-11 15:12:37 +08:00
local stateList = {--状态:0-7星级状态8为荣耀三星,0为小节点未通过1为小节点通过
[0] = {0,0,0},--0 为未获得星 1 为 已获得星 二进制
[1] = {0,0,1},
[2] = {0,1,0},
[3] = {0,1,1},
[4] = {1,0,0},
[5] = {1,0,1},
[6] = {1,1,0},
[7] = {1,1,1},
}
local allChapterData = {}--所有章节信息
local curChapterId = 1--当前章节id
local curChapterLevelId = 1--当前章节中小关卡id 打一关前端自己更新一次
2021-05-13 09:56:11 +08:00
local isShowChapterOpenPopup = false--弹出章节开启标志
2021-05-07 20:24:41 +08:00
function this.Initialize()
2021-05-11 15:12:37 +08:00
allChapterData = {}
for index, config in ConfigPairs(HardStageChapter) do
if config then
local singleChapterData = {}
singleChapterData.chapterId = config.Id
singleChapterData.config = config
singleChapterData.state = 0--未开启 1 开启
singleChapterData.stars = 0--章节获得总星数
singleChapterData.HardStageChapter = {}--章节中小关卡信息
local curMaxStarNum = 0
singleChapterData.node = {}
local curChapterAllLevel = ConfigManager.GetAllConfigsDataByKey(ConfigName.HardStage,"Chapter", config.Id)
for j = 1, #curChapterAllLevel do
curMaxStarNum = curMaxStarNum + curChapterAllLevel[j].HighestStar
local HardStageNode = {}
HardStageNode.nodeId = curChapterAllLevel[j].Id
HardStageNode.type = curChapterAllLevel[j].StageType--类型:0.大节点1.小节点
HardStageNode.state = 0--状态:0-7星级状态8为荣耀三星,0为小节点未通过1为小节点通过
2021-05-15 16:16:46 +08:00
HardStageNode.isFirst = false--是否是第一次荣耀
HardStageNode.isPass = false--是否通关
2021-05-11 15:12:37 +08:00
HardStageNode.config = curChapterAllLevel[j]--表
2021-05-11 20:20:38 +08:00
singleChapterData.node[HardStageNode.nodeId] = HardStageNode
2021-05-11 15:12:37 +08:00
end
2021-05-13 22:50:34 +08:00
singleChapterData.reward = {}
2021-05-11 15:12:37 +08:00
singleChapterData.curMaxStarNum = curMaxStarNum--章节总星数
allChapterData[config.Id] = singleChapterData
end
end
end
--后端更新章节信息
2021-05-13 09:56:11 +08:00
function this.UpdataChapterData(msg,_isShowChapterOpenPopup)
2021-05-15 13:49:18 +08:00
local oldChapterId = this.GetCurChapterId()
2021-05-11 15:12:37 +08:00
if msg then
for i = 1, #msg.chapter do
local singleHardStageChapter = allChapterData[msg.chapter[i].chapterId]
2021-07-01 21:07:53 +08:00
-- Log("chapterId:"..msg.chapter[i].chapterId.." stars"..msg.chapter[i].stars.." node"..#msg.chapter[i].node.."reward:"..#msg.chapter[i].reward.." needStars:"..singleHardStageChapter.stars)
2021-05-11 15:12:37 +08:00
singleHardStageChapter.chapterId = msg.chapter[i].chapterId
2021-05-15 13:49:18 +08:00
if singleHardStageChapter.chapterId > oldChapterId and _isShowChapterOpenPopup then
2021-05-13 09:56:11 +08:00
this.SetisShowChapterOpenPopup(true)
end
2021-05-11 15:12:37 +08:00
this.SetCurChapterId(singleHardStageChapter.chapterId)
singleHardStageChapter.stars = msg.chapter[i].stars--章节获得总星数
2021-05-11 20:20:38 +08:00
-- singleHardStageChapter.node = {}
2021-05-11 15:12:37 +08:00
for j = 1, #msg.chapter[i].node do
local HardStageNode = {}
HardStageNode.nodeId = msg.chapter[i].node[j].nodeId
HardStageNode.type = msg.chapter[i].node[j].type--类型:0.大节点1.小节点
HardStageNode.state = msg.chapter[i].node[j].state--状态:0-7星级状态8为荣耀三星,0为小节点未通过1为小节点通过
2021-05-15 16:16:46 +08:00
HardStageNode.isFirst= msg.chapter[i].node[j].isFirst--是否是第一次荣耀
2021-05-18 16:51:43 +08:00
HardStageNode.isPass= msg.chapter[i].node[j].isPass--节点是否通过
2021-05-11 15:12:37 +08:00
HardStageNode.config = HardStage[msg.chapter[i].node[j].nodeId]--表
this.SetCurChapterLevelId(HardStageNode.nodeId)
2021-05-11 20:20:38 +08:00
singleHardStageChapter.node[HardStageNode.nodeId] = HardStageNode
2021-05-11 15:12:37 +08:00
end
2021-05-13 22:50:34 +08:00
singleHardStageChapter.reward = {}--每章宝箱奖励
2021-05-11 15:12:37 +08:00
for k = 1, #msg.chapter[i].reward do
local HardStageChapterReward = {}
HardStageChapterReward.id = msg.chapter[i].reward[k].id
HardStageChapterReward.state = msg.chapter[i].reward[k].state--0.未领取1.已领取
HardStageChapterReward.config = HardStageReward[msg.chapter[i].reward[k].id]--表
table.insert(singleHardStageChapter.reward,HardStageChapterReward)
end
2021-06-10 17:05:51 +08:00
table.sort(singleHardStageChapter.reward, function(a,b) return a.id < b.id end)
2021-05-11 15:12:37 +08:00
allChapterData[msg.chapter[i].chapterId] = singleHardStageChapter
end
2021-05-13 20:30:10 +08:00
CheckRedPointStatus(RedPointType.FightLevel)
2021-05-24 11:21:56 +08:00
PracticeManager.StarNum = FightLevelManager.GetAllChapterStars()
2021-05-11 15:12:37 +08:00
end
end
2021-05-15 16:16:46 +08:00
--获取整个章节信息
2021-05-11 15:12:37 +08:00
function this.GetChapterData(allChapterId)
if allChapterId and allChapterId > 0 then
return allChapterData[allChapterId]
2021-05-14 16:44:40 +08:00
elseif not allChapterId then
2021-05-11 15:12:37 +08:00
return allChapterData
end
end
2021-05-15 16:16:46 +08:00
--获取整个章节中一小关信息
function this.GetChapterLevelData(allChapterId,levelId)
if allChapterId and allChapterId > 0 and levelId and levelId > 0 then
if allChapterData[allChapterId] then
return allChapterData[allChapterId].node[levelId]
end
end
end
2021-05-11 15:12:37 +08:00
function this.SetCurChapterId(ChapterId)
2021-05-29 23:14:16 +08:00
if curChapterId < ChapterId then
curChapterId = ChapterId
end
2021-05-11 15:12:37 +08:00
end
function this.GetCurChapterId()
return curChapterId
end
2021-05-13 09:56:11 +08:00
function this.SetisShowChapterOpenPopup(_isShowChapterOpenPopup)
2021-05-28 10:33:53 +08:00
Log("山河社稷图 是否弹章节开启 "..tostring(_isShowChapterOpenPopup))
2021-05-13 09:56:11 +08:00
isShowChapterOpenPopup = _isShowChapterOpenPopup
end
function this.GetisShowChapterOpenPopup()
return isShowChapterOpenPopup
end
2021-05-11 15:12:37 +08:00
function this.SetCurChapterLevelId(ChapterLevelId)
2021-05-29 23:14:16 +08:00
if curChapterLevelId < ChapterLevelId then
curChapterLevelId = ChapterLevelId
end
2021-05-11 15:12:37 +08:00
end
function this.GetCurChapterLevelId()
return curChapterLevelId
end
function this.GetAllChapterStars()
local allStarNum = 0
for i = 1, #allChapterData do
allStarNum = allStarNum + allChapterData[i].stars
end
return allStarNum
end
function this.GetCurLevelStarState(starNum,index)
return stateList[starNum][index] == 1
2021-05-07 20:24:41 +08:00
end
2021-05-11 20:20:38 +08:00
--请求回放
function this.HardStageReportRequset(_fightLevelData, callBack)
2021-05-13 22:50:34 +08:00
NetManager.HardStageReportRequset( _fightLevelData.nodeId,function (msg)--FIGHT_LEVEL _fightLevelData.config.Chapter,
2021-05-11 20:20:38 +08:00
if msg.player and #msg.player > 0 then
2021-05-22 15:26:30 +08:00
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup,FIGHTLEVEL_POPUP_TYPE.BackBattle,msg.player,_fightLevelData,callBack)
2021-05-11 20:20:38 +08:00
else
PopupTipPanel.ShowTip("尚无符合条件的回放!")
end
end)
end
2021-05-07 20:24:41 +08:00
--开始战斗
2021-05-11 15:12:37 +08:00
local HardStageFightResponseMsg = {}
2021-05-13 20:30:10 +08:00
local curBattlefightLevelData = {}
2021-05-11 15:12:37 +08:00
function this.FightLevelFightBattle(_fightLevelData, callBack)
2021-05-15 16:16:46 +08:00
UIManager.ClosePanel(UIName.FightLevelSingleLevelInfoPopup)
local curFormationTypeDef = FormationTypeDef.FIGHT_LEVEL
if _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel then
curFormationTypeDef = FormationTypeDef.FIGHT_LEVEL
else
curFormationTypeDef = FormationTypeDef.FIGHT_ASSISTANTLEVEL
end
NetManager.HardStageFightRequest(_fightLevelData.nodeId, curFormationTypeDef,function (msg)--FIGHT_LEVEL
2021-07-01 21:07:53 +08:00
-- Log("山河社稷图回复战斗 星级 "..msg.stars.." drop "..#msg.drop.itemlist)
2021-05-11 15:12:37 +08:00
HardStageFightResponseMsg = msg
2021-05-13 20:30:10 +08:00
curBattlefightLevelData = _fightLevelData
2021-05-14 15:03:48 +08:00
if _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel then
2021-05-11 16:58:01 +08:00
local fightData = BattleManager.GetBattleServerData(msg,0)
2021-05-14 15:03:48 +08:00
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.FIGHTLEVEL, callBack)
elseif _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel then
local fightData = BattleManager.GetBattleServerData(msg,0)
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.FIGHT_ASSISTANT_LEVEL, callBack)
2021-05-11 16:58:01 +08:00
elseif _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevelReward then
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
--刷新数据刷新界面
2021-05-14 19:55:28 +08:00
if callBack then
callBack()
callBack = nil
end
2021-05-11 16:58:01 +08:00
end)
end
end)
2021-05-11 15:12:37 +08:00
end
2021-05-13 09:56:11 +08:00
--战斗数据
2021-05-11 15:12:37 +08:00
function this.GetHardStageFightResponseMsg()
return HardStageFightResponseMsg
2021-05-07 20:24:41 +08:00
end
2021-05-13 20:30:10 +08:00
--当前战斗关卡数据
function this.GetcurBattlefightLevelData()
return curBattlefightLevelData
end
--入口红点判断
2021-05-13 09:56:11 +08:00
function this.GetChapterRewardBoxRedPoint()
for i = 1, #allChapterData do
2021-05-14 15:03:48 +08:00
local curChapterIsShowRed = this.GetSingleChapterRewardBoxRedPoint(i)
if curChapterIsShowRed then
2021-05-15 16:16:46 +08:00
-- LogYellow("山河社稷图入口 redpoint true")
2021-05-14 15:03:48 +08:00
return true
end
2021-05-13 20:30:10 +08:00
end
2021-05-15 16:16:46 +08:00
-- LogYellow("山河社稷图入口 redpoint false")
2021-05-13 20:30:10 +08:00
return false
end
--章节入口红点判断
2021-05-14 15:03:48 +08:00
function this.GetSingleChapterRewardBoxRedPoint(chapterId)
2021-05-13 20:30:10 +08:00
if allChapterData[chapterId] and allChapterData[chapterId].stars > 0 then
if allChapterData[chapterId].reward and #allChapterData[chapterId].reward > 0 then
for k = 1, #allChapterData[chapterId].reward do
2021-05-14 15:03:48 +08:00
if allChapterData[chapterId].reward[k].state == 0 and allChapterData[chapterId].stars >= allChapterData[chapterId].reward[k].config.Star then
2021-05-15 16:16:46 +08:00
-- LogYellow("chapterId true redpoint: "..chapterId)
2021-05-13 20:30:10 +08:00
return true
2021-05-13 09:56:11 +08:00
end
end
end
end
2021-05-15 16:16:46 +08:00
-- LogYellow("chapterId false redpoint: "..chapterId)
2021-05-13 09:56:11 +08:00
return false
end
2021-05-13 20:30:10 +08:00
--编队数据判断
function this.GetAllHeroDatas(limitLevel,parameter)
local heros = HeroManager.GetAllHeroDatas(limitLevel)
if parameter and parameter.config and parameter.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel and
HardStageBuff[parameter.config.HardStageBuff] and HardStageBuff[parameter.config.HardStageBuff].Type == 101 then
local Vocation = HardStageBuff[parameter.config.HardStageBuff].Vocation
if Vocation and #Vocation > 0 then
local newHeros = {}
for i = 1, #heros do
for j = 1, #Vocation do
if heros[i].property == Vocation[j] then
table.insert(newHeros,heros[i])
end
end
end
return newHeros
else
return heros
end
else
return heros
end
end
function this.GetHeroDataByProperty(_proId, limitLevel,parameter)
local heros = HeroManager.GetHeroDataByProperty(_proId, limitLevel)
if parameter and parameter.config and parameter.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel and
HardStageBuff[parameter.config.HardStageBuff] and HardStageBuff[parameter.config.HardStageBuff].Type == 101 then
local Vocation = HardStageBuff[parameter.config.HardStageBuff].Vocation
if Vocation and #Vocation > 0 then
local isheros = false
for j = 1, #Vocation do
if _proId == Vocation[j] then
isheros = true
end
end
if isheros then
return heros
else
return {}
end
else
return heros
end
else
return heros
end
end
function this.RrefreshFormation(parameter)
local newFormation = {} -- 编队界面的编队数据
local curTeam = FormationManager.GetFormationByID(FormationTypeDef.FIGHT_ASSISTANTLEVEL)
2021-05-13 20:30:10 +08:00
-- 编队界面的数据
newFormation.teamHeroInfos = {}
newFormation.teamPokemonInfos = {}
newFormation.teamId = FormationTypeDef.FIGHT_ASSISTANTLEVEL
2021-05-13 20:30:10 +08:00
newFormation.teamName = curTeam.teamName
newFormation.teamPokemonInfos = curTeam.teamPokemonInfos
-- 成员数据
if parameter and parameter.config and parameter.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel and HardStageBuff[parameter.config.HardStageBuff] then
for i = 1, #curTeam.teamHeroInfos do
local roleData = curTeam.teamHeroInfos[i]
if HardStageBuff[parameter.config.HardStageBuff].Type == 100 then
if #newFormation.teamHeroInfos < 1 then--只能使用1个神将进入战斗后复制为相同的6个神将
-- 编队界面数据重组
table.insert(newFormation.teamHeroInfos, roleData)
end
elseif HardStageBuff[parameter.config.HardStageBuff].Type == 101 then
if roleData.heroId then
local singleHeroData = HeroManager.GetSingleHeroData(roleData.heroId)
local Vocation = HardStageBuff[parameter.config.HardStageBuff].Vocation
for j = 1, #Vocation do
if singleHeroData and singleHeroData.property == Vocation[j] then--只能上阵人系神将和佛系神将
-- 编队界面数据重组
table.insert(newFormation.teamHeroInfos, roleData)
end
end
end
end
end
if HardStageBuff[parameter.config.HardStageBuff].Type == 100 or HardStageBuff[parameter.config.HardStageBuff].Type == 101 then
FormationManager.formationList[FormationTypeDef.FIGHT_ASSISTANTLEVEL] = newFormation
2021-05-13 20:30:10 +08:00
end
end
end
function this.GetFormationHeroMaxNum(parameter)
if parameter and parameter.config and parameter.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel and HardStageBuff[parameter.config.HardStageBuff] then
if HardStageBuff[parameter.config.HardStageBuff].Type == 100 then --只能使用1个神将进入战斗后复制为相同的6个神将
return 1
end
end
return ActTimeCtrlManager.MaxArmyNum()
end
2021-05-14 15:03:48 +08:00
--领取完章节宝箱数据 前端自己赋值刷新
function this.SetChapterBoxRewardData(_chapterId,_Id,_state)
if allChapterData[_chapterId] then
if allChapterData[_chapterId].reward then
for i = 1, #allChapterData[_chapterId].reward do
if allChapterData[_chapterId].reward[i].id == _Id then
allChapterData[_chapterId].reward[i].state = _state
end
end
end
end
end
2021-07-14 11:33:33 +08:00
--========================= 山河试炼专用 ===============================
2021-07-14 11:36:33 +08:00
function this.GetNextMissionStar()
local data = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.ShanHeShiLian)
local list = {}
local configData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",data.activityId)
for i = 1, #configData do
if configData[i].ActivityId == data.activityId then
if configData[i].Values[1][1] > this.GetAllChapterStars() then
return configData[i].Values[1][1] - this.GetAllChapterStars()
end
end
end
return 0
end
function this.CheckTrialRedPoint()
local data = CommonActPageManager.GetData(ActivityTypeDef.ShanHeShiLian)
for i = 1, #data.rewards do
if data.rewards[i].state == 0 and data.rewards[i].otherData.Values[1][1] <= FightLevelManager.GetAllChapterStars() then
return true
end
end
return false
end
2021-07-14 11:33:33 +08:00
--=====================================================================
2021-05-07 20:24:41 +08:00
return this