修改一下填充逻辑

This commit is contained in:
xiekaidong 2023-04-12 10:24:06 +08:00
parent ce32bb29f6
commit e1e2573d23

View File

@ -371,16 +371,36 @@ function BattleController:fillBoard()
local pathMap = {} local pathMap = {}
local columnCount = {} local columnCount = {}
local gridMap = {}
for c = 1, BattleConst.COLUMN_COUNT do for c = 1, BattleConst.COLUMN_COUNT do
for r = BattleConst.ROW_COUNT, 1, -1 do for r = BattleConst.ROW_COUNT, 1, -1 do
local posId = ModuleManager.BattleManager:getPosId(r, c) local posId = ModuleManager.BattleManager:getPosId(r, c)
local entity = DataManager.BattleData:getGridEntity(posId) local entity = DataManager.BattleData:getGridEntity(posId)
if entity:getIsIdle() then if entity:getIsIdle() then
self:fillThisPos(posId, columnCount) self:fillThisPos(posId, columnCount, gridMap)
end end
end 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 c = 1, BattleConst.COLUMN_COUNT do
for r = BattleConst.ROW_COUNT, 1, -1 do for r = BattleConst.ROW_COUNT, 1, -1 do
local posId = ModuleManager.BattleManager:getPosId(r, c) local posId = ModuleManager.BattleManager:getPosId(r, c)
@ -566,7 +586,7 @@ function BattleController:getSkillElementList(elementType, count, useAlternate)
end end
---- 从一个点直接遍历所有相关的路径 ---- 从一个点直接遍历所有相关的路径
function BattleController:fillThisPos(posId, columnCount) function BattleController:fillThisPos(posId, columnCount, gridMap)
local entity = DataManager.BattleData:getGridEntity(posId) local entity = DataManager.BattleData:getGridEntity(posId)
if not entity or not entity:getIsIdle() then if not entity or not entity:getIsIdle() then
return return
@ -598,7 +618,10 @@ function BattleController:fillThisPos(posId, columnCount)
fallEntity:addPath({x = curPos.x, y = curPos.y}) fallEntity:addPath({x = curPos.x, y = curPos.y})
DataManager.BattleData:exchangeGridEntities(posId, fallPosId) 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 else
for index, fallPosId in ipairs(list) do for index, fallPosId in ipairs(list) do
local fallEntity = DataManager.BattleData:getGridEntity(fallPosId) local fallEntity = DataManager.BattleData:getGridEntity(fallPosId)
@ -608,7 +631,7 @@ function BattleController:fillThisPos(posId, columnCount)
if fallEntity then if fallEntity then
if not fallEntity:isCantFallType() then if not fallEntity:isCantFallType() then
if fallEntity:getIsIdle() then if fallEntity:getIsIdle() then
self:fillThisPos(fallPosId, columnCount) self:fillThisPos(fallPosId, columnCount, gridMap)
end end
fallEntity = DataManager.BattleData:getGridEntity(fallPosId) fallEntity = DataManager.BattleData:getGridEntity(fallPosId)
if not fallEntity:getIsIdle() then if not fallEntity:getIsIdle() then
@ -621,7 +644,7 @@ function BattleController:fillThisPos(posId, columnCount)
fallEntity:addPath({x = curPos.x, y = curPos.y}) fallEntity:addPath({x = curPos.x, y = curPos.y})
DataManager.BattleData:exchangeGridEntities(posId, fallPosId) DataManager.BattleData:exchangeGridEntities(posId, fallPosId)
self:fillThisPos(fallPosId, columnCount) self:fillThisPos(fallPosId, columnCount, gridMap)
return return
end end
end end
@ -768,7 +791,7 @@ function BattleController:addHeroAttr(attrName, value)
-- -- body -- -- body
-- elseif attrName == then -- elseif attrName == then
-- -- body -- -- body
-- elseif attrName == then -- elseif attrName == then'
-- -- body -- -- body
-- elseif attrName == then -- elseif attrName == then
-- -- body -- -- body