From efa763ef2c0566d5ba89ead571b16f919067a60e Mon Sep 17 00:00:00 2001 From: puxuan <413323644@qq.com> Date: Mon, 10 Nov 2025 16:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/battle_base_controller.lua | 22 ++ .../controller/battle_controller_stage.lua | 211 +++++++++++------- 2 files changed, 154 insertions(+), 79 deletions(-) diff --git a/lua/app/module/battle/controller/battle_base_controller.lua b/lua/app/module/battle/controller/battle_base_controller.lua index 01b8a8e4..d79f4ce9 100644 --- a/lua/app/module/battle/controller/battle_base_controller.lua +++ b/lua/app/module/battle/controller/battle_base_controller.lua @@ -83,6 +83,15 @@ function BattleBaseController:getBattleUIPath() return "app/ui/battle/battle_ui" end +function BattleBaseController:setCheckTutorial(tutorial) +end + +function BattleBaseController:checkTutorialBoard() +end + +function BattleBaseController:hideTutorialBoard() +end + ---- 障碍格子图片 function BattleBaseController:getBlockIcon() local chapterInfo = self:getChapterConfig()[self.chapterId] @@ -296,6 +305,7 @@ function BattleBaseController:onDefDead(callback) end function BattleBaseController:onLinkChange() + self:hideTutorialBoard() self.battleUI:hideAllSfxLine() self.linkChangeNeedFalsePosMap = table.clearOrCreate(self.linkChangeNeedFalsePosMap) for posId, entity in pairs(self.battleData:getGridEnties()) do @@ -325,6 +335,11 @@ function BattleBaseController:onLinkChange() end local count = #sequence + if count > 0 then + self:setCheckTutorial(false) + else + self:setCheckTutorial(true) + end for index, info in ipairs(sequence) do local entity = self.battleData:getGridEntity(info.posId) @@ -545,6 +560,8 @@ function BattleBaseController:init(params, snapshot) self.eliminateTotalCount = 0 self.maxLinkCount = 0 self.realTime = 0 + self.tutorialTime = 0 + self.needCheckTutorial = true self.doubleMystery = 0 self.taskProgress = {} self.waveRoundCount = {} @@ -1186,6 +1203,7 @@ function BattleBaseController:enterElimination(needDelay) self.battleUI:hideAllBoardSfxs() + self:setCheckTutorial(true) -- 检查棋盘 local find, pathList = self:findAttention() if not find then -- 如果没找到,就要打乱棋盘 @@ -1408,6 +1426,7 @@ function BattleBaseController:onLinkOver() local sequence = self.battleData:getGridSequence() local count = #sequence if count < self:getMinEliminationCount() then + self:setCheckTutorial(true) return end @@ -3259,8 +3278,10 @@ function BattleBaseController:_tick(dt, originDt) self.waveDurationTime = self.waveDurationTime + originDt self.totalDurationTime = self.totalDurationTime + originDt if self.isPause then + self:hideTutorialBoard() return end + self.tutorialTime = self.tutorialTime + dt if self.needWaitingBoardOver == false then self:enterRoundBegin() end @@ -3282,6 +3303,7 @@ function BattleBaseController:_tick(dt, originDt) self:checkSkillSlowDown(dt) self:tick(dt) BattleBoardTouchHelper:tick(dt) + self:checkTutorialBoard() end function BattleBaseController:adRevive(revive) diff --git a/lua/app/module/battle/controller/battle_controller_stage.lua b/lua/app/module/battle/controller/battle_controller_stage.lua index 941c2532..65d28dc9 100644 --- a/lua/app/module/battle/controller/battle_controller_stage.lua +++ b/lua/app/module/battle/controller/battle_controller_stage.lua @@ -1,5 +1,6 @@ local BattleController = require "app/module/battle/controller/battle_controller" local BattleControllerStage = class("BattleControllerStage", BattleController) +local BoardHeler = require "app/module/battle/helper/board_helper" function BattleControllerStage:canRevive() return true @@ -16,28 +17,28 @@ function BattleControllerStage:canGetDoubleRewards() end function BattleControllerStage:getBoardConfig() - return ConfigManager:getConfig("chapter_board") + return ConfigManager:getConfig("chapter_board") end function BattleControllerStage:getChapterConfig() - return ConfigManager:getConfig("chapter") + return ConfigManager:getConfig("chapter") end function BattleControllerStage:getChapterId() - return DataManager.ChapterData:getChapterId() + return DataManager.ChapterData:getChapterId() end function BattleControllerStage:getInitBoard() - if not self.boradList then - self.boradList = {} - self.fixedRandomGrid = {} - self.mysteryBoxIndexMap = {} + if not self.boradList then + self.boradList = {} + self.fixedRandomGrid = {} + self.mysteryBoxIndexMap = {} - local config = self:getChapterConfig()[self.chapterId] - local boardCfg = self:getBoardConfig() - for idx, boardId in ipairs(config.board) do - local cfg = boardCfg[boardId] - if cfg then + local config = self:getChapterConfig()[self.chapterId] + local boardCfg = self:getBoardConfig() + for idx, boardId in ipairs(config.board) do + local cfg = boardCfg[boardId] + if cfg then local tab = { board = GFunc.getTable(cfg.board), mysteryBoard = GFunc.getTable(cfg.mystery_box_board), @@ -46,92 +47,144 @@ function BattleControllerStage:getInitBoard() if config.mystery_box and config.mystery_box_reward and config.mystery_box[idx] and math.random(1, GConst.BattleConst.DEFAULT_FACTOR) <= config.mystery_box[idx] then self.mysteryBoxIndexMap[idx] = GFunc.randomDrop(config.mystery_box_reward) end - table.insert(self.boradList, tab) - table.insert(self.fixedRandomGrid, GFunc.getTable(cfg.control_element)) - end - end + table.insert(self.boradList, tab) + table.insert(self.fixedRandomGrid, GFunc.getTable(cfg.control_element)) + end + end - -- if config.mystery_box and config.mystery_box_reward then - -- for i, index in ipairs(config.mystery_box) do - -- if not DataManager.ChapterData:getChapterMysteryBoxIsGot(self.chapterId, i) then - -- self.mysteryBoxIndexMap[index] = config.mystery_box_reward[i] - -- end - -- end - -- end - end + -- if config.mystery_box and config.mystery_box_reward then + -- for i, index in ipairs(config.mystery_box) do + -- if not DataManager.ChapterData:getChapterMysteryBoxIsGot(self.chapterId, i) then + -- self.mysteryBoxIndexMap[index] = config.mystery_box_reward[i] + -- end + -- end + -- end + end - return self.boradList, self.fixedRandomGrid, self.mysteryBoxIndexMap + return self.boradList, self.fixedRandomGrid, self.mysteryBoxIndexMap end function BattleControllerStage:getFixedRogueSkill() - if not self.fixedRogueSkill then - local config = ConfigManager:getConfig("chapter")[self.chapterId] - if not DataManager.ChapterData:getChapterPassed(self.chapterId) and config.involved_skill then - self.fixedRogueSkill = GFunc.getTable(config.involved_skill) - else - self.fixedRogueSkill = {} - end - end + if not self.fixedRogueSkill then + local config = ConfigManager:getConfig("chapter")[self.chapterId] + if not DataManager.ChapterData:getChapterPassed(self.chapterId) and config.involved_skill then + self.fixedRogueSkill = GFunc.getTable(config.involved_skill) + else + self.fixedRogueSkill = {} + end + end - return self.fixedRogueSkill + return self.fixedRogueSkill end function BattleControllerStage:controllBattleEnd() - self.combatReport = { - battleType = GConst.BattleConst.BATTLE_TYPE.STAGE, - wave = self:getWaveIndex(), - victory = self.victory, - } - local atkReport = {} - local teamEntity = self.battleData:getAtkTeam() - local members = teamEntity:getAllMembers() - for k, v in pairs(members) do - local report = { - heroId = v:getId(), - dmg = v:getDamageCount(), - } - table.insert(atkReport, report) - end - self.combatReport.atkReport = atkReport - if not self.victory then - self.combatReport.wave = self.combatReport.wave - 1 - end - BIReport:postFightHeroReport(self.combatReport.battleType, atkReport) - ModuleManager.ChapterManager:endFight(self.chapterId, self.combatReport, self.gotMysteryBoxIndexs, self.taskProgress, self.doubleMystery) + self.combatReport = { + battleType = GConst.BattleConst.BATTLE_TYPE.STAGE, + wave = self:getWaveIndex(), + victory = self.victory, + } + local atkReport = {} + local teamEntity = self.battleData:getAtkTeam() + local members = teamEntity:getAllMembers() + for k, v in pairs(members) do + local report = { + heroId = v:getId(), + dmg = v:getDamageCount(), + } + table.insert(atkReport, report) + end + self.combatReport.atkReport = atkReport + if not self.victory then + self.combatReport.wave = self.combatReport.wave - 1 + end + BIReport:postFightHeroReport(self.combatReport.battleType, atkReport) + ModuleManager.ChapterManager:endFight(self.chapterId, self.combatReport, self.gotMysteryBoxIndexs, self.taskProgress, self.doubleMystery) end function BattleControllerStage:postWaveOver(atkDead, isQuit) - local deathType = BIReport.FIGHT_DEATH_TYPE.SURVIVE - local waveEndType = BIReport.FIGHT_WAVE_END_TYPE.WIN - if atkDead then - if self.isBossWave then - deathType = BIReport.FIGHT_DEATH_TYPE.BOSS_FAIL - else - deathType = BIReport.FIGHT_DEATH_TYPE.NORMAL_FAIL - end - waveEndType = BIReport.FIGHT_WAVE_END_TYPE.FAIL - end + local deathType = BIReport.FIGHT_DEATH_TYPE.SURVIVE + local waveEndType = BIReport.FIGHT_WAVE_END_TYPE.WIN + if atkDead then + if self.isBossWave then + deathType = BIReport.FIGHT_DEATH_TYPE.BOSS_FAIL + else + deathType = BIReport.FIGHT_DEATH_TYPE.NORMAL_FAIL + end + waveEndType = BIReport.FIGHT_WAVE_END_TYPE.FAIL + end - if isQuit then - waveEndType = BIReport.FIGHT_WAVE_END_TYPE.QUIT - end + if isQuit then + waveEndType = BIReport.FIGHT_WAVE_END_TYPE.QUIT + end - local duration = self.waveDurationTime - local totalTime = self.totalDurationTime - local startTimes = DataManager.ChapterData:getChapterFightCount(self.chapterId) - local isFirstWin = false - if not DataManager.ChapterData:getChapterPassed(self.chapterId) and self.victory then - isFirstWin = true - end + local duration = self.waveDurationTime + local totalTime = self.totalDurationTime + local startTimes = DataManager.ChapterData:getChapterFightCount(self.chapterId) + local isFirstWin = false + if not DataManager.ChapterData:getChapterPassed(self.chapterId) and self.victory then + isFirstWin = true + end - local isFianlStep = self:getWaveIndex() >= self.maxWaveIndex + local isFianlStep = self:getWaveIndex() >= self.maxWaveIndex - BIReport:postFightEnd(GConst.BattleConst.BATTLE_TYPE.STAGE, self.battleData, self.chapterId, self:getWaveIndex(), duration, totalTime, self.eliminateCount, self.eliminateTotalCount, waveEndType, deathType, startTimes, isFirstWin, isFianlStep, self.maxLinkCount) + BIReport:postFightEnd(GConst.BattleConst.BATTLE_TYPE.STAGE, self.battleData, self.chapterId, self:getWaveIndex(), duration, totalTime, self.eliminateCount, self.eliminateTotalCount, waveEndType, deathType, startTimes, isFirstWin, isFianlStep, self.maxLinkCount) end function BattleControllerStage:postFightStart() - local unlockMaxChapter = DataManager.ChapterData:getNewChapterId() - BIReport:postFightBegin(GConst.BattleConst.BATTLE_TYPE.STAGE, self:getWaveIndex(), self.chapterId, unlockMaxChapter, DataManager.ChapterData:getChapterFightCount(self.chapterId)) + local unlockMaxChapter = DataManager.ChapterData:getNewChapterId() + BIReport:postFightBegin(GConst.BattleConst.BATTLE_TYPE.STAGE, self:getWaveIndex(), self.chapterId, unlockMaxChapter, DataManager.ChapterData:getChapterFightCount(self.chapterId)) end +--@region 消除提示 +function BattleControllerStage:getAtkMinRow() + return GConst.BattleConst.COLUMN_COUNT +end + +function BattleControllerStage:setCheckTutorial(tutorial) + self.needCheckTutorial = tutorial +end + +-- showAttention 类似 但是没有调用 不会重复提示 +function BattleControllerStage:checkTutorialBoard() + if not self.needCheckTutorial then + return + end + if DataManager.TutorialData:getIsInTutorial() then + return + end + local time = math.floor(self.tutorialTime) + if time == 0 or time %3 ~= 0 then + return + end + local elementTypeCoefficient = {} + local teamEntity = self.battleData:getAtkTeam() + local members = teamEntity:getAllMembers() + for _, v in pairs(members) do + elementTypeCoefficient[v:getMatchType()] = v:getAtk() + end + local path = BoardHeler:findPvpLinkOptimalSolution(self, 1, self:getAtkMinRow(), elementTypeCoefficient, self:getMinEliminationCount()) + if path and #path >= self:getMinEliminationCount() then + self.tutorialPath = path + for _, posId in ipairs(path) do + local entity = self.battleData:getGridEntity(posId) + if entity and entity:getCell() then + entity:getCell():showAni() + end + end + end +end + +function BattleControllerStage:hideTutorialBoard() + self.tutorialTime = 0 + if self.tutorialPath then + for _, posId in ipairs(self.tutorialPath) do + local entity = self.battleData:getGridEntity(posId) + if entity and entity:getCell() then + entity:getCell():hideAni() + end + end + self.tutorialPath = nil + end +end +--@endregion return BattleControllerStage \ No newline at end of file