From 4605282d53c010e593ee590570f75e2a2e748703 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Tue, 16 May 2023 19:13:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=9C=E7=A2=8D=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/config/grid_type.lua | 110 ++++++- lua/app/config/hero.lua | 10 +- lua/app/config/mall_daily.lua | 100 +++---- lua/app/module/battle/battle_const.lua | 16 +- lua/app/module/battle/battle_manager.lua | 28 ++ .../battle/controller/battle_controller.lua | 273 +++++++++++------- .../skill/battle_grid_effect_handle.lua | 56 ++++ .../skill/battle_grid_effect_handle.lua.meta | 10 + lua/app/ui/battle/battle_ui.lua | 90 ++++-- lua/app/ui/battle/cell/grid_cell.lua | 2 +- .../userdata/battle/battle_grid_entity.lua | 47 ++- 11 files changed, 530 insertions(+), 212 deletions(-) create mode 100644 lua/app/module/battle/skill/battle_grid_effect_handle.lua create mode 100644 lua/app/module/battle/skill/battle_grid_effect_handle.lua.meta diff --git a/lua/app/config/grid_type.lua b/lua/app/config/grid_type.lua index 4c35925e..bd9e75b2 100644 --- a/lua/app/config/grid_type.lua +++ b/lua/app/config/grid_type.lua @@ -4,7 +4,6 @@ local grid_type = { }, [1]={ ["icon"]="battle_hinder_4", - ["can_fall"]=0, ["cant_link"]=1, ["element_invalid"]=1 }, @@ -27,7 +26,7 @@ local grid_type = { 1, 3 }, - ["break_count"]=2, + ["break_count"]=1, ["cant_link"]=1, ["element_invalid"]=1, ["break_sfx"]="sfx_piece_za_b01" @@ -39,7 +38,7 @@ local grid_type = { 2, 3 }, - ["break_count"]=2, + ["break_count"]=1, ["break_sfx"]="sfx_piece_za_b03" }, [5]={ @@ -55,12 +54,113 @@ local grid_type = { ["break_sfx"]="sfx_piece_za_b02" }, [6]={ - ["icon"]="ice", + ["icon"]="lock", ["can_fall"]=1, ["cant_link"]=1 + }, + [7]={ + ["icon"]="stone_3", + ["next_type"]=3, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["cant_link"]=1, + ["element_invalid"]=1, + ["break_sfx"]="sfx_piece_za_b01" + }, + [8]={ + ["icon"]="rocket_up", + ["next_type"]=0, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["cant_link"]=1, + ["element_invalid"]=1, + ["effect"]=1, + ["effect_params"]={ + 1 + }, + ["effect_trigger"]=2 + }, + [9]={ + ["icon"]="rocket_down", + ["next_type"]=0, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["cant_link"]=1, + ["element_invalid"]=1, + ["effect"]=1, + ["effect_params"]={ + 2 + }, + ["effect_trigger"]=2 + }, + [10]={ + ["icon"]="rocket_left", + ["next_type"]=0, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["cant_link"]=1, + ["element_invalid"]=1, + ["effect"]=1, + ["effect_params"]={ + 3 + }, + ["effect_trigger"]=2 + }, + [11]={ + ["icon"]="rocket_right", + ["next_type"]=0, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["cant_link"]=1, + ["element_invalid"]=1, + ["effect"]=1, + ["effect_params"]={ + 4 + }, + ["effect_trigger"]=2 + }, + [12]={ + ["icon"]="leaf", + ["next_type"]=0, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["break_stay_element"]=1, + ["can_fall"]=1, + ["cant_link"]=1 + }, + [13]={ + ["icon"]="jelly", + ["next_type"]=0, + ["break_condition"]={ + 1, + 3 + }, + ["break_count"]=1, + ["break_stay_element"]=1, + ["cant_link"]=1, + ["effect"]=2, + ["effect_trigger"]=1 } } local config = { -data=grid_type,count=7 +data=grid_type,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/hero.lua b/lua/app/config/hero.lua index 84bcefec..d8645200 100644 --- a/lua/app/config/hero.lua +++ b/lua/app/config/hero.lua @@ -52,7 +52,7 @@ local hero = { ["model_id"]="p0005", ["icon"]="5", ["item_id"]=12001, - ["unlock_chapter"]=1 + ["unlock_chapter"]=0 }, [22001]={ ["position"]=2, @@ -162,7 +162,7 @@ local hero = { ["model_id"]="p0007", ["icon"]="7", ["item_id"]=23001, - ["unlock_chapter"]=6 + ["unlock_chapter"]=0 }, [32001]={ ["position"]=3, @@ -272,7 +272,7 @@ local hero = { ["model_id"]="p0006", ["icon"]="6", ["item_id"]=33001, - ["unlock_chapter"]=8 + ["unlock_chapter"]=0 }, [42001]={ ["position"]=4, @@ -382,7 +382,7 @@ local hero = { ["model_id"]="p0008", ["icon"]="8", ["item_id"]=43001, - ["unlock_chapter"]=4 + ["unlock_chapter"]=0 }, [52001]={ ["position"]=5, @@ -437,7 +437,7 @@ local hero = { ["model_id"]="p0004", ["icon"]="4", ["item_id"]=52001, - ["unlock_chapter"]=2 + ["unlock_chapter"]=0 } } local config = { diff --git a/lua/app/config/mall_daily.lua b/lua/app/config/mall_daily.lua index 0a226e9a..191c6ae4 100644 --- a/lua/app/config/mall_daily.lua +++ b/lua/app/config/mall_daily.lua @@ -26,64 +26,64 @@ local mall_daily = { [2]={ ["good"]={ { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=12001, ["id_for_nothing"]="VwpcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=22001, ["id_for_nothing"]="VApcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=23001, ["id_for_nothing"]="VAtcA2Q=", ["num"]=4, ["num_for_nothing"]="Ug==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=32001, ["id_for_nothing"]="VQpcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=33001, ["id_for_nothing"]="VQtcA2Q=", ["num"]=4, ["num_for_nothing"]="Ug==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=42001, ["id_for_nothing"]="UgpcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=43001, ["id_for_nothing"]="UgtcA2Q=", ["num"]=4, ["num_for_nothing"]="Ug==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=52001, ["id_for_nothing"]="UwpcA2Q=", ["num"]=10, @@ -170,64 +170,64 @@ local mall_daily = { [3]={ ["good"]={ { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=12001, ["id_for_nothing"]="VwpcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=22001, ["id_for_nothing"]="VApcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=23001, ["id_for_nothing"]="VAtcA2Q=", ["num"]=4, ["num_for_nothing"]="Ug==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=32001, ["id_for_nothing"]="VQpcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=33001, ["id_for_nothing"]="VQtcA2Q=", ["num"]=4, ["num_for_nothing"]="Ug==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=42001, ["id_for_nothing"]="UgpcA2Q=", ["num"]=10, ["num_for_nothing"]="Vwg=" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=43001, ["id_for_nothing"]="UgtcA2Q=", ["num"]=4, ["num_for_nothing"]="Ug==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=52001, ["id_for_nothing"]="UwpcA2Q=", ["num"]=10, @@ -314,24 +314,24 @@ local mall_daily = { [4]={ ["good"]={ { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=23001, ["id_for_nothing"]="VAtcA2Q=", ["num"]=5, ["num_for_nothing"]="Uw==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=33001, ["id_for_nothing"]="VQtcA2Q=", ["num"]=5, ["num_for_nothing"]="Uw==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=43001, ["id_for_nothing"]="UgtcA2Q=", ["num"]=5, @@ -373,24 +373,24 @@ local mall_daily = { [5]={ ["good"]={ { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=23001, ["id_for_nothing"]="VAtcA2Q=", ["num"]=5, ["num_for_nothing"]="Uw==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=33001, ["id_for_nothing"]="VQtcA2Q=", ["num"]=5, ["num_for_nothing"]="Uw==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=43001, ["id_for_nothing"]="UgtcA2Q=", ["num"]=5, @@ -432,24 +432,24 @@ local mall_daily = { [6]={ ["good"]={ { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=23001, ["id_for_nothing"]="VAtcA2Q=", ["num"]=5, ["num_for_nothing"]="Uw==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=33001, ["id_for_nothing"]="VQtcA2Q=", ["num"]=5, ["num_for_nothing"]="Uw==" }, { - ["type"]=2, - ["type_for_nothing"]="VA==", + ["type"]=1, + ["type_for_nothing"]="Vw==", ["id"]=43001, ["id_for_nothing"]="UgtcA2Q=", ["num"]=5, diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 9db3ddd0..8404962f 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -47,6 +47,9 @@ BattleConst.RECOVER_HP_INTERVAL = 0.2 BattleConst.RECOVER_HP_PERCENT = 333 BattleConst.EFFECT_NUMBER_DELAY = 0.2 BattleConst.MAX_CACHE_SKILL_COUNT = 3 +BattleConst.SKILL_ELIMINATION_TIME = 0.5 +BattleConst.ELIMINATION_INTERVAL = 0.01 +BattleConst.GRID_BREAK_EFFECT_INTERVAL = 0.1 BattleConst.BATTLE_ROUND_STEP = { WAIT_BEGIN = 0, -- 等待开始 @@ -361,14 +364,25 @@ BattleConst.GRID_TYPE = { VINES = 4, ICE = 5, LOCK = 6, + JELLY = 13, } BattleConst.GRID_BREAK_CONDITION = { - ACOUND = 1, + AROUND = 1, LINE = 2, SKILL = 3, } +BattleConst.GRID_EFFECT_TYPE = { + DIRECTION_ELIMINATION = 1, + CROSS_SPREAD = 2, +} + +BattleConst.GRID_EFFECT_TRIGGER_TYPE = { + ON_ROUND_BEGIN = 1, + ON_GRID_BREAK = 2, +} + ---- 元素类型 BattleConst.ELEMENT_TYPE = { NONE = 0, diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index 5eed3db4..cc4328c2 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -271,6 +271,34 @@ function BattleManager:getPosCenterAndDir(pos1, pos2) return centerPos, zEuler end +function BattleManager:getPosIdsByDirection(posId, direction) + local rc = self:getPosRC(posId) + local list = {} + if direction == BattleConst.BOARD_RANGE_TYPE.UP then + for r = rc.r, 1, -1 do + local id = self:getPosId(r, rc.c) + table.insert(list, id) + end + elseif direction == BattleConst.BOARD_RANGE_TYPE.DOWN then + for r = rc.r, BattleConst.ROW_COUNT do + local id = self:getPosId(r, rc.c) + table.insert(list, id) + end + elseif direction == BattleConst.BOARD_RANGE_TYPE.LEFT then + for c = rc.c, 1, -1 do + local id = self:getPosId(rc.r, c) + table.insert(list, id) + end + elseif direction == BattleConst.BOARD_RANGE_TYPE.RIGHT then + for c = rc.c, BattleConst.COLUMN_COUNT do + local id = self:getPosId(rc.r, c) + table.insert(list, id) + end + end + + return list +end + ----------------------- end 一些公共相关的方法 ----------------------------- function BattleManager:bindBattleUnitAttribute(hashCode, side) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 741f4c4f..5aaf1135 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -8,6 +8,7 @@ local BattleController = class("BattleController") local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle" local BATTLE_ROGUE_SKILL_HANDLE = require "app/module/battle/skill/battle_rogue_skill_handle" +local BATTLE_GRID_EFFECT_HANDLE = require "app/module/battle/skill/battle_grid_effect_handle" local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle" local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT @@ -144,8 +145,6 @@ function BattleController:onLinkChange() entity:getCell():showAni() end end - - self:setGridBreakCondition(boomGridIds, info.posId, GRID_BREAK_CONDITION.LINE) end for posId, cell in pairs(needFalsePosMap) do @@ -158,24 +157,10 @@ function BattleController:onLinkChange() if entity:getCell() then entity:getCell():showCircle(true) end - self:setGridBreakCondition(boomGridIds, info.posId, GRID_BREAK_CONDITION.SKILL) end end - local elementTypeMap = {} - for posId, boomTypes in pairs(boomGridIds) do - local entity = self.battleData:getGridEntity(posId) - if entity then - local elementTypeInvalid = entity:isElmentTypeInvalid() - local breaked, isIdle = entity:tryBreakGrid(boomTypes, true) - if isIdle then - if not entity:getSkillId() and not elementTypeInvalid then - local elementType = entity:getElementType() - elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 - end - end - end - end + local aniSequence, influenceElementType, lineCount, elementTypeMap, linkElementType = self:calculateCurElimination() self.battleUI:refreshSkill(elementTypeMap, count > 0) if mainElementType then @@ -464,6 +449,19 @@ end function BattleController:enterRoundBegin() self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_BEGIN + + local gridEntities = self.battleData:getGridEnties() + local effectGrid = {} + for posId, entity in pairs(gridEntities) do + if entity:getEffectType() then + table.insert(effectGrid, posId) + end + end + + for _, posId in ipairs(effectGrid) do + BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(posId, gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_ROUND_BEGIN, self) + end + self:enterEliminationBegin() end @@ -878,35 +876,147 @@ function BattleController:onLinkOver() local skillId = self.battleData:getSequenceHadSkill() local skillEntity - local linkElementType - local influenceElementType if skillId then skillEntity = self.battleData:getSkillEntityBySkillId(skillId) end - local elementTypeMap = {} + local aniSequence, influenceElementTypeMap, lineCount, elementTypeMap, linkElementType, effectGridMap = self:calculateCurElimination() + + self.battleData:addSkillEnergy(elementTypeMap) + self.battleData:clearGridSequence() + self.battleUI:disableUITouch() + self.battleUI:eliminationAni(aniSequence, effectGridMap, function() + self:generateInstructions(skillEntity, linkElementType, lineCount, influenceElementTypeMap, elementTypeMap) + self:enterRefreshBoard() + end) + + self.eliminateCount = self.eliminateCount + 1 + self.eliminateTotalCount = self.eliminateTotalCount + 1 +end + +function BattleController:calculateCurElimination() + local sequence = self.battleData:getGridSequence() + local skillId = self.battleData:getSequenceHadSkill() + local skillEntity + if skillId then + skillEntity = self.battleData:getSkillEntityBySkillId(skillId) + end + local breakedMap = {} local boomGridIds = {} - local lineCount = 0 + local sequenceMap = {} + for idx, info in ipairs(sequence) do + sequenceMap[info.posId] = idx + end - local skillPosId - local randomPosList - for _, info in ipairs(sequence) do - local entity = self.battleData:getGridEntity(info.posId) - if entity:getSkillId() then - skillPosId = info.posId - else - linkElementType = entity:getElementType() - end - self:setGridBreakCondition(boomGridIds, info.posId, GRID_BREAK_CONDITION.LINE) + local time = 0 + local skillTime = BattleConst.SKILL_ELIMINATION_TIME + local aniSequence = {} + for idx, info in ipairs(sequence) do + local posId = info.posId + self:dealGridBreak(posId, GRID_BREAK_CONDITION.LINE, time, breakedMap, sequenceMap, aniSequence, boomGridIds) + time = time + BattleConst.ELIMINATION_INTERVAL + end - local outline = BattleConst.UP_DOWN_LEFT_RIGHT[info.posId] - for _, aroundPosId in ipairs(outline) do - self:setGridBreakCondition(boomGridIds, aroundPosId, GRID_BREAK_CONDITION.ACOUND) + local randomPosList, influenceElementTypeMap + for i, info in ipairs(aniSequence) do + if info.isSkill then + randomPosList, influenceElementTypeMap = self:dealSkillElement(info.timeIdx + skillTime, breakedMap, sequenceMap, aniSequence, boomGridIds) + local aniUnit = aniSequence[i] + aniUnit.rangeList = skillEntity:getBoardRange() + aniUnit.randomPosList = randomPosList + break end end - sequence = {} + local lineCount = 0 + local elementTypeMap = {} + local linkElementType + local gridEntities = self.battleData:getGridEnties() + local effectGridMap = {} + for _, info in ipairs(aniSequence) do + local entity = gridEntities[info.posId] + local elementType = entity:getElementType() + if not info.noAni and info.isIdle then + elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 + if boomGridIds[info.posId] and boomGridIds[info.posId][GRID_BREAK_CONDITION.LINE] then + lineCount = lineCount + 1 + if not info.isSkill then + linkElementType = elementType + end + end + end + if entity:getEffectType() and info.isIdle then + effectGridMap[info.posId] = true + end + end + return aniSequence, influenceElementTypeMap, lineCount, elementTypeMap, linkElementType, effectGridMap +end + +function BattleController:dealGridBreak(posId, condition, time, breakedMap, sequenceMap, aniSequence, gridMap) + self:setGridBreakCondition(gridMap, posId, condition) + if breakedMap[posId] or (sequenceMap[posId] and condition ~= GRID_BREAK_CONDITION.LINE) then + return + end + + local gridEntities = self.battleData:getGridEnties() + local entity = gridEntities[posId] + local breaked, isIdle = entity:tryBreakGrid(condition, true) + local aniUnit = self:getEliminattionAniInfo(posId, time) + aniUnit.noAni = entity:isElmentTypeInvalid() + aniUnit.isIdle = isIdle + if entity:getSkillId() then + aniUnit.isSkill = true + end + + if breaked then + breakedMap[posId] = true + + aniUnit.breakSfxName = entity:getBreakSfx() + aniUnit.callback = function() + entity:tryBreakGrid(condition) + end + + table.insert(aniSequence, aniUnit) + else + if entity:canBreakByThisCondition(condition) then + breakedMap[posId] = true + aniUnit.callback = function() + entity:tryBreakGrid(condition) + end + table.insert(aniSequence, aniUnit) + end + end + + if isIdle then + if condition == GRID_BREAK_CONDITION.LINE then + local outline = BattleConst.UP_DOWN_LEFT_RIGHT[posId] + for _, id in ipairs(outline) do + self:dealGridBreak(id, GRID_BREAK_CONDITION.AROUND, time, breakedMap, sequenceMap, aniSequence, gridMap) + end + end + if entity:getEffectType() then + local list = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(posId, gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_GRID_BREAK, self) + if list then + aniUnit.aniPosList = {} + aniUnit.overCallback = aniUnit.callback + aniUnit.callback = nil + for index, id in ipairs(list) do + if id ~= posId then + self:dealGridBreak(id, GRID_BREAK_CONDITION.SKILL, time + BattleConst.GRID_BREAK_EFFECT_INTERVAL * index, breakedMap, sequenceMap, aniSequence, gridMap) + table.insert(aniUnit.aniPosList, id) + end + end + end + end + end + + return isIdle +end + +function BattleController:dealSkillElement(time, breakedMap, sequenceMap, aniSequence, boomGridIds) + local randomPosList + local influenceElementTypeMap = {} for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do local entity = self.battleData:getGridEntity(posId) if not entity:getIsIdle() then @@ -917,96 +1027,41 @@ function BattleController:onLinkOver() end table.insert(randomPosList, posId) end + influenceElementTypeMap[entity:getElementType()] = (influenceElementTypeMap[entity:getElementType()] or 0) + 1 end - self:setGridBreakCondition(boomGridIds, posId, GRID_BREAK_CONDITION.SKILL) + self:dealGridBreak(posId, GRID_BREAK_CONDITION.SKILL, time, breakedMap, sequenceMap, aniSequence, boomGridIds) end end - local gridBreakSfxInfo - for posId, boomTypes in pairs(boomGridIds) do - local entity = self.battleData:getGridEntity(posId) - if entity then - local breakSfxName = entity:getBreakSfx() - local elementTypeInvalid = entity:isElmentTypeInvalid() - local breaked, isIdle = entity:tryBreakGrid(boomTypes) - if breaked then - if breakSfxName then - if not gridBreakSfxInfo then - gridBreakSfxInfo = {} - end - if not gridBreakSfxInfo[breakSfxName] then - gridBreakSfxInfo[breakSfxName] = {} - end - table.insert(gridBreakSfxInfo[breakSfxName], posId) - end - end - if isIdle 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 + return randomPosList, influenceElementTypeMap +end - if not entity:getSkillId() then - if boomTypes[GRID_BREAK_CONDITION.SKILL] then - local elementType = entity:getElementType() - if not influenceElementType then - influenceElementType = {} - end - influenceElementType[elementType] = true - end - - if boomTypes[GRID_BREAK_CONDITION.LINE] then - lineCount = lineCount + 1 - end - end - end - end - end - - ---- 播放碎裂特效 - if gridBreakSfxInfo then - for breakSfxName, list in pairs(gridBreakSfxInfo) do - for index, posId in ipairs(list) do - self.battleUI:getSfxGridBreak(breakSfxName, index, function(obj) - local pos = ModuleManager.BattleManager:getPosInfo(posId) - obj:setLocalScale(38, 38, 38) - obj:setLocalPosition(pos.x, pos.y, 0) - obj:play() - end) - end - end - end - - if skillPosId then - local rangeList = skillEntity:getBoardRange() - self.battleUI:playSkillLineSfx(skillPosId, rangeList, randomPosList) - end - - self.battleData:addSkillEnergy(elementTypeMap) - self.battleData:clearGridSequence() - - self.battleUI:disableUITouch() - self.battleUI:eliminationAni(sequence, function() - self:generateInstructions(skillEntity, linkElementType, lineCount, influenceElementType, elementTypeMap) - self:enterRefreshBoard() - end) - - self.eliminateCount = self.eliminateCount + 1 - self.eliminateTotalCount = self.eliminateTotalCount + 1 +function BattleController:getEliminattionAniInfo(posId, timeIdx) + return { + posId = posId, + noAni = nil, + aniPosList = nil, + breakSfxName = nil, + timeIdx = timeIdx, + conditions = nil, + isSkill = false, + isIdle = false, + callback = nil, + overCallback = nil, + } end function BattleController:setGridBreakCondition(gridMap, posId, condition) if not gridMap[posId] then gridMap[posId] = {} gridMap[posId][condition] = true - return true + return true, true end if gridMap[posId][condition] then return false end gridMap[posId][condition] = true - return true + return true, false end function BattleController:fillBoard(isRoundBeginCheck) diff --git a/lua/app/module/battle/skill/battle_grid_effect_handle.lua b/lua/app/module/battle/skill/battle_grid_effect_handle.lua new file mode 100644 index 00000000..e8167800 --- /dev/null +++ b/lua/app/module/battle/skill/battle_grid_effect_handle.lua @@ -0,0 +1,56 @@ +local BattleConst = require "app/module/battle/battle_const" + +local BattleGridEffectHandle = {} + +local GRID_EFFECT_TYPE = BattleConst.GRID_EFFECT_TYPE +local GRID_BREAK_CONDITION = BattleConst.GRID_BREAK_CONDITION + +local function _directionElinination(entity, gridEntities, battleController) + local effectParams = entity:getEffectParams() + if not effectParams then + return + end + local direction = effectParams[1] + local list = ModuleManager.BattleManager:getPosIdsByDirection(entity:getPosId(), direction) + return list +end + +local function _crossSpread(entity, gridEntities, battleController) + local tempList = BattleConst.UP_DOWN_LEFT_RIGHT[entity:getPosId()] + if not tempList then + return + end + + for _, posId in ipairs(tempList) do + local gridEntity = gridEntities[posId] + if gridEntity:isEmptyIdle() then + battleController.battleData:setGridType(posId, BattleConst.GRID_TYPE.JELLY) + end + end + + local list = GFunc.getTable(tempList) + return list +end + +BattleGridEffectHandle._gridEffectOn = { + [GRID_EFFECT_TYPE.DIRECTION_ELIMINATION] = _directionElinination, + [GRID_EFFECT_TYPE.CROSS_SPREAD] = _crossSpread, +} + +function BattleGridEffectHandle.gridEffectOn(posId, gridEntities, triggerType, battleController) + local entity = gridEntities[posId] + local effectType = entity:getEffectType() + if not effectType then + return + end + if entity:getEffectTrigger() ~= triggerType then + return + end + + local func = BattleGridEffectHandle._gridEffectOn[effectType] + if func then + return func(entity, gridEntities, battleController) + end +end + +return BattleGridEffectHandle \ No newline at end of file diff --git a/lua/app/module/battle/skill/battle_grid_effect_handle.lua.meta b/lua/app/module/battle/skill/battle_grid_effect_handle.lua.meta new file mode 100644 index 00000000..10f98460 --- /dev/null +++ b/lua/app/module/battle/skill/battle_grid_effect_handle.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8a7948a2aa6fe264086e695e9670b6f9 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 1646bad7..a4219a13 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -821,9 +821,9 @@ function BattleUI:refreshBoard() end end -function BattleUI:eliminationAni(sequence, callback) +function BattleUI:eliminationAni(aniSequence, effectGridMap, callback) self:showMask(true) - if not sequence then + if not aniSequence then if callback then callback() end @@ -847,36 +847,92 @@ function BattleUI:eliminationAni(sequence, callback) self.posIdMap = {} end - for index, info in ipairs(sequence) do + local breakSfxNameIndexMap = {} + for index, info in ipairs(aniSequence) do if not self.posIdMap[info.posId] then local pos = ModuleManager.BattleManager:getPosInfo(info.posId) self.posIdMap[info.posId] = true local entity = DataManager.BattleData:getGridEntity(info.posId) + local time = info.timeIdx if entity and entity:getCell() then entity:getCell():refresh(entity) - local baseObject = entity:getCell():getBaseObject() - baseObject:getTransform():SetAsLastSibling() - if info.noAni then - baseObject:setAnchoredPositionX(DEFAULT_X) - else - if entity:getSkillId() then - entity:getCell():hideSkillSfx() - end - self.eliminationAniSeq:Insert(index * 0.01, baseObject:getTransform():DOScale(1.3, 0.1)) - self.eliminationAniSeq:InsertCallback(index * 0.01 + 0.2, function() - self:getSfxSmoke(index, function(obj) - obj:setAnchoredPosition(pos.x, pos.y) + + if info.callback then + self.eliminationAniSeq:InsertCallback(time, function() + if info.callback then + info.callback() + end + end) + end + + if info.breakSfxName then + breakSfxNameIndexMap[info.breakSfxName] = (breakSfxNameIndexMap[info.breakSfxName] or 0) + 1 + self.eliminationAniSeq:InsertCallback(time, function() + self:getSfxGridBreak(info.breakSfxName, breakSfxNameIndexMap[info.breakSfxName], function(obj) + local pos = ModuleManager.BattleManager:getPosInfo(info.posId) + obj:setLocalScale(38, 38, 38) + obj:setLocalPosition(pos.x, pos.y, 0) obj:play() end) end) - self.eliminationAniSeq:Insert(index * 0.01 + 0.2, baseObject:getTransform():DOAnchorPos(self:getElementSkillPos(entity:getElementType()), 0.3)) - self.eliminationAniSeq:Insert(index * 0.01 + 0.2, baseObject:getTransform():DOScale(0.5, 0.3)) + end + + if info.isIdle then + if entity:getSkillId() then + entity:getCell():hideSkillSfx() + end + local baseObject = entity:getCell():getBaseObject() + baseObject:getTransform():SetAsLastSibling() + if info.aniPosList then + local posList = {} + local count = 0 + for _, posId in ipairs(info.aniPosList) do + table.insert(posList, ModuleManager.BattleManager:getPosInfo(posId)) + count = count + 1 + end + local anitime = count * GConst.BattleConst.GRID_BREAK_EFFECT_INTERVAL + self.eliminationAniSeq:Insert(time, baseObject:getTransform():DOLocalPath(posList, anitime):SetEase(CS.DG.Tweening.Ease.Linear)) + + if info.overCallback then + self.eliminationAniSeq:InsertCallback(time + anitime, function() + if info.noAni then + baseObject:setAnchoredPositionX(DEFAULT_X) + end + info.overCallback() + end) + end + else + if info.noAni then + baseObject:setAnchoredPositionX(DEFAULT_X) + else + if info.rangeList then + self.eliminationAniSeq:InsertCallback(time, function() + self:playSkillLineSfx(info.posId, info.rangeList, info.randomPosList) + end) + end + self.eliminationAniSeq:Insert(time, baseObject:getTransform():DOScale(1.3, 0.1)) + self.eliminationAniSeq:InsertCallback(time + 0.2, function() + self:getSfxSmoke(index, function(obj) + obj:setAnchoredPosition(pos.x, pos.y) + obj:play() + end) + end) + self.eliminationAniSeq:Insert(time + 0.2, baseObject:getTransform():DOAnchorPos(self:getElementSkillPos(entity:getElementType()), 0.3)) + self.eliminationAniSeq:Insert(time + 0.2, baseObject:getTransform():DOScale(0.5, 0.3)) + end + end end end end end + for posId, _ in pairs(effectGridMap) do + local entity = DataManager.BattleData:getGridEntity(posId) + local baseObject = entity:getCell():getBaseObject() + baseObject:getTransform():SetAsLastSibling() + end + self.eliminationAniSeq:AppendCallback(function() for posId, _ in pairs(self.posIdMap) do local entity = DataManager.BattleData:getGridEntity(posId) diff --git a/lua/app/ui/battle/cell/grid_cell.lua b/lua/app/ui/battle/cell/grid_cell.lua index 0a8528cd..045a8ac0 100644 --- a/lua/app/ui/battle/cell/grid_cell.lua +++ b/lua/app/ui/battle/cell/grid_cell.lua @@ -11,7 +11,7 @@ function GridCell:refresh(gridEntity, curElement, skillPosId) local atlas, icon = ModuleManager.BattleManager:getElementIcon(elementType) elementIcon:setSprite(atlas, icon) end - elementIcon:setVisible(true) + elementIcon:setVisible(not gridEntity:isElmentTypeInvalid()) local showMask = false if curElement and (curElement ~= elementType or not gridEntity:canLink()) then diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index 5f4ebffa..1a40c8c3 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -90,7 +90,7 @@ function BattleGridEntity:isElmentTypeInvalid() end ---- 返回值1为true, 返回值2为是否为idle状态;返回值1为false时,没有返回值2 -function BattleGridEntity:tryBreakGrid(boomTypes, onlyCheck) +function BattleGridEntity:tryBreakGrid(condition, onlyCheck) if self:getIsIdle() then if not onlyCheck then self:setGridType(BattleConst.GRID_TYPE.EMPTY) @@ -98,15 +98,9 @@ function BattleGridEntity:tryBreakGrid(boomTypes, onlyCheck) return false end local nextGridType = self:getNextGridType() + local isIdle = false if nextGridType then - local canbreak = false - for boomType, _ in pairs(boomTypes) do - if self:canBreakByThisCondition(boomType) then - canbreak = true - break - end - end - if not canbreak then + if not self:canBreakByThisCondition(condition) then return false end @@ -120,7 +114,7 @@ function BattleGridEntity:tryBreakGrid(boomTypes, onlyCheck) local breakStayElement = self:getBreakStayElement() self:setGridType(nextGridType) if nextGridType == BattleConst.GRID_TYPE.EMPTY and not breakStayElement then - self:setIsIdle(true) + isIdle = true end else if self:getBreakCount() + 1 < self:getCfgBreakCount() then @@ -129,36 +123,29 @@ function BattleGridEntity:tryBreakGrid(boomTypes, onlyCheck) local breakStayElement = self:getBreakStayElement() if nextGridType == BattleConst.GRID_TYPE.EMPTY and not breakStayElement then - return true, true - else - return true, false + isIdle = true end end else if self:getSkillId() then - if boomTypes[BattleConst.GRID_BREAK_CONDITION.LINE] then -- 技能破碎逻辑为,链接消除 - if not onlyCheck then - self:setIsIdle(true) - end + if condition == BattleConst.GRID_BREAK_CONDITION.LINE then -- 技能破碎逻辑为,链接消除 + isIdle = true else return false end else - if self:isEmptyIdle() and (boomTypes[BattleConst.GRID_BREAK_CONDITION.LINE] or boomTypes[BattleConst.GRID_BREAK_CONDITION.SKILL]) then -- 空类型/带技能破碎逻辑为,链接消除 置为闲置即消除 - if not onlyCheck then - self:setIsIdle(true) - end + if self:isEmptyIdle() and (condition == BattleConst.GRID_BREAK_CONDITION.LINE or condition == BattleConst.GRID_BREAK_CONDITION.SKILL) then -- 空类型/带技能破碎逻辑为,链接消除 置为闲置即消除 + isIdle = true else -- 不可破碎类型 return false end end end if not onlyCheck then + self:setIsIdle(isIdle) self:setDirty() - return true, self:getIsIdle() - else - return true, true end + return true, isIdle end function BattleGridEntity:getPos() @@ -387,4 +374,16 @@ function BattleGridEntity:addBreakCount(count) self.breakCount = self.breakCount + count end +function BattleGridEntity:getEffectType() + return self:getGridTypeConfig().effect +end + +function BattleGridEntity:getEffectParams() + return self:getGridTypeConfig().effect_params +end + +function BattleGridEntity:getEffectTrigger() + return self:getGridTypeConfig().effect_trigger +end + return BattleGridEntity \ No newline at end of file