优化木棍障碍物

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
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 一些公共相关的方法 -----------------------------
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 BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle"
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 BattleBaseController = class("BattleBaseController")
local BattleConst = GConst.BattleConst
@ -1404,7 +1405,9 @@ function BattleBaseController:dealGridBreak(posId, condition, time, breakedMap,
local outline = BattleConst.UP_DOWN_LEFT_RIGHT[posId]
for _, id in ipairs(outline) do
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

View File

@ -177,4 +177,24 @@ function BoardHelper:getAroundPosIds(posId, gridMap, mainElementType)
return ids
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

View File

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