填充bug修复

This commit is contained in:
xiekaidong 2023-04-19 21:03:53 +08:00
parent 90070e8798
commit 7afa7f77b5
5 changed files with 57 additions and 40 deletions

View File

@ -264,10 +264,11 @@ BattleConst.GRID_TYPE_ICON = {
[BattleConst.GRID_TYPE.ICE] = "ice", [BattleConst.GRID_TYPE.ICE] = "ice",
} }
---- 周围格子消除一次后会变成什么格子 ---- 周围格子或自己消除一次后会变成什么格子
BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = { BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = {
[BattleConst.GRID_TYPE.SNOW_BOX] = {BattleConst.GRID_TYPE.EMPTY}, [BattleConst.GRID_TYPE.SNOW_BOX] = {BattleConst.GRID_TYPE.EMPTY},
[BattleConst.GRID_TYPE.SOLID_SNOW] = {BattleConst.GRID_TYPE.SNOW_BOX}, [BattleConst.GRID_TYPE.SOLID_SNOW] = {BattleConst.GRID_TYPE.SNOW_BOX},
[BattleConst.GRID_TYPE.VINES] = {BattleConst.GRID_TYPE.EMPTY},
[BattleConst.GRID_TYPE.ICE] = {BattleConst.GRID_TYPE.EMPTY}, [BattleConst.GRID_TYPE.ICE] = {BattleConst.GRID_TYPE.EMPTY},
} }
@ -288,6 +289,7 @@ BattleConst.CANT_LINK_GRID_TYPE = {
---- 元素类型 ---- 元素类型
BattleConst.ELEMENT_TYPE = { BattleConst.ELEMENT_TYPE = {
NONE = 0,
RED = 1, RED = 1,
YELLOW = 2, YELLOW = 2,
GREEN = 3, GREEN = 3,

View File

@ -1039,11 +1039,16 @@ function BattleUnitComp:playDead(callback)
self.deadOverCallback = callback self.deadOverCallback = callback
if self:getIsClear() then if self:getIsClear() then
self.deadOverCallback = nil self.deadOverCallback = nil
return callback() if callback then
callback()
end
return
end end
if self.currState ~= UNIT_STATE.DEAD and not self:changeState(UNIT_STATE.DEAD) then if self.currState ~= UNIT_STATE.DEAD and not self:changeState(UNIT_STATE.DEAD) then
self.deadOverCallback = nil self.deadOverCallback = nil
callback() if callback then
callback()
end
end end
end end

View File

@ -604,6 +604,7 @@ function BattleController:onLinkOver()
linkElementType = elementType linkElementType = elementType
lineCount = lineCount + 1 lineCount = lineCount + 1
end end
boomGridIds[info.posId] = true
local outline = BattleConst.GRID_OUT_LINE_POS_ID[info.posId] local outline = BattleConst.GRID_OUT_LINE_POS_ID[info.posId]
for aroundPosId, _ in pairs(outline) do for aroundPosId, _ in pairs(outline) do
@ -624,10 +625,13 @@ function BattleController:onLinkOver()
if not eliminationPosIds[posId] then if not eliminationPosIds[posId] then
eliminationPosIds[posId] = true eliminationPosIds[posId] = true
table.insert(sequence, {posId = posId}) table.insert(sequence, {posId = posId})
if not entity:getSkillId() then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
end
end end
if not entity:getSkillId() then if not entity:getSkillId() then
local elementType = entity:getElementType() local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
if not influenceElementType then if not influenceElementType then
influenceElementType = {} influenceElementType = {}
end end
@ -640,13 +644,13 @@ function BattleController:onLinkOver()
end end
for posId, status in pairs(boomGridIds) do for posId, status in pairs(boomGridIds) do
if not eliminationPosIds[posId] then local entity = self.battleData:getGridEntity(posId)
local entity = self.battleData:getGridEntity(posId) if entity then
if entity then local elementTypeInvalid = entity:isElmentTypeInvalid()
local elementTypeInvalid = entity:isElmentTypeInvalid() entity:addAroundEliminationCount()
entity:addAroundEliminationCount() if entity:getIsIdle() then
if entity:getIsIdle() then eliminationPosIds[posId] = true
eliminationPosIds[posId] = true if not eliminationPosIds[posId] then
table.insert(sequence, {posId = posId, noAni = elementTypeInvalid}) table.insert(sequence, {posId = posId, noAni = elementTypeInvalid})
if not entity:getSkillId() and not elementTypeInvalid then if not entity:getSkillId() and not elementTypeInvalid then
local elementType = entity:getElementType() local elementType = entity:getElementType()
@ -670,7 +674,6 @@ end
function BattleController:fillBoard() function BattleController:fillBoard()
local pathMap = {} local pathMap = {}
local columnCount = {} local columnCount = {}
local gridMap = {} 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
@ -1105,25 +1108,23 @@ function BattleController:fillThisPos(posId, columnCount, gridMap)
if not fallEntity then -- 异常情况,理论上不可能不存在 if not fallEntity then -- 异常情况,理论上不可能不存在
return return
end end
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, gridMap)
self:fillThisPos(fallPosId, columnCount, gridMap) end
end fallEntity = self.battleData:getGridEntity(fallPosId)
fallEntity = self.battleData:getGridEntity(fallPosId) if not fallEntity:getIsIdle() then
if not fallEntity:getIsIdle() then if not fallEntity:getPath()[1] then
if not fallEntity:getPath()[1] then local curPos = ModuleManager.BattleManager:getPosInfo(fallPosId)
local curPos = ModuleManager.BattleManager:getPosInfo(fallPosId)
fallEntity:addPath({x = curPos.x, y = curPos.y})
end
local curPos = ModuleManager.BattleManager:getPosInfo(posId)
fallEntity:addPath({x = curPos.x, y = curPos.y}) fallEntity:addPath({x = curPos.x, y = curPos.y})
self.battleData:exchangeGridEntities(posId, fallPosId)
self:fillThisPos(fallPosId, columnCount, gridMap)
return
end end
local curPos = ModuleManager.BattleManager:getPosInfo(posId)
fallEntity:addPath({x = curPos.x, y = curPos.y})
self.battleData:exchangeGridEntities(posId, fallPosId)
self:fillThisPos(fallPosId, columnCount, gridMap)
return
end end
end end
end end

View File

@ -59,12 +59,15 @@ function BattleUI:initSkill()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
for name, elementType in pairs(GConst.BattleConst.ELEMENT_TYPE) do for name, elementType in pairs(GConst.BattleConst.ELEMENT_TYPE) do
self.skillNodeCells[elementType] = CellManager:addCellComp(uiMap["battle_ui.bg_2.skill_node_cell_" .. elementType], SKILL_NODE_CELL) local obj = uiMap["battle_ui.bg_2.skill_node_cell_" .. elementType]
local skillEntity = DataManager.BattleData:getSkillEntities()[elementType] if obj then
if skillEntity then self.skillNodeCells[elementType] = CellManager:addCellComp(obj, SKILL_NODE_CELL)
self.skillNodeCells[elementType]:refresh(skillEntity) local skillEntity = DataManager.BattleData:getSkillEntities()[elementType]
if skillEntity then
self.skillNodeCells[elementType]:refresh(skillEntity)
end
self.skillNodeCells[elementType]:getBaseObject():setActive(skillEntity ~= nil)
end end
self.skillNodeCells[elementType]:getBaseObject():setActive(skillEntity ~= nil)
end end
uiMap["battle_ui.bg_2.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout() uiMap["battle_ui.bg_2.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
@ -467,10 +470,13 @@ function BattleUI:hideGenerateSkillGridCells()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
self.generateSkillGridEntities = {} self.generateSkillGridEntities = {}
for name, elementType in pairs(GConst.BattleConst.ELEMENT_TYPE) do for name, elementType in pairs(GConst.BattleConst.ELEMENT_TYPE) do
local cell = CellManager:addCellComp(uiMap["battle_ui.bg_2.board_node.ani_node.grid_cell_" .. elementType], GRID_CELL) local obj = uiMap["battle_ui.bg_2.board_node.ani_node.grid_cell_" .. elementType]
local entity = DataManager.BattleData:getNewGridEntity() if obj then
entity:setCell(cell) local cell = CellManager:addCellComp(obj, GRID_CELL)
self.generateSkillGridEntities[elementType] = entity local entity = DataManager.BattleData:getNewGridEntity()
entity:setCell(cell)
self.generateSkillGridEntities[elementType] = entity
end
end end
end end

View File

@ -5,12 +5,15 @@ function BattleGridEntity:ctor(data)
self:clear() self:clear()
self.posId = data.posId or 0 self.posId = data.posId or 0
self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY
self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.NONE
self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数 self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数
self.skillId = data.skillId self.skillId = data.skillId
self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数 self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数
self.isIdle = false self.isIdle = false
self.data.isDirty = false self.data.isDirty = false
if self.gridType == BattleConst.GRID_TYPE.EMPTY and self.elementType == BattleConst.ELEMENT_TYPE.NONE then
self.isIdle = true
end
end end
function BattleGridEntity:clear() function BattleGridEntity:clear()
@ -71,7 +74,7 @@ function BattleGridEntity:getElementType(skillEntity)
end end
function BattleGridEntity:isCantFallType() function BattleGridEntity:isCantFallType()
return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false return not self:isEmptyType()
end end
function BattleGridEntity:isObstacleType() function BattleGridEntity:isObstacleType()