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

137 lines
6.4 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)
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-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为小节点通过
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
singleChapterData.curMaxStarNum = curMaxStarNum--章节总星数
allChapterData[config.Id] = singleChapterData
end
end
end
--后端更新章节信息
function this.UpdataChapterData(msg)
LogYellow("msg.chapter "..#msg.chapter)
if msg then
for i = 1, #msg.chapter do
local singleHardStageChapter = allChapterData[msg.chapter[i].chapterId]
2021-05-11 20:20:38 +08:00
LogYellow("msg.chapter[i].chapterId "..msg.chapter[i].chapterId.." "..msg.chapter[i].stars.." node num "..#msg.chapter[i].node.." reward num "..#msg.chapter[i].reward)
2021-05-11 15:12:37 +08:00
singleHardStageChapter.chapterId = msg.chapter[i].chapterId
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为小节点通过
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-11 20:20:38 +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
allChapterData[msg.chapter[i].chapterId] = singleHardStageChapter
end
end
end
function this.GetChapterData(allChapterId)
if allChapterId and allChapterId > 0 then
return allChapterData[allChapterId]
else
return allChapterData
end
end
function this.SetCurChapterId(ChapterId)
curChapterId = ChapterId
end
function this.GetCurChapterId()
return curChapterId
end
function this.SetCurChapterLevelId(ChapterLevelId)
curChapterLevelId = ChapterLevelId
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)
NetManager.HardStageReportRequset(_fightLevelData.config.Chapter, _fightLevelData.nodeId,function (msg)--FIGHT_LEVEL
if msg.player and #msg.player > 0 then
UIManager.OpenPanel(UIName.FightLevelSingleLevelInfoPopup,FIGHTLEVEL_POPUP_TYPE.BackBattle,msg.player)
else
PopupTipPanel.ShowTip("尚无符合条件的回放!")
end
end)
end
2021-05-07 20:24:41 +08:00
--开始战斗
2021-05-11 15:12:37 +08:00
local HardStageFightResponseMsg = {}
function this.FightLevelFightBattle(_fightLevelData, callBack)
2021-05-11 16:58:01 +08:00
NetManager.HardStageFightRequest(_fightLevelData.nodeId, FormationTypeDef.FIGHT_LEVEL,function (msg)--FIGHT_LEVEL
-- LogYellow("ssssssssssssssssssss 9")
2021-05-11 15:12:37 +08:00
HardStageFightResponseMsg = msg
2021-05-11 16:58:01 +08:00
if _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel or _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevel then
local fightData = BattleManager.GetBattleServerData(msg,0)
UIManager.OpenPanel(UIName.BattlePanel, fightData, _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.MainLevel and BATTLE_TYPE.FIGHTLEVEL or BATTLE_TYPE.FIGHT_ASSISTANT_LEVEL, callBack)
elseif _fightLevelData.config.StageType == FIGHTLEVEL_STAGETYPE.AssistantLevelReward then
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
--刷新数据刷新界面
end)
end
end)
2021-05-11 15:12:37 +08:00
end
function this.GetHardStageFightResponseMsg()
return HardStageFightResponseMsg
2021-05-07 20:24:41 +08:00
end
return this