消除逻辑调整一下

This commit is contained in:
xiekaidong 2023-04-07 15:31:27 +08:00
parent 76ace3a065
commit d9191bd03a
5 changed files with 50 additions and 10 deletions

View File

@ -26,6 +26,13 @@ BattleConst.GRID_TYPE = {
ICE = 5, ICE = 5,
} }
BattleConst.GRID_TYPE_ICON = {
[BattleConst.GRID_TYPE.SNOW_BOX] = "snow_1",
[BattleConst.GRID_TYPE.SOLID_SNOW] = "snow_2",
[BattleConst.GRID_TYPE.VINES] = "vine",
[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},
@ -35,6 +42,7 @@ BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = {
---- 不可下落的格子类型 ---- 不可下落的格子类型
BattleConst.CANT_FALL_GRID_TYPE = { BattleConst.CANT_FALL_GRID_TYPE = {
[BattleConst.GRID_TYPE.OBSTACLE] = true,
[BattleConst.GRID_TYPE.VINES] = true, [BattleConst.GRID_TYPE.VINES] = true,
[BattleConst.GRID_TYPE.ICE] = true, [BattleConst.GRID_TYPE.ICE] = true,
} }

View File

@ -32,8 +32,8 @@ function BattleManager:getElementIcon(elementType)
return GConst.ATLAS_PATH.BATTLE, icon return GConst.ATLAS_PATH.BATTLE, icon
end end
function BattleManager:getGridTypeIcon(elementType) function BattleManager:getGridTypeIcon(gridType)
local icon = GConst.BattleConst.ELEMENT_ICON[elementType] local icon = GConst.BattleConst.GRID_TYPE_ICON[gridType]
if not icon then if not icon then
return GConst.ATLAS_PATH.COMMON, "common_alpha" return GConst.ATLAS_PATH.COMMON, "common_alpha"
end end

View File

@ -117,17 +117,30 @@ function BattleController:onEliminationAniOver()
eliminationPosIds[posId] = true eliminationPosIds[posId] = true
end end
local newIdleList = {}
local cellList = {}
for posId, status in pairs(boomGridIds) do for posId, status in pairs(boomGridIds) do
if not eliminationPosIds[posId] then if not eliminationPosIds[posId] then
local entity = DataManager.BattleData:getGridEntity(posId) local entity = DataManager.BattleData:getGridEntity(posId)
if entity then if entity then
entity:addAroundEliminationCount() entity:addAroundEliminationCount()
if entity:getIsIdle() then
table.insert(newIdleList, entity)
table.insert(cellList, entity:getCell())
end
end end
end end
end end
DataManager.BattleData:clearGridSequence() DataManager.BattleData:clearGridSequence()
if cellList[1] then
self.battleUI:eliminationAni(cellList, function()
self:fillBoard()
end)
return
end
self:fillBoard() self:fillBoard()
end end

View File

@ -1,15 +1,27 @@
local GridCell = class("GridCell", BaseCell) local GridCell = class("GridCell", BaseCell)
function GridCell:refresh(gridEntity, curElement) function GridCell:refresh(gridEntity, curElement)
local atlas, icon = ModuleManager.BattleManager:getElementIcon(gridEntity:getElementType())
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
if self.lastIcon ~= icon then local elementType = gridEntity:getElementType()
self.lastIcon = icon if self.lastElementType ~= elementType then
self.lastElementType = elementType
local atlas, icon = ModuleManager.BattleManager:getElementIcon(elementType)
uiMap["grid_cell.touch_node.ani_node.middle_bg"]:setSprite(atlas, icon) uiMap["grid_cell.touch_node.ani_node.middle_bg"]:setSprite(atlas, icon)
end end
uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(curElement and curElement ~= gridEntity:getElementType()) local showMask = false
uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isCantFallType()) if curElement and (curElement ~= elementType or not gridEntity:canLink()) then
showMask = true
end
uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(showMask)
uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isObstacleType())
if self.lastGridType ~= gridEntity:getGridType() then
self.lastGridType = gridEntity:getGridType()
local atlas, icon = ModuleManager.BattleManager:getGridTypeIcon(self.lastGridType)
uiMap["grid_cell.touch_node.ani_node.up_bg"]:setSprite(atlas, icon)
end
--- 测试代码 --- 测试代码
uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount()) uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount())

View File

@ -34,6 +34,10 @@ function BattleGridEntity:isCantFallType()
return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false
end end
function BattleGridEntity:isObstacleType()
return self.gridType == BattleConst.GRID_TYPE.OBSTACLE
end
function BattleGridEntity:getAroundEliminationCount() function BattleGridEntity:getAroundEliminationCount()
return self.aroundEliminationCount return self.aroundEliminationCount
end end
@ -41,10 +45,13 @@ end
function BattleGridEntity:addAroundEliminationCount(count) function BattleGridEntity:addAroundEliminationCount(count)
count = count or 1 count = count or 1
self.aroundEliminationCount = self.aroundEliminationCount + count self.aroundEliminationCount = self.aroundEliminationCount + count
local gridTypeList = BattleConst.AROUND_ELIMINATION_TO_EMPTY_TYPE_COUNT[self.gridType] local gridTypeList = BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType]
if gridTypeList and gridTypeList[self.aroundEliminationCount] then if gridTypeList and gridTypeList[self.aroundEliminationCount] then
self:setGridType(gridTypeList[self.aroundEliminationCount]) local gridType = gridTypeList[self.aroundEliminationCount]
self.aroundEliminationCount = self.aroundEliminationCount - 1 self:setGridType(gridType)
if gridType == BattleConst.GRID_TYPE.EMPTY then
self:setIsIdle(true)
end
end end
self:setDirty() self:setDirty()
end end