diff --git a/lua/app/bf/unity/effect_object.lua b/lua/app/bf/unity/effect_object.lua index 91a7307c..0ab95f9f 100644 --- a/lua/app/bf/unity/effect_object.lua +++ b/lua/app/bf/unity/effect_object.lua @@ -34,6 +34,18 @@ function EffectObject:play() self.effectHelper:Play() end +function EffectObject:playComplete(complete, customTime) + self.effectHelper:Play() + local duration = customTime or self:getDuration() + if self.playCompleteSeq then + self.playCompleteSeq:Kill() + self.playCompleteSeq = nil + end + self.playCompleteSeq = self:createBindTweenSequence() + self.playCompleteSeq:AppendInterval(duration) + self.playCompleteSeq:AppendCallback(complete) +end + -- 延迟播放 function EffectObject:playDelay(delayTime, hideBeforePlay) if delayTime <= 0 then 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 e148bbc6..16166bb4 100644 --- a/lua/app/module/battle/skill/battle_grid_effect_handle.lua +++ b/lua/app/module/battle/skill/battle_grid_effect_handle.lua @@ -30,7 +30,13 @@ local function _crossSpread(entity, gridEntities, battleController, onlyCheck) for _, posId in ipairs(tempList) do local gridEntity = gridEntities[posId] if gridEntity:isEmptyIdle() then - battleController.battleData:setGridType(posId, entity:getGridType() or BattleConst.GRID_TYPE.JELLY) + 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 succ = true break end diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 9df084b4..9ec99363 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -1082,6 +1082,22 @@ function BattleUI:dealGridEffectSfx(time, info, breakSfxNameIndexMap, entity) end end +function BattleUI:showGridEffectSfx(posId, sfxName, callback) + self:getSfxGridEffect(sfxName, function(info) + info.isIdle = false + local pos = ModuleManager.BattleManager:getPosInfo(posId) + info.obj:setLocalPosition(pos.x, pos.y, 0) + info.obj:setActive(true) + info.obj:playComplete(function() + info.isIdle = true + info.obj:setActive(false) + if callback then + callback() + end + end) + end) +end + function BattleUI:generateSkillAni(map, callback) if table.nums(map) <= 0 then if callback then @@ -1698,6 +1714,39 @@ function BattleUI:resetParentAllSfxGridBreak() end end +function BattleUI:getSfxGridEffect(effectSfxPath, func) + if not effectSfxPath then + return + end + + if not self.root.gridEffectSfx then + self.root.gridEffectSfx = {} + end + if not self.root.gridEffectSfx[effectSfxPath] then + self.root.gridEffectSfx[effectSfxPath] = {} + end + local count = 0 + for index, info in pairs(self.root.gridEffectSfx[effectSfxPath]) do + if info.isIdle then + func(self.root.gridEffectSfx[effectSfxPath][index]) + return + end + count = count + 1 + end + + local index = count + 1 + self.root.gridEffectSfx[effectSfxPath][index] = { + isLoaded = true, + } + EffectManager:loadUIEffectAsync(effectSfxPath, self, self.gridNode, GConst.UI_EFFECT_ORDER.LEVEL5, function(obj) + self.root.gridEffectSfx[effectSfxPath][index].obj = obj + self.root.gridEffectSfx[effectSfxPath][index].isIdle = true + if func then + func(self.root.gridEffectSfx[effectSfxPath][index]) + end + end) +end + function BattleUI:getSfxSmoke(index, func) self.hidingAllSfxSmoke = false @@ -1900,6 +1949,18 @@ function BattleUI:initUISfxs() end end + if self.root.gridEffectSfx then + for breakSfxPath, list in pairs(self.root.gridEffectSfx) do + for index, info in pairs(list) do + if info.obj then + info.obj:setActive(true) + info.obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), GConst.UI_EFFECT_ORDER.LEVEL5) + info.obj:setActive(false) + end + end + end + end + if self.root.lineSfxObjs then for index, info in pairs(self.root.lineSfxObjs) do if info.obj then @@ -2256,6 +2317,11 @@ function BattleUI:clear() self.bossEnterAniSeq:Kill() self.bossEnterAniSeq = nil end + + if self.showGridEffectSfxSid then + self:unscheduleGlobal(self.showGridEffectSfxSid) + self.showGridEffectSfxSid = nil + end end return BattleUI \ No newline at end of file