diff --git a/lua/app/game.lua b/lua/app/game.lua index 93e283fd..8d612628 100644 --- a/lua/app/game.lua +++ b/lua/app/game.lua @@ -389,6 +389,17 @@ if NOT_PUBLISH then Logger.logHighlight("截图保存地址:%s", path) end + if Input.GetKeyDown(KeyCode.G) and Input.GetKey(KeyCode.LeftControl) then + if DataManager.BattleData.gridEntities then + local map = {} + for posId, entity in pairs(DataManager.BattleData.gridEntities) do + map[posId] = entity:getSnapshoptInfo() + end + Logger.logHighlight("——————————战斗棋盘快照如下————————") + Logger.printTable(map) + end + end + -- if Input.GetKeyDown(KeyCode.P) then -- ModuleManager.ChapterManager:showBattleFailUI(nil, true) -- end diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 688aefc7..43648db3 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -292,10 +292,15 @@ BattleConst.GRID_TYPE_ICON = { ---- 周围格子或自己消除一次后会变成什么格子 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}, + [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, +} + +BattleConst.AROUND_BOOM_TYPE = { + ACOUND = 1, + LINE = 2, } ---- 不可下落的格子类型 diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index c6e3d6ff..c824110a 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -769,11 +769,13 @@ function BattleController:onLinkOver() linkElementType = elementType lineCount = lineCount + 1 end - boomGridIds[info.posId] = true + boomGridIds[info.posId] = BattleConst.AROUND_BOOM_TYPE.LINE local outline = BattleConst.UP_DOWN_LEFT_RIGHT[info.posId] for _, aroundPosId in ipairs(outline) do - boomGridIds[aroundPosId] = true + if not boomGridIds[aroundPosId] then + boomGridIds[aroundPosId] = BattleConst.AROUND_BOOM_TYPE.ACOUND + end end local entity = self.battleData:getGridEntity(info.posId) @@ -803,35 +805,36 @@ function BattleController:onLinkOver() influenceElementType[elementType] = true end else - boomGridIds[posId] = true + boomGridIds[posId] = BattleConst.AROUND_BOOM_TYPE.LINE end end end local gridBreakSfxInfo - for posId, status in pairs(boomGridIds) do + for posId, boomType in pairs(boomGridIds) do local entity = self.battleData:getGridEntity(posId) if entity then local gridType = entity:getGridType() - if BattleConst.GRID_TYPE_BREAK_SFX[gridType] then - if not gridBreakSfxInfo then - gridBreakSfxInfo = {} + if entity:addAroundEliminationCount(boomType) then + if BattleConst.GRID_TYPE_BREAK_SFX[gridType] then + if not gridBreakSfxInfo then + gridBreakSfxInfo = {} + end + if not gridBreakSfxInfo[gridType] then + gridBreakSfxInfo[gridType] = {} + end + table.insert(gridBreakSfxInfo[gridType], posId) end - if not gridBreakSfxInfo[gridType] then - gridBreakSfxInfo[gridType] = {} - end - table.insert(gridBreakSfxInfo[gridType], posId) - end - - 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() - elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 + + local elementTypeInvalid = entity:isElmentTypeInvalid() + 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() + elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 + end end end end diff --git a/lua/app/ui/battle/cell/grid_cell.lua b/lua/app/ui/battle/cell/grid_cell.lua index df3c8e22..f5af3cbc 100644 --- a/lua/app/ui/battle/cell/grid_cell.lua +++ b/lua/app/ui/battle/cell/grid_cell.lua @@ -69,8 +69,6 @@ function GridCell:refresh(gridEntity, curElement, skillPosId) self:hideAni() end self:showHighLight(self.lastShowHlElementType ~= nil, self.lastShowHlElementType) - --- 测试代码 - -- uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount()) end function GridCell:addTouchListener(func) diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index 97731214..4cec2260 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -6,7 +6,6 @@ function BattleGridEntity:ctor(data) self.posId = data.posId or 0 self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY 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 @@ -17,7 +16,6 @@ end function BattleGridEntity:clear() self.gridType = BattleConst.GRID_TYPE.EMPTY self.elementType = BattleConst.ELEMENT_TYPE.RED - self.aroundEliminationCount = 0 -- 周围消除次数 self.skillId = nil self.linkSkillCount = 0 -- 任意链接技能激活次数 self.isIdle = false @@ -29,7 +27,6 @@ function BattleGridEntity:getSnapshoptInfo() posId = self.posId, gridType = self.gridType, elementType = self.elementType, - aroundEliminationCount = self.aroundEliminationCount, isIdle = self.isIdle, skillId = self.skillId, linkSkillCount = self.linkSkillCount, @@ -40,7 +37,6 @@ function BattleGridEntity:setInfoBySnapshop(snapshot) self.posId = snapshot.posId or 0 self.gridType = snapshot.gridType or BattleConst.GRID_TYPE.EMPTY self.elementType = snapshot.elementType or BattleConst.ELEMENT_TYPE.RED - self.aroundEliminationCount = snapshot.aroundEliminationCount or 0 -- 周围消除次数 self.isIdle = snapshot.isIdle self.skillId = snapshot.skillId self.linkSkillCount = snapshot.linkSkillCount @@ -87,23 +83,21 @@ function BattleGridEntity:isElmentTypeInvalid() return BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType] ~= nil end -function BattleGridEntity:getAroundEliminationCount() - return self.aroundEliminationCount -end - -function BattleGridEntity:addAroundEliminationCount(count) - count = count or 1 - self.aroundEliminationCount = self.aroundEliminationCount + count - local gridTypeList = BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType] - if gridTypeList and gridTypeList[self.aroundEliminationCount] then - local gridType = gridTypeList[self.aroundEliminationCount] +function BattleGridEntity:addAroundEliminationCount(boomType) + local nextGridType = BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType] + if nextGridType then local beforeGridtype = self:getGridType() - self:setGridType(gridType) - if gridType == BattleConst.GRID_TYPE.EMPTY and beforeGridtype ~= BattleConst.GRID_TYPE.ICE then + if beforeGridtype == BattleConst.GRID_TYPE.VINES and boomType ~= BattleConst.AROUND_BOOM_TYPE.LINE then + return false + end + + self:setGridType(nextGridType) + if nextGridType == BattleConst.GRID_TYPE.EMPTY and beforeGridtype ~= BattleConst.GRID_TYPE.ICE then self:setIsIdle(true) end end self:setDirty() + return true end function BattleGridEntity:getPos() @@ -124,9 +118,6 @@ end function BattleGridEntity:setIsIdle(isIdle) self.isIdle = isIdle == true - if self.isIdle then - self.aroundEliminationCount = 0 - end end function BattleGridEntity:canLink() @@ -154,7 +145,6 @@ end function BattleGridEntity:setGridType(gridType) self.gridType = gridType - self.aroundEliminationCount = 0 self:setDirty() end