From bea9daf0bcadb69aa77113c365a03ab1e6849817 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Thu, 11 May 2023 16:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E6=B6=88=E7=81=ADx=E8=A1=8C?= =?UTF-8?q?=E5=88=97=E7=A9=BA=E9=97=B2=E5=85=83=E7=B4=A0=E6=8A=80=E8=83=BD?= =?UTF-8?q?=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 | 16 ++++++ .../skill/battle_board_skill_handle.lua | 56 +++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index f2a3fd8f..44179db1 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -687,6 +687,7 @@ BattleConst.SKILL_TYPE = { CHANGE_ALL_ELEMENT_TYPE = 5, RANDOM_KILL_SKILL_GRID = 6, SHUFFLE_BOARD = 7, + RANDOM_KILL_ROW_OR_COLUMN = 8, } BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = { @@ -694,6 +695,7 @@ BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = { [BattleConst.SKILL_TYPE.CHANGE_ALL_ELEMENT_TYPE] = true, [BattleConst.SKILL_TYPE.RANDOM_KILL_SKILL_GRID] = true, [BattleConst.SKILL_TYPE.SHUFFLE_BOARD] = true, + [BattleConst.SKILL_TYPE.RANDOM_KILL_ROW_OR_COLUMN] = 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 c0d490f9..9114778d 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -1711,6 +1711,22 @@ function BattleController:killGrids(posIdList) self.battleUI:removeGridOutOfScreen(posIdList) end +function BattleController:killRowOrColumn(infoList) + local map = {} + for _, info in ipairs(infoList) do + if info.posList then + for i, posId in ipairs(info.posList) do + if not map[posId] then + map[posId] = true + local entity = DataManager.BattleData:getGridEntity(posId) + entity:setIsIdle(true) + end + end + self.battleUI:removeGridOutOfScreen(info.posList) + end + end +end + function BattleController:addHeroAttr(attrName, value) if not self.battleData or not self.battleData.atkTeam then return 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 4969b4d7..f7f03b16 100644 --- a/lua/app/module/battle/skill/battle_board_skill_handle.lua +++ b/lua/app/module/battle/skill/battle_board_skill_handle.lua @@ -146,6 +146,61 @@ local function _takeShuffleBoard(atkUnitComp, skillEntity, battleController) battleController:shuffleBoard() end +local function _takeRandomKillRowOrColumn(atkUnitComp, skillEntity, battleController) + local battleData = battleController.battleData + if not battleData or not battleData:getGridEnties() or not skillEntity:getEliminateSkillParameter() then + return + end + + local count = skillEntity:getEliminateSkillParameter()[1] + if count <= 0 then + return + end + + local listCount = 0 + local list = {} + local rowMap = {} + local columnMap = {} + for posId, entity in pairs(battleData:getGridEnties()) do + if entity:isEmptyIdle() then + local rc = ModuleManager.BattleManager:getPosRC(posId) + local r = rc.r + local c = rc.c + if not rowMap[r] then + table.insert(list, {r = r}) + listCount = listCount + 1 + rowMap[r] = {} + end + if not columnMap[c] then + table.insert(list, {c = c}) + listCount = listCount + 1 + columnMap[c] = {} + end + table.insert(rowMap[r], posId) + table.insert(columnMap[c], posId) + end + end + + local infoList = {} + for i = 1, count do + if not list[1] then + break + end + local info = table.remove(list, math.random(1, listCount)) + listCount = listCount - 1 + if info.r then + info.posList = rowMap[info.r] + elseif info.c then + info.posList = columnMap[info.c] + end + if info.posList then + table.insert(infoList, info) + end + end + + battleController:killRowOrColumn(infoList) +end + BattleBoardSkillHandle._activeBoardSkill = { [SKILL_TYPE.ELIMINATION] = _takeElimination, [SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround, @@ -157,6 +212,7 @@ BattleBoardSkillHandle._activeAttackOverSkill = { [SKILL_TYPE.CHANGE_ALL_ELEMENT_TYPE] = _takeChangeAllElementType, [SKILL_TYPE.RANDOM_KILL_SKILL_GRID] = _takeRandomKillSkillGrid, [SKILL_TYPE.SHUFFLE_BOARD] = _takeShuffleBoard, + [SKILL_TYPE.RANDOM_KILL_ROW_OR_COLUMN] = _takeRandomKillRowOrColumn, } function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, sequenceEntities, battleController)