From d9191bd03a97afc22d191de786dcdb23527efe33 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Fri, 7 Apr 2023 15:31:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4=E9=80=BB=E8=BE=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 8 +++++++ lua/app/module/battle/battle_manager.lua | 4 ++-- .../battle/controller/battle_controller.lua | 13 +++++++++++ lua/app/ui/battle/cell/grid_cell.lua | 22 ++++++++++++++----- .../userdata/battle/battle_grid_entity.lua | 13 ++++++++--- 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 5b221f7e..4cb9fe04 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -26,6 +26,13 @@ BattleConst.GRID_TYPE = { 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.GRID_TYPE.SNOW_BOX] = {BattleConst.GRID_TYPE.EMPTY}, @@ -35,6 +42,7 @@ BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = { ---- 不可下落的格子类型 BattleConst.CANT_FALL_GRID_TYPE = { + [BattleConst.GRID_TYPE.OBSTACLE] = true, [BattleConst.GRID_TYPE.VINES] = true, [BattleConst.GRID_TYPE.ICE] = true, } diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index e077efbd..1406678d 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -32,8 +32,8 @@ function BattleManager:getElementIcon(elementType) return GConst.ATLAS_PATH.BATTLE, icon end -function BattleManager:getGridTypeIcon(elementType) - local icon = GConst.BattleConst.ELEMENT_ICON[elementType] +function BattleManager:getGridTypeIcon(gridType) + local icon = GConst.BattleConst.GRID_TYPE_ICON[gridType] if not icon then return GConst.ATLAS_PATH.COMMON, "common_alpha" end diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index faf03605..d5d8f08b 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -117,17 +117,30 @@ function BattleController:onEliminationAniOver() eliminationPosIds[posId] = true end + local newIdleList = {} + local cellList = {} for posId, status in pairs(boomGridIds) do if not eliminationPosIds[posId] then local entity = DataManager.BattleData:getGridEntity(posId) if entity then entity:addAroundEliminationCount() + if entity:getIsIdle() then + table.insert(newIdleList, entity) + table.insert(cellList, entity:getCell()) + end end end end DataManager.BattleData:clearGridSequence() + if cellList[1] then + self.battleUI:eliminationAni(cellList, function() + self:fillBoard() + end) + return + end + self:fillBoard() end diff --git a/lua/app/ui/battle/cell/grid_cell.lua b/lua/app/ui/battle/cell/grid_cell.lua index 170b4148..3677bbe3 100644 --- a/lua/app/ui/battle/cell/grid_cell.lua +++ b/lua/app/ui/battle/cell/grid_cell.lua @@ -1,15 +1,27 @@ local GridCell = class("GridCell", BaseCell) function GridCell:refresh(gridEntity, curElement) - local atlas, icon = ModuleManager.BattleManager:getElementIcon(gridEntity:getElementType()) local uiMap = self:getUIMap() - if self.lastIcon ~= icon then - self.lastIcon = icon + local elementType = gridEntity:getElementType() + 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) end - uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(curElement and curElement ~= gridEntity:getElementType()) - uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isCantFallType()) + local showMask = false + 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()) diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index 6435b2d9..f2019da3 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -34,6 +34,10 @@ function BattleGridEntity:isCantFallType() return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false end +function BattleGridEntity:isObstacleType() + return self.gridType == BattleConst.GRID_TYPE.OBSTACLE +end + function BattleGridEntity:getAroundEliminationCount() return self.aroundEliminationCount end @@ -41,10 +45,13 @@ end function BattleGridEntity:addAroundEliminationCount(count) count = count or 1 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 - self:setGridType(gridTypeList[self.aroundEliminationCount]) - self.aroundEliminationCount = self.aroundEliminationCount - 1 + local gridType = gridTypeList[self.aroundEliminationCount] + self:setGridType(gridType) + if gridType == BattleConst.GRID_TYPE.EMPTY then + self:setIsIdle(true) + end end self:setDirty() end