From e1e2573d2361330a00ac84dffbb1c768ea1ab5e4 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 12 Apr 2023 10:24:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B=E5=A1=AB?= =?UTF-8?q?=E5=85=85=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 | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index dfc731c0..e073b737 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -371,16 +371,36 @@ function BattleController:fillBoard() local pathMap = {} local columnCount = {} + local gridMap = {} for c = 1, BattleConst.COLUMN_COUNT do for r = BattleConst.ROW_COUNT, 1, -1 do local posId = ModuleManager.BattleManager:getPosId(r, c) local entity = DataManager.BattleData:getGridEntity(posId) if entity:getIsIdle() then - self:fillThisPos(posId, columnCount) + self:fillThisPos(posId, columnCount, gridMap) end end end + while true do + local find = false + for c = 1, BattleConst.COLUMN_COUNT do + local list = gridMap[c] + if list and list[1] then -- 此列有需要填充的元素 + local entity = table.remove(list, 1) + if entity then + DataManager.BattleData:setGridInfo(entity:getPosId(), self:getRandomGridInfo()) + end + find = true + end + end + + if not find then + break + end + end + + for c = 1, BattleConst.COLUMN_COUNT do for r = BattleConst.ROW_COUNT, 1, -1 do local posId = ModuleManager.BattleManager:getPosId(r, c) @@ -566,7 +586,7 @@ function BattleController:getSkillElementList(elementType, count, useAlternate) end ---- 从一个点直接遍历所有相关的路径 -function BattleController:fillThisPos(posId, columnCount) +function BattleController:fillThisPos(posId, columnCount, gridMap) local entity = DataManager.BattleData:getGridEntity(posId) if not entity or not entity:getIsIdle() then return @@ -598,7 +618,10 @@ function BattleController:fillThisPos(posId, columnCount) fallEntity:addPath({x = curPos.x, y = curPos.y}) DataManager.BattleData:exchangeGridEntities(posId, fallPosId) - DataManager.BattleData:setGridInfo(posId, self:getRandomGridInfo()) + if not gridMap[c] then + gridMap[c] = {} + end + table.insert(gridMap[c], fallEntity) else for index, fallPosId in ipairs(list) do local fallEntity = DataManager.BattleData:getGridEntity(fallPosId) @@ -608,7 +631,7 @@ function BattleController:fillThisPos(posId, columnCount) if fallEntity then if not fallEntity:isCantFallType() then if fallEntity:getIsIdle() then - self:fillThisPos(fallPosId, columnCount) + self:fillThisPos(fallPosId, columnCount, gridMap) end fallEntity = DataManager.BattleData:getGridEntity(fallPosId) if not fallEntity:getIsIdle() then @@ -621,7 +644,7 @@ function BattleController:fillThisPos(posId, columnCount) fallEntity:addPath({x = curPos.x, y = curPos.y}) DataManager.BattleData:exchangeGridEntities(posId, fallPosId) - self:fillThisPos(fallPosId, columnCount) + self:fillThisPos(fallPosId, columnCount, gridMap) return end end @@ -768,7 +791,7 @@ function BattleController:addHeroAttr(attrName, value) -- -- body -- elseif attrName == then -- -- body - -- elseif attrName == then + -- elseif attrName == then' -- -- body -- elseif attrName == then -- -- body