diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index a53027e3..9658311b 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -418,6 +418,7 @@ BattleConst.GRID_EFFECT_TYPE = { SELECT_COMMON_SKILL = 3, REWARD_BOX = 4, CROSS_SPREAD_NOT_BREAK = 5, + CROSS_MOVE_NOT_BREAK = 6, } BattleConst.GRID_EFFECT_TRIGGER_TYPE = { diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 89b33688..5a6b6d78 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -575,7 +575,7 @@ function BattleController:takeGridEffect() local availableEffectTypeMap for _, entity in ipairs(effectGrid) do local effectType = entity:getEffectType() - if not availableEffectTypeMap or not availableEffectTypeMap[effectType] then + if effectType ~= BattleConst.GRID_EFFECT_TYPE.CROSS_MOVE_NOT_BREAK and (not availableEffectTypeMap or not availableEffectTypeMap[effectType]) then local succ = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(entity:getPosId(), gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_ROUND_BEGIN, self) if succ and (effectType == BattleConst.GRID_EFFECT_TYPE.CROSS_SPREAD or effectType == BattleConst.GRID_EFFECT_TYPE.CROSS_SPREAD_NOT_BREAK) then @@ -586,6 +586,19 @@ function BattleController:takeGridEffect() end end end + + for _, entity in ipairs(effectGrid) do -- gridEffect == 6的最后处理 + local effectType = entity:getEffectType() + if effectType == BattleConst.GRID_EFFECT_TYPE.CROSS_MOVE_NOT_BREAK and (not availableEffectTypeMap or not availableEffectTypeMap[effectType]) then + local succ = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(entity:getPosId(), gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_ROUND_BEGIN, self) + if succ then + if not availableEffectTypeMap then + availableEffectTypeMap = {} + end + availableEffectTypeMap[effectType] = true + end + end + end end function BattleController:enterEliminationBegin() @@ -1919,16 +1932,27 @@ end function BattleController:changeElementType(count, elementType) self.changeElementTypeMap = table.clearOrCreate(self.changeElementTypeMap) + self.changeElementTypeList = table.clearOrCreate(self.changeElementTypeList) + local listCount = 0 for _, entity in pairs(self.battleData:getGridEnties()) do if entity:canChangeInfo() and entity:getElementType() ~= elementType then - self.changeElementTypeMap[entity] = elementType - count = count - 1 - if count <= 0 then - break - end + table.insert(self.changeElementTypeList, entity) + listCount = listCount + 1 end end + count = math.min(count, listCount) + for i = 1, count do + if listCount <= 0 then + break + end + local index = math.random(1, listCount) + self.changeElementTypeList[index], self.changeElementTypeList[listCount] = self.changeElementTypeList[listCount], self.changeElementTypeList[index] + local entity = table.remove(self.changeElementTypeList) + listCount = listCount - 1 + self.changeElementTypeMap[entity] = elementType + end + self:changeElementTypeByMap(self.changeElementTypeMap) end diff --git a/lua/app/module/battle/skill/battle_grid_effect_handle.lua b/lua/app/module/battle/skill/battle_grid_effect_handle.lua index 189fc3fd..60b7af14 100644 --- a/lua/app/module/battle/skill/battle_grid_effect_handle.lua +++ b/lua/app/module/battle/skill/battle_grid_effect_handle.lua @@ -95,12 +95,58 @@ local function _rewardBox(entity, gridEntities, battleController, onlyCheck) return true end +local function _crossMoveNotBreak(entity, gridEntities, battleController, onlyCheck) + if onlyCheck then + return + end + + if battleController.lastRoundBreakedGridType[entity:getGridType()] then + return + end + + -- 计算所有的蛇 + local allSnake = {} + for posId, entity in pairs(gridEntities) do + if entity:getEffectType() == BattleConst.GRID_EFFECT_TYPE.CROSS_MOVE_NOT_BREAK then + table.insert(allSnake, entity) + end + end + + if not allSnake[1] then + return + end + + local map = {} + local succ = false + for _, entity in ipairs(allSnake) do + local tempList = BattleConst.UP_DOWN_LEFT_RIGHT[entity:getPosId()] + if tempList then + tempList = table.shuffle(GFunc.getTable(tempList)) + for _, posId in ipairs(tempList) do + local gridEntity = gridEntities[posId] + if gridEntity:isEmptyIdle() and not map[posId] then + map[entity:getPosId()] = entity + map[posId] = gridEntity + battleController.battleData:exchangeGridEntities(entity:getPosId(), posId) + succ = true + break + end + end + end + end + if succ then + battleController.battleUI:moveGridCells(map) + end + return succ +end + BattleGridEffectHandle._gridEffectOn = { [GRID_EFFECT_TYPE.DIRECTION_ELIMINATION] = _directionElinination, [GRID_EFFECT_TYPE.CROSS_SPREAD] = _crossSpread, [GRID_EFFECT_TYPE.SELECT_COMMON_SKILL] = _selectCommonSkill, [GRID_EFFECT_TYPE.REWARD_BOX] = _rewardBox, [GRID_EFFECT_TYPE.CROSS_SPREAD_NOT_BREAK] = _crossSpreadNotBreak, + [GRID_EFFECT_TYPE.CROSS_MOVE_NOT_BREAK] = _crossMoveNotBreak, } function BattleGridEffectHandle.gridEffectOn(posId, gridEntities, triggerType, battleController, onlyCheck) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 9a558fa6..ae343a38 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -1136,6 +1136,35 @@ function BattleUI:showGridEffectSfx(posId, sfxName, callback, customTime, zEuler end) end +function BattleUI:moveGridCells(gridEntityList, callback) + if not gridEntityList then + if callback then + callback() + end + end + + if self.moveGridCellsSeq then + self.moveGridCellsSeq:Kill() + self.moveGridCellsSeq = nil + end + + self.moveGridCellsSeq = self.root:createBindTweenSequence() + for _, entity in pairs(gridEntityList) do + local posId = entity:getPosId() + local baseObject = entity:getCell():getBaseObject() + local pos = ModuleManager.BattleManager:getPosInfo(posId) + if entity:getEffectType() then + baseObject:getTransform():SetAsLastSibling() + end + self.moveGridCellsSeq:Insert(0, baseObject:getTransform():DOLocalMove(pos, 1)) + end + self.moveGridCellsSeq:AppendCallback(function() + if callback then + callback() + end + end) +end + function BattleUI:generateSkillAni(map, callback) if table.nums(map) <= 0 then if callback then @@ -2357,6 +2386,11 @@ function BattleUI:clear() self.bossEnterAniSeq:Kill() self.bossEnterAniSeq = nil end + + if self.moveGridCellsSeq then + self.moveGridCellsSeq:Kill() + self.moveGridCellsSeq = nil + end end return BattleUI \ No newline at end of file