From eb2872b7ee2dc6457995d71fc4acb0f1106494d3 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Sat, 3 Jun 2023 19:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=88=98=E6=96=97=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/controller/battle_controller.lua | 37 +++++++++++++++---- .../skill/battle_grid_effect_handle.lua | 5 +-- lua/app/ui/battle/battle_ui.lua | 14 ++++--- lua/app/userdata/battle/battle_data.lua | 12 +++++- .../userdata/battle/battle_grid_entity.lua | 18 ++++++--- 5 files changed, 62 insertions(+), 24 deletions(-) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index fd81b6a9..1a00b015 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -264,6 +264,7 @@ function BattleController:init(params) self.waveRoundCount = {} self.lastRoundBreakedGridType = {} self.waitingFillCount = 0 + self.needWaitingBoardOver = nil self.chapterId = self:getChapterId() self.waveIndex = 0 @@ -530,6 +531,7 @@ function BattleController:enterNextWave() self.battleUI:refreshWave(self.waveIndex) end if self.waveIndex == 1 then -- 第一波 + self.needWaitingBoardOver = true self:generateBoard(true) else -- 上报关卡结束 @@ -541,10 +543,13 @@ function BattleController:enterNextWave() self.isBossWave = self.defTeam:getMainUnit().unitEntity:getIsBoss() self:postFightStart() - self:enterRoundBegin() + if not self.needWaitingBoardOver then + self:enterRoundBegin() + end end function BattleController:enterRoundBegin() + self.needWaitingBoardOver = nil self.waveRoundCount[self.waveIndex] = (self.waveRoundCount[self.waveIndex] or 0) + 1 self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_BEGIN self:takeGridEffect() @@ -1036,7 +1041,7 @@ function BattleController:calculateCurElimination(onlyCheck) local randomPosList, influenceElementTypeMap for i, info in ipairs(self.aniSequence) do - if info.isSkill then + if info.isSkill and skillEntity then randomPosList, influenceElementTypeMap = self:dealSkillElement(info.timeIdx + skillTime, self.breakedMap, self.sequenceMap, self.aniSequence, self.boomGridIds, onlyCheck) local aniUnit = self.aniSequence[i] if not BattleConst.NO_EFFECT_GRID_SKILL_TYPE[skillEntity:getSkillType()] then @@ -1334,15 +1339,18 @@ end function BattleController:generateBoard(isFirst) local boardList, _, mysteryBoxIndexMap = self:getInitBoard() if self.curBoardIndex and self.curBoardIndex >= #boardList then + self.needWaitingBoardOver = false return end if not self.battleUI then + self.needWaitingBoardOver = false return end self.curBoardIndex = (self.curBoardIndex or 0) + 1 if not boardList[self.curBoardIndex] then -- 容错 + self.needWaitingBoardOver = false return end local board = boardList[self.curBoardIndex].board @@ -1352,7 +1360,9 @@ function BattleController:generateBoard(isFirst) end self.battleUI:switchBoard(function() self.battleData:refreshBoard(board, self:getBlockIcon()) - self.battleUI:initGridCell() + self.battleUI:initGridCell(function() + self.needWaitingBoardOver = false + end) end, function() -- self:enterRoundBegin() end, isFirst) @@ -1389,11 +1399,21 @@ function BattleController:popBoardCacheSkill(callback) if self.popSkillPosIdList[1] then self.popNewSkillId[index] = info self.popNewSkillId[index].posId = table.remove(self.popSkillPosIdList) + self:setGridSkillId(self.popNewSkillId[index].posId, info.skillId, true) else break end end - self.battleUI:cacheSkillAni(self.popNewSkillId, true, callback) + + self.battleUI:cacheSkillAni(self.popNewSkillId, true, function() + for index, info in ipairs(self.popNewSkillId) do + self.battleData:setGridDirty(info.posId) + end + + if callback then + callback() + end + end) else if callback then callback() @@ -1436,13 +1456,13 @@ function BattleController:generateSkill(callback) end) end -function BattleController:setGridSkillId(posId, skillId) +function BattleController:setGridSkillId(posId, skillId, noDirty) local entity = self.battleData:getGridEntity(posId) if entity then - entity:setSkilId(skillId) + entity:setSkilId(skillId, noDirty) local skillEntity = self.battleData:getSkillEntityBySkillId(skillId) if skillEntity and entity:getElementType() ~= skillEntity:getPosition() then - entity:setElementType(skillEntity:getPosition()) + entity:setElementType(skillEntity:getPosition(), noDirty) end end end @@ -2498,6 +2518,9 @@ function BattleController:_tick(dt) if self.isPause then return end + if self.needWaitingBoardOver == false then + self:enterRoundBegin() + end if self.waitingFillCount <= 0 and self.isWaitingFill and self.isRoundBeginCheck then self:fillBoard(self.isRoundBeginCheck) end diff --git a/lua/app/module/battle/skill/battle_grid_effect_handle.lua b/lua/app/module/battle/skill/battle_grid_effect_handle.lua index 6e8c0b2e..189fc3fd 100644 --- a/lua/app/module/battle/skill/battle_grid_effect_handle.lua +++ b/lua/app/module/battle/skill/battle_grid_effect_handle.lua @@ -64,12 +64,11 @@ local function _crossSpreadNotBreak(entity, gridEntities, battleController, only for _, posId in ipairs(tempList) do local gridEntity = gridEntities[posId] if gridEntity:isEmptyIdle() then + battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY, true) if battleController.battleUI and entity:getEffectSfx() then battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function() - battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY) + battleController.battleData:setGridDirty(posId) end) - else - battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY) end succ = true break diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 27265906..88408fee 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -778,7 +778,8 @@ function BattleUI:shakeScreen(shakeType, duration) self.shakeTween.timeScale = DataManager.BattleData:getTimeScale() end -function BattleUI:initGridCell() +function BattleUI:initGridCell(callback) + self.onInitGridCellOverCallback = callback if self.root.gridCells then self.gridCells = self.root.gridCells self.gridInitOver = true @@ -831,6 +832,12 @@ function BattleUI:onInitGridCellOver() end end + local callback = self.onInitGridCellOverCallback + self.onInitGridCellOverCallback = nil + if callback then + callback() + end + ---- 检查引导 ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.START_TUTORIAL) end @@ -1551,11 +1558,6 @@ function BattleUI:doCachePopAni(skillInfo, callback) end self.cacheSkillAniSeq:AppendCallback(function() - for index, info in ipairs(skillInfo) do - if self.battleController then - self.battleController:setGridSkillId(info.posId, info.skillId) - end - end self.boardCacheNode:setVisible(false) self:enableUITouch() if callback then diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 9a8b8408..e5dbd3ac 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -334,15 +334,23 @@ function BattleData:setInfoBySnapshop(posId, snapInfo) entity:setInfoBySnapshop(snapInfo) end -function BattleData:setGridType(posId, gridType) +function BattleData:setGridType(posId, gridType, noDirty) local entity = self.gridEntities[posId] if not entity then return end - entity:setGridType(gridType) + entity:setGridType(gridType, noDirty) entity:determineIdleStatus() end +function BattleData:setGridDirty(posId) + local entity = self.gridEntities[posId] + if not entity then + return + end + entity:setDirty() +end + function BattleData:lockAllSkillGrid(lock) if not self.gridEntities then return diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index da58cc07..34fa1c3b 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -191,20 +191,24 @@ function BattleGridEntity:clearPath() self.pathList = {} end -function BattleGridEntity:setGridType(gridType) +function BattleGridEntity:setGridType(gridType, noDirty) if self.gridType ~= gridType then self.gridType = gridType self.breakCount = 0 - self:setDirty() + if not noDirty then + self:setDirty() + end end end -function BattleGridEntity:setElementType(elementType) +function BattleGridEntity:setElementType(elementType, noDirty) self.elementType = elementType if DataManager.BattleData:getCacheLockedElement(self.elementType) then self:setGridType(BattleConst.GRID_TYPE.LOCK) end - self:setDirty() + if not noDirty then + self:setDirty() + end end function BattleGridEntity:getSkillId() @@ -214,10 +218,12 @@ function BattleGridEntity:getSkillId() return self.skillId end -function BattleGridEntity:setSkilId(skillId) +function BattleGridEntity:setSkilId(skillId, noDirty) self.skillId = skillId self.linkSkillCount = 0 - self:setDirty() + if not noDirty then + self:setDirty() + end end function BattleGridEntity:canChangeInfo()