From 44ff40613542e7dd254e63c9d8c1e68bced17590 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Fri, 2 Jun 2023 22:28:22 +0800 Subject: [PATCH] =?UTF-8?q?boss=E6=9C=BA=E5=88=B6=E6=A3=8B=E7=9B=98?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/bf/unity/effect_object.lua | 12 +- lua/app/module/battle/battle_const.lua | 10 ++ .../battle/controller/battle_controller.lua | 22 ++- .../skill/battle_board_skill_handle.lua | 143 ++++++++++++++---- lua/app/ui/battle/battle_ui.lua | 20 +-- lua/app/ui/battle/cell/grid_cell.lua | 16 ++ 6 files changed, 181 insertions(+), 42 deletions(-) diff --git a/lua/app/bf/unity/effect_object.lua b/lua/app/bf/unity/effect_object.lua index 0ab95f9f..46e123cf 100644 --- a/lua/app/bf/unity/effect_object.lua +++ b/lua/app/bf/unity/effect_object.lua @@ -34,14 +34,22 @@ function EffectObject:play() self.effectHelper:Play() end -function EffectObject:playComplete(complete, customTime) +function EffectObject:playComplete(complete, customTime, customCallback) self.effectHelper:Play() - local duration = customTime or self:getDuration() + local duration = self:getDuration() if self.playCompleteSeq then self.playCompleteSeq:Kill() self.playCompleteSeq = nil end self.playCompleteSeq = self:createBindTweenSequence() + if customTime then + self.playCompleteSeq:AppendInterval(customTime) + self.playCompleteSeq:AppendCallback(customCallback) + duration = duration - customTime + if duration <= 0 then + duration = 0.01 + end + end self.playCompleteSeq:AppendInterval(duration) self.playCompleteSeq:AppendCallback(complete) end diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index de87ed1f..1fab8da2 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -759,6 +759,16 @@ BattleConst.OUTLINE_SFX = { BattleConst.LINE_SFX = "assets/prefabs/effects/battle/sfx_piece_line_b01.prefab" BattleConst.CHANGE_ELEMENT_SFX = "assets/prefabs/effects/battle/sfx_skill_b02.prefab" BattleConst.LINK_SMOKE = "assets/prefabs/effects/battle/sfx_piece_smoke_b01.prefab" +BattleConst.LINK_SMOKE = "assets/prefabs/effects/battle/sfx_piece_smoke_b01.prefab" +BattleConst.GRID_KILL_SFX = { + [BattleConst.ELEMENT_TYPE.RED] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b04.prefab", + [BattleConst.ELEMENT_TYPE.YELLOW] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b05.prefab", + [BattleConst.ELEMENT_TYPE.GREEN] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b02.prefab", + [BattleConst.ELEMENT_TYPE.BLUE] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b01.prefab", + [BattleConst.ELEMENT_TYPE.PURPLE] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b03.prefab", + skill = "assets/prefabs/effects/battle/sfx_piece_skill_posui_b01.prefab", + line = "assets/prefabs/effects/battle/sfx_piece_xiaochu_b01.prefab", +} BattleConst.BATTLE_TASK_FIELD = { SKILL_BOX_OPEN = "skill_box", -- 技能宝箱打开次数(神灯) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 9abc42ea..df5fe867 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -263,6 +263,7 @@ function BattleController:init(params) self.taskProgress = {} self.waveRoundCount = {} self.lastRoundBreakedGridType = {} + self.waitingFillCount = 0 self.chapterId = self:getChapterId() self.waveIndex = 0 @@ -720,7 +721,13 @@ function BattleController:enterRefreshBoard(isRoundBeginCheck, callback) self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_REFRESH_BOARD end self.onFillBoardOverCallback = callback - self:fillBoard(isRoundBeginCheck) + self.isRoundBeginCheck = isRoundBeginCheck + if self.isRoundBeginCheck and self.waitingFillCount > 0 then + self.isWaitingFill = true + return + end + + self:fillBoard(self.isRoundBeginCheck) end function BattleController:enterRoundEnd() @@ -1251,6 +1258,8 @@ function BattleController:fillBoard(isRoundBeginCheck) self.battleUI:fallGrid(self.fillBoardPathMap, isRoundBeginCheck, function() self:onFillBoardOver(isRoundBeginCheck) + self.isRoundBeginCheck = nil + self.isWaitingFill = false end) end @@ -2476,11 +2485,22 @@ function BattleController:getTaskProgress() return self.taskProgress end +function BattleController:addFillWaitingCount() + self.waitingFillCount = self.waitingFillCount + 1 +end + +function BattleController:reduceFillWaitingCount() + self.waitingFillCount = self.waitingFillCount - 1 +end + function BattleController:_tick(dt) self.realTime = self.realTime + dt if self.isPause then return end + if self.waitingFillCount <= 0 and self.isWaitingFill and self.isRoundBeginCheck then + self:fillBoard(self.isRoundBeginCheck) + end self.time = self.time + dt self.atkTeam:tick(dt) self.defTeam:tick(dt) diff --git a/lua/app/module/battle/skill/battle_board_skill_handle.lua b/lua/app/module/battle/skill/battle_board_skill_handle.lua index e93544c1..fd70891a 100644 --- a/lua/app/module/battle/skill/battle_board_skill_handle.lua +++ b/lua/app/module/battle/skill/battle_board_skill_handle.lua @@ -138,15 +138,17 @@ local function _takeRandomKillSkillGrid(atkUnitComp, skillEntity, battleControll end end - if listCount > count then - local removeCount = listCount - count - for i = 1, removeCount do - table.remove(list, math.random(1, listCount)) - listCount = listCount - 1 + -- 处理表现 + for index, posId in ipairs(list) do + if index > count then + break end + battleController.battleUI:showGridEffectSfx(posId, BattleConst.GRID_KILL_SFX.skill, function() + local entity = battleData:getGridEntity(posId) + entity:setIsIdle(true) + battleController.battleUI:removeOneGridOutOfScreen(posId) + end, 0.08) end - - battleController:killGrids(list) end local function _takeShuffleBoard(atkUnitComp, skillEntity, battleController) @@ -168,24 +170,27 @@ local function _takeRandomKillRowOrColumn(atkUnitComp, skillEntity, battleContro if count <= 0 then return end - - local listCount = 0 - local list = {} + local rCount = math.random(0, count) + local cCount = count - rCount local rowMap = {} local columnMap = {} + local rList = {} + local rListCount = 0 + local cList = {} + local cListCount = 0 for posId, entity in pairs(battleData:getGridEnties()) do if entity:isEmptyIdle() then local rc = ModuleManager.BattleManager:getPosRC(posId) local r = rc.r local c = rc.c if not rowMap[r] then - table.insert(list, {r = r}) - listCount = listCount + 1 + table.insert(rList, r) + rListCount = rListCount + 1 rowMap[r] = {} end if not columnMap[c] then - table.insert(list, {c = c}) - listCount = listCount + 1 + table.insert(cList, c) + cListCount = cListCount + 1 columnMap[c] = {} end table.insert(rowMap[r], posId) @@ -194,23 +199,60 @@ local function _takeRandomKillRowOrColumn(atkUnitComp, skillEntity, battleContro end local infoList = {} - for i = 1, count do - if not list[1] then - break - end - local info = table.remove(list, math.random(1, listCount)) - listCount = listCount - 1 - if info.r then - info.posList = rowMap[info.r] - elseif info.c then - info.posList = columnMap[info.c] - end - if info.posList then - table.insert(infoList, info) + rCount = math.min(rCount, rListCount) + cCount = math.min(cCount, cListCount) + for i = 1, rCount do + local r = table.remove(rList, math.random(1, rListCount)) + rListCount = rListCount - 1 + if rowMap[r] then + table.insert(infoList, { + r = true, + centerPos = ModuleManager.BattleManager:getPosId(r, 4), + posList = rowMap[r] + }) end end - battleController:killRowOrColumn(infoList) + for i = 1, cCount do + local c = table.remove(cList, math.random(1, cListCount)) + cListCount = cListCount - 1 + if columnMap[c] then + table.insert(infoList, { + c = true, + centerPos = ModuleManager.BattleManager:getPosId(4, c), + posList = columnMap[c] + }) + end + end + + + local temp_map = {} + -- 处理表现 + for index, info in ipairs(infoList) do + for _, posId in ipairs(info.posList) do + if not temp_map[posId] then + battleController:addFillWaitingCount() + temp_map[posId] = true + end + end + local zEuler = 0 + if info.c then + zEuler = 90 + end + battleController.battleUI:showGridEffectSfx(info.centerPos, BattleConst.GRID_KILL_SFX.line, function() + for _, posId in ipairs(info.posList) do + local entity = battleData:getGridEntity(posId) + entity:setIsIdle(true) + if entity:getCell() then + entity:getCell():doScale(0, 1, function() + battleController:reduceFillWaitingCount() + battleController.battleUI:removeOneGridOutOfScreen(posId) + entity:getCell():hideAni() + end) + end + end + end, 1, zEuler) + end end local function _takeKillMaxElementAndHeal(atkUnitComp, skillEntity, battleController) @@ -254,7 +296,20 @@ local function _takeKillMaxElementAndHeal(atkUnitComp, skillEntity, battleContro local heal = count * effectNum * atkUnitComp.unitEntity:getAtk() // GConst.BattleConst.DEFAULT_FACTOR atkUnitComp:takeDamageOrCure(atkUnitComp, heal, BattleConst.EFFECT_TYPE.HEAL, 0, BattleConst.SPECIAL_DAMAGE_OR_CURE_TYPE.KILL_MAX_ELEMENT_AND_HEAL) - battleController:killGrids(list) + -- 处理表现 + for _, posId in ipairs(list) do + if BattleConst.GRID_KILL_SFX[maxElement] then + battleController.battleUI:showGridEffectSfx(posId, BattleConst.GRID_KILL_SFX[maxElement], function() + local entity = battleData:getGridEntity(posId) + entity:setIsIdle(true) + battleController.battleUI:removeOneGridOutOfScreen(posId) + end, 0.08) + else + local entity = battleData:getGridEntity(posId) + entity:setIsIdle(true) + battleController.battleUI:removeOneGridOutOfScreen(posId) + end + end end @@ -305,6 +360,7 @@ local function _takeKillRowAndColumn(atkUnitComp, skillEntity, battleController) if rowMap[r] then table.insert(infoList, { r = r, + centerPos = ModuleManager.BattleManager:getPosId(r, 4), posList = rowMap[r] }) end @@ -316,12 +372,39 @@ local function _takeKillRowAndColumn(atkUnitComp, skillEntity, battleController) if columnMap[c] then table.insert(infoList, { c = c, + centerPos = ModuleManager.BattleManager:getPosId(4, c), posList = columnMap[c] }) end end - battleController:killRowOrColumn(infoList) + local temp_map = {} + -- 处理表现 + for index, info in ipairs(infoList) do + for _, posId in ipairs(info.posList) do + if not temp_map[posId] then + battleController:addFillWaitingCount() + temp_map[posId] = true + end + end + local zEuler = 0 + if info.c then + zEuler = 90 + end + battleController.battleUI:showGridEffectSfx(info.centerPos, BattleConst.GRID_KILL_SFX.line, function() + for _, posId in ipairs(info.posList) do + local entity = battleData:getGridEntity(posId) + entity:setIsIdle(true) + if entity:getCell() then + entity:getCell():doScale(0, 1, function() + battleController:reduceFillWaitingCount() + battleController.battleUI:removeOneGridOutOfScreen(posId) + entity:getCell():hideAni() + end) + end + end + end, 1, zEuler) + end end local function _takeAddSkillEnergy(atkUnitComp, skillEntity, battleController) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 9ec99363..27265906 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -1082,15 +1082,18 @@ function BattleUI:dealGridEffectSfx(time, info, breakSfxNameIndexMap, entity) end end -function BattleUI:showGridEffectSfx(posId, sfxName, callback) +function BattleUI:showGridEffectSfx(posId, sfxName, callback, customTime, zEuler) self:getSfxGridEffect(sfxName, function(info) info.isIdle = false local pos = ModuleManager.BattleManager:getPosInfo(posId) + customTime = customTime or info.obj:getDuration() info.obj:setLocalPosition(pos.x, pos.y, 0) + info.obj:setLocalEulerAngles(0, 0, zEuler) info.obj:setActive(true) info.obj:playComplete(function() info.isIdle = true info.obj:setActive(false) + end, customTime, function() if callback then callback() end @@ -1313,12 +1316,16 @@ end function BattleUI:removeGridOutOfScreen(posIdList) for _, posId in ipairs(posIdList) do - local entity = DataManager.BattleData:getGridEntity(posId) - local cell = entity:getCell() - cell:getBaseObject():setAnchoredPositionX(DEFAULT_X) + self:removeOneGridOutOfScreen(posId) end end +function BattleUI:removeOneGridOutOfScreen(posId) + local entity = DataManager.BattleData:getGridEntity(posId) + local cell = entity:getCell() + cell:getBaseObject():setAnchoredPositionX(DEFAULT_X) +end + function BattleUI:fallGrid(listInfo, isRoundBeginCheck, callback) if isRoundBeginCheck then self:showMask(false) @@ -2317,11 +2324,6 @@ 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 diff --git a/lua/app/ui/battle/cell/grid_cell.lua b/lua/app/ui/battle/cell/grid_cell.lua index 198bb43a..04a8e499 100644 --- a/lua/app/ui/battle/cell/grid_cell.lua +++ b/lua/app/ui/battle/cell/grid_cell.lua @@ -1,6 +1,7 @@ local GridCell = class("GridCell", BaseCell) function GridCell:refresh(gridEntity, curElement, skillPosId) + self:clearDoScale() self.gridEntity = gridEntity local uiMap = self:getUIMap() local downBg = uiMap["grid_cell.touch_node.ani_node.down_bg"] @@ -215,6 +216,7 @@ function GridCell:showAni() end function GridCell:hideAni() + self:clearDoScale() local uiMap = self:getUIMap() if not self.aniComp then self.aniComp = uiMap["grid_cell.touch_node.ani_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR) @@ -223,6 +225,20 @@ function GridCell:hideAni() self:resetTranform() end +function GridCell:doScale(targetScale, time, callback) + self:clearDoScale() + self.doScaleSeq = self.baseObject:createBindTweenSequence() + self.doScaleSeq:Append(self.baseObject:getTransform():DOScale(targetScale, time)) + self.doScaleSeq:AppendCallback(callback) +end + +function GridCell:clearDoScale() + if self.doScaleSeq then + self.doScaleSeq:Kill() + self.doScaleSeq = nil + end +end + function GridCell:setOrder(uiOder) local uiMap = self:getUIMap() for elementType, name in pairs(GConst.BattleConst.OUTLINE_SFX) do