优化木棍障碍物

This commit is contained in:
xiekaidong 2023-08-11 11:24:52 +08:00
parent 4c65578099
commit f5ed280271
4 changed files with 76 additions and 32 deletions

View File

@ -446,6 +446,18 @@ function BattleManager:getPosByDirection(posId, direction, maxRow)
end end
end end
function BattleManager:getReverseDirection(direction)
if direction == BattleConst.BOARD_RANGE_TYPE.UP then
return BattleConst.BOARD_RANGE_TYPE.DOWN
elseif direction == BattleConst.BOARD_RANGE_TYPE.DOWN then
return BattleConst.BOARD_RANGE_TYPE.UP
elseif direction == BattleConst.BOARD_RANGE_TYPE.LEFT then
return BattleConst.BOARD_RANGE_TYPE.RIGHT
elseif direction == BattleConst.BOARD_RANGE_TYPE.RIGHT then
return BattleConst.BOARD_RANGE_TYPE.LEFT
end
end
----------------------- end 一些公共相关的方法 ----------------------------- ----------------------- end 一些公共相关的方法 -----------------------------
function BattleManager:bindBattleUnitAttribute(hashCode, side) function BattleManager:bindBattleUnitAttribute(hashCode, side)

View File

@ -11,6 +11,7 @@ local BATTLE_INSTRUCTIONS_HELPER = require "app/module/battle/helper/battle_inst
local BattleBoardTouchHelper = require "app/module/battle/helper/battle_board_touch_helper" local BattleBoardTouchHelper = require "app/module/battle/helper/battle_board_touch_helper"
local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle" local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle"
local BATTLE_SNAPSHOT_HELPER = require "app/module/battle/helper/battle_snapshot_helper" local BATTLE_SNAPSHOT_HELPER = require "app/module/battle/helper/battle_snapshot_helper"
local BOARD_HELER = require "app/module/battle/helper/board_helper"
local BattleFormula = require "app/module/battle/helper/battle_formula" local BattleFormula = require "app/module/battle/helper/battle_formula"
local BattleBaseController = class("BattleBaseController") local BattleBaseController = class("BattleBaseController")
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
@ -1404,7 +1405,9 @@ function BattleBaseController:dealGridBreak(posId, condition, time, breakedMap,
local outline = BattleConst.UP_DOWN_LEFT_RIGHT[posId] local outline = BattleConst.UP_DOWN_LEFT_RIGHT[posId]
for _, id in ipairs(outline) do for _, id in ipairs(outline) do
if self.battleData:getGridEntity(id) then if self.battleData:getGridEntity(id) then
self:dealGridBreak(id, GRID_BREAK_CONDITION.AROUND, time, breakedMap, sequenceMap, aniSequence, gridMap, onlyCheck) if not BOARD_HELER:hasGridEdgeBetween(self, posId, id) then
self:dealGridBreak(id, GRID_BREAK_CONDITION.AROUND, time, breakedMap, sequenceMap, aniSequence, gridMap, onlyCheck)
end
end end
end end
end end

View File

@ -177,4 +177,24 @@ function BoardHelper:getAroundPosIds(posId, gridMap, mainElementType)
return ids return ids
end end
function BoardHelper:hasGridEdgeBetween(battleController, posId1, posId2)
local direction = ModuleManager.BattleManager:getPosDirection(posId1, posId2)
local reverseDirection = ModuleManager.BattleManager:getReverseDirection(direction)
if not reverseDirection then
return false
end
local gridEdgeEntity = battleController.battleData:getGridEdgeEntity(posId1, direction)
if gridEdgeEntity and not gridEdgeEntity:getIsIdle() then
return true
end
local gridEdgeEntity = battleController.battleData:getGridEdgeEntity(posId2, reverseDirection)
if gridEdgeEntity and not gridEdgeEntity:getIsIdle() then
return true
end
return false
end
return BoardHelper return BoardHelper

View File

@ -1,5 +1,5 @@
local BattleConst = require "app/module/battle/battle_const" local BattleConst = require "app/module/battle/battle_const"
local BOARD_HELER = require "app/module/battle/helper/board_helper"
local BattleGridEffectHandle = {} local BattleGridEffectHandle = {}
local GRID_EFFECT_TYPE = BattleConst.GRID_EFFECT_TYPE local GRID_EFFECT_TYPE = BattleConst.GRID_EFFECT_TYPE
@ -20,6 +20,7 @@ local function _crossSpread(entity, gridEntities, battleController, onlyCheck)
return return
end end
local ePodId = entity:getPosId()
local tempList = BattleConst.UP_DOWN_LEFT_RIGHT[entity:getPosId()] local tempList = BattleConst.UP_DOWN_LEFT_RIGHT[entity:getPosId()]
if not tempList then if not tempList then
return return
@ -30,15 +31,17 @@ local function _crossSpread(entity, gridEntities, battleController, onlyCheck)
for _, posId in ipairs(tempList) do for _, posId in ipairs(tempList) do
local gridEntity = gridEntities[posId] local gridEntity = gridEntities[posId]
if gridEntity and gridEntity:isEmptyIdle() then if gridEntity and gridEntity:isEmptyIdle() then
if battleController.battleUI and entity:getEffectSfx() then if not BOARD_HELER:hasGridEdgeBetween(battleController, posId, ePodId) then
battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function() if battleController.battleUI and entity:getEffectSfx() then
battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function()
battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY)
end)
else
battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY) battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY)
end) end
else succ = true
battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY) break
end end
succ = true
break
end end
end end
@ -54,6 +57,7 @@ local function _crossSpreadNotBreak(entity, gridEntities, battleController, only
return return
end end
local ePodId = entity:getPosId()
local tempList = BattleConst.UP_DOWN_LEFT_RIGHT[entity:getPosId()] local tempList = BattleConst.UP_DOWN_LEFT_RIGHT[entity:getPosId()]
if not tempList then if not tempList then
return return
@ -64,14 +68,16 @@ local function _crossSpreadNotBreak(entity, gridEntities, battleController, only
for _, posId in ipairs(tempList) do for _, posId in ipairs(tempList) do
local gridEntity = gridEntities[posId] local gridEntity = gridEntities[posId]
if gridEntity and gridEntity:isEmptyIdle() then if gridEntity and gridEntity:isEmptyIdle() then
battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY, true) if not BOARD_HELER:hasGridEdgeBetween(battleController, posId, ePodId) then
if battleController.battleUI and entity:getEffectSfx() then battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY, true)
battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function() if battleController.battleUI and entity:getEffectSfx() then
battleController.battleData:setGridDirty(posId) battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function()
end) battleController.battleData:setGridDirty(posId)
end)
end
succ = true
break
end end
succ = true
break
end end
end end
@ -100,6 +106,7 @@ local function _crossMoveNotBreak(entity, gridEntities, battleController, onlyCh
return return
end end
local ePodId = entity:getPosId()
if battleController.lastRoundBreakedGridType[entity:getGridType()] then if battleController.lastRoundBreakedGridType[entity:getGridType()] then
return return
end end
@ -125,24 +132,26 @@ local function _crossMoveNotBreak(entity, gridEntities, battleController, onlyCh
for _, posId in ipairs(tempList) do for _, posId in ipairs(tempList) do
local gridEntity = gridEntities[posId] local gridEntity = gridEntities[posId]
if gridEntity and gridEntity:isEmptyIdle() and not map[posId] then if gridEntity and gridEntity:isEmptyIdle() and not map[posId] then
local direction = ModuleManager.BattleManager:getPosDirection(entity:getPosId(), posId) if not BOARD_HELER:hasGridEdgeBetween(battleController, posId, ePodId) then
local cell = entity:getCell() local direction = ModuleManager.BattleManager:getPosDirection(entity:getPosId(), posId)
if cell then local cell = entity:getCell()
if direction == BattleConst.BOARD_RANGE_TYPE.UP then if cell then
cell:playAnim("up", true, false, false) if direction == BattleConst.BOARD_RANGE_TYPE.UP then
elseif direction == BattleConst.BOARD_RANGE_TYPE.DOWN then cell:playAnim("up", true, false, false)
cell:playAnim("down", true, false, false) elseif direction == BattleConst.BOARD_RANGE_TYPE.DOWN then
elseif direction == BattleConst.BOARD_RANGE_TYPE.LEFT then cell:playAnim("down", true, false, false)
cell:playAnim("left", true, false, false) elseif direction == BattleConst.BOARD_RANGE_TYPE.LEFT then
elseif direction == BattleConst.BOARD_RANGE_TYPE.RIGHT then cell:playAnim("left", true, false, false)
cell:playAnim("right", true, false, false) elseif direction == BattleConst.BOARD_RANGE_TYPE.RIGHT then
cell:playAnim("right", true, false, false)
end
end end
map[entity:getPosId()] = entity
map[posId] = gridEntity
battleController.battleData:exchangeGridEntities(entity:getPosId(), posId)
succ = true
break
end end
map[entity:getPosId()] = entity
map[posId] = gridEntity
battleController.battleData:exchangeGridEntities(entity:getPosId(), posId)
succ = true
break
end end
end end
end end