From 5f7cca6351661d392743e950a5655fbac8ff9d20 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Thu, 11 May 2023 15:31:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E4=B9=B1=E6=A3=8B=E7=9B=98=E7=9A=84?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 2 + .../battle/controller/battle_controller.lua | 84 ++++++++++--------- .../skill/battle_board_skill_handle.lua | 10 +++ 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 1f660f5d..f2a3fd8f 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -686,12 +686,14 @@ BattleConst.SKILL_TYPE = { ELIMINATION_GRID_AND_ELEMENT = 4, CHANGE_ALL_ELEMENT_TYPE = 5, RANDOM_KILL_SKILL_GRID = 6, + SHUFFLE_BOARD = 7, } BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = { [BattleConst.SKILL_TYPE.RELEASE_GRID_TYPE] = true, [BattleConst.SKILL_TYPE.CHANGE_ALL_ELEMENT_TYPE] = true, [BattleConst.SKILL_TYPE.RANDOM_KILL_SKILL_GRID] = true, + [BattleConst.SKILL_TYPE.SHUFFLE_BOARD] = true, } BattleConst.SKILL_METHOD_TYPE = { diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 37fb1d38..c0d490f9 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -469,43 +469,9 @@ function BattleController:enterElimination(needDelay) -- 检查棋盘 local find, pathList = self:findAttention() if not find then -- 如果没找到,就要打乱棋盘 - local changeInfo = self:shuffleBoard() - if changeInfo then - self.battleData:setGridEntitiesPosId(changeInfo) - self.battleUI:shuffleBoard(changeInfo, function() - self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION - end) - else - local resetList = {} - for posId, entity in pairs(self.battleData:getGridEnties()) do - if entity:isEmptyIdle() then - table.insert(resetList, posId) - end - end - local resetInfo = self:resetGrids(resetList) - if not resetInfo then - if EDITOR_MODE then - Logger.logHighlight("----- 处于无法消除状态 -----") - end - self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION - else - if self.resetGridSid then - ModuleManager.BattleManager:unscheduleGlobal(self.resetGridSid) - self.resetGridSid = nil - end - - self.resetGridSid = ModuleManager.BattleManager:performWithDelayGlobal(function() - local count = 1 - for posId, info in pairs(resetInfo) do - self.battleData:setGridInfo(posId, info) - self.battleUI:playChangeElementSfx(posId, count) - count = count + 1 - end - self.resetGridSid = nil - self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION - end, 0.5) - end - end + self:shuffleBoard(function() + self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION + end) else self.attentionList = pathList -- ModuleManager.BattleManager:performWithDelayGlobal(function() @@ -1797,7 +1763,49 @@ function BattleController:showAttention() end, 2) end -function BattleController:shuffleBoard() +function BattleController:shuffleBoard(callback) + local changeInfo = self:getShuffleBoardInfo() + if changeInfo then + self.battleData:setGridEntitiesPosId(changeInfo) + self.battleUI:shuffleBoard(changeInfo, callback) + else + local resetList = {} + for posId, entity in pairs(self.battleData:getGridEnties()) do + if entity:isEmptyIdle() then + table.insert(resetList, posId) + end + end + local resetInfo = self:resetGrids(resetList) + if not resetInfo then + if EDITOR_MODE then + Logger.logHighlight("----- 处于无法消除状态 -----") + end + if callback then + callback() + end + else + if self.resetGridSid then + ModuleManager.BattleManager:unscheduleGlobal(self.resetGridSid) + self.resetGridSid = nil + end + + self.resetGridSid = ModuleManager.BattleManager:performWithDelayGlobal(function() + local count = 1 + for posId, info in pairs(resetInfo) do + self.battleData:setGridInfo(posId, info) + self.battleUI:playChangeElementSfx(posId, count) + count = count + 1 + end + self.resetGridSid = nil + if callback then + callback() + end + end, 0.5) + end + end +end + +function BattleController:getShuffleBoardInfo() local posList = {} local gridEntityList = {} local anySkillList = {} diff --git a/lua/app/module/battle/skill/battle_board_skill_handle.lua b/lua/app/module/battle/skill/battle_board_skill_handle.lua index c45f9734..4969b4d7 100644 --- a/lua/app/module/battle/skill/battle_board_skill_handle.lua +++ b/lua/app/module/battle/skill/battle_board_skill_handle.lua @@ -137,6 +137,15 @@ local function _takeRandomKillSkillGrid(atkUnitComp, skillEntity, battleControll battleController:killGrids(list) end +local function _takeShuffleBoard(atkUnitComp, skillEntity, battleController) + local battleData = battleController.battleData + if not battleData or not battleData:getGridEnties() then + return + end + + battleController:shuffleBoard() +end + BattleBoardSkillHandle._activeBoardSkill = { [SKILL_TYPE.ELIMINATION] = _takeElimination, [SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround, @@ -147,6 +156,7 @@ BattleBoardSkillHandle._activeAttackOverSkill = { [SKILL_TYPE.RELEASE_GRID_TYPE] = _taleReleaseGridType, [SKILL_TYPE.CHANGE_ALL_ELEMENT_TYPE] = _takeChangeAllElementType, [SKILL_TYPE.RANDOM_KILL_SKILL_GRID] = _takeRandomKillSkillGrid, + [SKILL_TYPE.SHUFFLE_BOARD] = _takeShuffleBoard, } function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, sequenceEntities, battleController)