优化木棍障碍物

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,10 +1405,12 @@ 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
if not BOARD_HELER:hasGridEdgeBetween(self, posId, id) then
self:dealGridBreak(id, GRID_BREAK_CONDITION.AROUND, time, breakedMap, sequenceMap, aniSequence, gridMap, onlyCheck) self:dealGridBreak(id, GRID_BREAK_CONDITION.AROUND, time, breakedMap, sequenceMap, aniSequence, gridMap, onlyCheck)
end end
end end
end end
end
if entity:getEffectType() then if entity:getEffectType() then
local succ, list = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(posId, gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_GRID_BREAK, self, onlyCheck) local succ, list = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(posId, gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_GRID_BREAK, self, onlyCheck)
if list then if list then

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,6 +31,7 @@ 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 not BOARD_HELER:hasGridEdgeBetween(battleController, posId, ePodId) then
if battleController.battleUI and entity:getEffectSfx() then if battleController.battleUI and entity:getEffectSfx() then
battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function() battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function()
battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY) battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY)
@ -41,6 +43,7 @@ local function _crossSpread(entity, gridEntities, battleController, onlyCheck)
break break
end end
end end
end
return succ return succ
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,6 +68,7 @@ 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
if not BOARD_HELER:hasGridEdgeBetween(battleController, posId, ePodId) then
battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY, true) battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY, true)
if battleController.battleUI and entity:getEffectSfx() then if battleController.battleUI and entity:getEffectSfx() then
battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function() battleController.battleUI:showGridEffectSfx(posId, entity:getEffectSfx(), function()
@ -74,6 +79,7 @@ local function _crossSpreadNotBreak(entity, gridEntities, battleController, only
break break
end end
end end
end
return succ return succ
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,6 +132,7 @@ 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
if not BOARD_HELER:hasGridEdgeBetween(battleController, posId, ePodId) then
local direction = ModuleManager.BattleManager:getPosDirection(entity:getPosId(), posId) local direction = ModuleManager.BattleManager:getPosDirection(entity:getPosId(), posId)
local cell = entity:getCell() local cell = entity:getCell()
if cell then if cell then
@ -147,6 +155,7 @@ local function _crossMoveNotBreak(entity, gridEntities, battleController, onlyCh
end end
end end
end end
end
if succ then if succ then
battleController.battleUI:moveGridCells(map, function() battleController.battleUI:moveGridCells(map, function()
for _, entity in ipairs(allSnake) do for _, entity in ipairs(allSnake) do