From 7afa7f77b582f13915d22a8ebcbffca2242bf672 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 19 Apr 2023 21:03:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=AB=E5=85=85bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 4 +- .../battle/component/battle_unit_comp.lua | 9 +++- .../battle/controller/battle_controller.lua | 53 ++++++++++--------- lua/app/ui/battle/battle_ui.lua | 24 +++++---- .../userdata/battle/battle_grid_entity.lua | 7 ++- 5 files changed, 57 insertions(+), 40 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 4f3da124..54f0aaaa 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -264,10 +264,11 @@ BattleConst.GRID_TYPE_ICON = { [BattleConst.GRID_TYPE.ICE] = "ice", } ----- 周围格子消除一次后会变成什么格子 +---- 周围格子或自己消除一次后会变成什么格子 BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = { [BattleConst.GRID_TYPE.SNOW_BOX] = {BattleConst.GRID_TYPE.EMPTY}, [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}, } @@ -288,6 +289,7 @@ BattleConst.CANT_LINK_GRID_TYPE = { ---- 元素类型 BattleConst.ELEMENT_TYPE = { + NONE = 0, RED = 1, YELLOW = 2, GREEN = 3, diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index ff5d5c9c..8a274391 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -1039,11 +1039,16 @@ function BattleUnitComp:playDead(callback) self.deadOverCallback = callback if self:getIsClear() then self.deadOverCallback = nil - return callback() + if callback then + callback() + end + return end if self.currState ~= UNIT_STATE.DEAD and not self:changeState(UNIT_STATE.DEAD) then self.deadOverCallback = nil - callback() + if callback then + callback() + end end end diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index a49ac45e..3a24d4de 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -604,6 +604,7 @@ function BattleController:onLinkOver() linkElementType = elementType lineCount = lineCount + 1 end + boomGridIds[info.posId] = true local outline = BattleConst.GRID_OUT_LINE_POS_ID[info.posId] for aroundPosId, _ in pairs(outline) do @@ -624,10 +625,13 @@ function BattleController:onLinkOver() if not eliminationPosIds[posId] then eliminationPosIds[posId] = true table.insert(sequence, {posId = posId}) + if not entity:getSkillId() then + local elementType = entity:getElementType() + elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 + end end if not entity:getSkillId() then local elementType = entity:getElementType() - elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 if not influenceElementType then influenceElementType = {} end @@ -640,13 +644,13 @@ function BattleController:onLinkOver() end for posId, status in pairs(boomGridIds) do - if not eliminationPosIds[posId] then - local entity = self.battleData:getGridEntity(posId) - if entity then - local elementTypeInvalid = entity:isElmentTypeInvalid() - entity:addAroundEliminationCount() - if entity:getIsIdle() then - eliminationPosIds[posId] = true + local entity = self.battleData:getGridEntity(posId) + if entity then + local elementTypeInvalid = entity:isElmentTypeInvalid() + entity:addAroundEliminationCount() + if entity:getIsIdle() then + eliminationPosIds[posId] = true + if not eliminationPosIds[posId] then table.insert(sequence, {posId = posId, noAni = elementTypeInvalid}) if not entity:getSkillId() and not elementTypeInvalid then local elementType = entity:getElementType() @@ -670,7 +674,6 @@ end function BattleController:fillBoard() local pathMap = {} local columnCount = {} - local gridMap = {} for c = 1, BattleConst.COLUMN_COUNT do for r = BattleConst.ROW_COUNT, 1, -1 do @@ -1105,25 +1108,23 @@ function BattleController:fillThisPos(posId, columnCount, gridMap) if not fallEntity then -- 异常情况,理论上不可能不存在 return end - if fallEntity then - if not fallEntity:isCantFallType() then - if fallEntity:getIsIdle() then - self:fillThisPos(fallPosId, columnCount, gridMap) - end - fallEntity = self.battleData:getGridEntity(fallPosId) - if not fallEntity:getIsIdle() then - if not fallEntity:getPath()[1] then - local curPos = ModuleManager.BattleManager:getPosInfo(fallPosId) - fallEntity:addPath({x = curPos.x, y = curPos.y}) - end - - local curPos = ModuleManager.BattleManager:getPosInfo(posId) + if not fallEntity:isCantFallType() then + if fallEntity:getIsIdle() then + self:fillThisPos(fallPosId, columnCount, gridMap) + end + fallEntity = self.battleData:getGridEntity(fallPosId) + if not fallEntity:getIsIdle() then + if not fallEntity:getPath()[1] then + local curPos = ModuleManager.BattleManager:getPosInfo(fallPosId) fallEntity:addPath({x = curPos.x, y = curPos.y}) - - self.battleData:exchangeGridEntities(posId, fallPosId) - self:fillThisPos(fallPosId, columnCount, gridMap) - return 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 diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 42e5649d..3ec0c57a 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -59,12 +59,15 @@ function BattleUI:initSkill() local uiMap = self.root:genAllChildren() 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 skillEntity = DataManager.BattleData:getSkillEntities()[elementType] - if skillEntity then - self.skillNodeCells[elementType]:refresh(skillEntity) + local obj = uiMap["battle_ui.bg_2.skill_node_cell_" .. elementType] + if obj then + self.skillNodeCells[elementType] = CellManager:addCellComp(obj, SKILL_NODE_CELL) + local skillEntity = DataManager.BattleData:getSkillEntities()[elementType] + if skillEntity then + self.skillNodeCells[elementType]:refresh(skillEntity) + end + self.skillNodeCells[elementType]:getBaseObject():setActive(skillEntity ~= nil) end - self.skillNodeCells[elementType]:getBaseObject():setActive(skillEntity ~= nil) end 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() self.generateSkillGridEntities = {} 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 entity = DataManager.BattleData:getNewGridEntity() - entity:setCell(cell) - self.generateSkillGridEntities[elementType] = entity + local obj = uiMap["battle_ui.bg_2.board_node.ani_node.grid_cell_" .. elementType] + if obj then + local cell = CellManager:addCellComp(obj, GRID_CELL) + local entity = DataManager.BattleData:getNewGridEntity() + entity:setCell(cell) + self.generateSkillGridEntities[elementType] = entity + end end end diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index e406628f..b7755e72 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -5,12 +5,15 @@ function BattleGridEntity:ctor(data) self:clear() self.posId = data.posId or 0 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.skillId = data.skillId self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数 self.isIdle = 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 function BattleGridEntity:clear() @@ -71,7 +74,7 @@ function BattleGridEntity:getElementType(skillEntity) end function BattleGridEntity:isCantFallType() - return BattleConst.CANT_FALL_GRID_TYPE[self.gridType] or false + return not self:isEmptyType() end function BattleGridEntity:isObstacleType()