diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 47a9dadb..77274349 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -763,6 +763,8 @@ function BattleController:onLinkOver() local boomGridIds = {} local lineCount = 0 + local skillPosId + local randomPosList for _, info in ipairs(sequence) do if not eliminationPosIds[info.posId] then local entity = self.battleData:getGridEntity(info.posId) @@ -771,6 +773,8 @@ function BattleController:onLinkOver() elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 linkElementType = elementType lineCount = lineCount + 1 + else + skillPosId = info.posId end boomGridIds[info.posId] = BattleConst.AROUND_BOOM_TYPE.LINE @@ -787,7 +791,7 @@ function BattleController:onLinkOver() end end - for posId, _ in pairs(self.battleData:getSkillInfluenceGrids()) do + for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do local entity = self.battleData:getGridEntity(posId) if not entity:getIsIdle() then if entity:isEmptyIdle() then @@ -800,6 +804,13 @@ function BattleController:onLinkOver() elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 end end + if info.direction == BattleConst.BOARD_RANGE_TYPE.RANDOM then + if not randomPosList then + randomPosList = {} + end + table.insert(randomPosList, posId) + end + if not entity:getSkillId() then local elementType = entity:getElementType() if not influenceElementType then @@ -858,6 +869,11 @@ function BattleController:onLinkOver() end end + if skillPosId then + local rangeList = skillEntity:getBoardRange() + self.battleUI:playSkillLineSfx(skillPosId, rangeList, randomPosList) + end + self.battleData:addSkillEnergy(elementTypeMap) self.battleData:clearGridSequence() @@ -1549,6 +1565,7 @@ function BattleController:changeElementType(count, elementType) local entity = table.remove(list, math.random(1, #list)) if entity then entity:setElementType(elementType) + self.battleUI:playChangeElementSfx(entity:getPosId(), i) end end end diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 3c341558..7835cd1f 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -57,6 +57,7 @@ function BattleUI:_display() self:initUISfxs() self:initSkillSelectCells() self:hideAllSfxSmoke() + self:initSkillLineSfx() end function BattleUI:_addListeners() @@ -1274,6 +1275,148 @@ function BattleUI:hideAllSfxSmoke() end end +function BattleUI:initSkillLineSfx() + local uiMap = self.root:genAllChildren() + if not self.skillLineSfxs then + self.skillLineSfxs = {} + self.skillLineSfxs[13] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_1h"] + self.skillLineSfxs[11] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_1v"] + self.skillLineSfxs[15] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_1l"] + self.skillLineSfxs[17] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_1r"] + + self.skillLineSfxs[23] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_2h"] + self.skillLineSfxs[21] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_2v"] + self.skillLineSfxs[25] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_2l"] + self.skillLineSfxs[27] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_2r"] + + self.skillLineSfxs[33] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_3h"] + self.skillLineSfxs[31] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_3v"] + self.skillLineSfxs[35] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_3l"] + self.skillLineSfxs[37] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b01_3r"] + end + + if not self.skillLightSfxs then + self.skillLightSfxs = {} + self.skillLightSfxs.point = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b03"] + self.skillLightSfxs[11] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b04_1"] + self.skillLightSfxs[12] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b04_2"] + self.skillLightSfxs[13] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b04_3"] + self.skillLightSfxs[14] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b04_4"] + self.skillLightSfxs[15] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b04_5"] + + self.skillLightSfxs[21] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b05_1"] + self.skillLightSfxs[22] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b05_2"] + self.skillLightSfxs[23] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b05_3"] + self.skillLightSfxs[24] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b05_4"] + self.skillLightSfxs[25] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b05_5"] + end + + if not self.changeElementSfxs then + self.changeElementSfxs = {} + self.changeElementSfxs[1] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b02_1"] + self.changeElementSfxs[2] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b02_2"] + self.changeElementSfxs[3] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b02_3"] + self.changeElementSfxs[4] = uiMap["battle_ui.bg_2.board_node.grid_node.sfx_skill_b02_4"] + end + + for _, obj in pairs(self.skillLineSfxs) do + obj:setActive(true) + obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), GConst.UI_EFFECT_ORDER.LEVEL2) + obj:setActive(false) + end + + for _, obj in pairs(self.skillLightSfxs) do + obj:setActive(true) + obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), GConst.UI_EFFECT_ORDER.LEVEL2) + obj:setActive(false) + end + + for _, obj in pairs(self.changeElementSfxs) do + obj:setActive(true) + obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(self:getUIOrder(), GConst.UI_EFFECT_ORDER.LEVEL2) + obj:setActive(false) + end +end + +function BattleUI:playSkillLineSfx(posId, boradRangeList, randomPosList) + if not boradRangeList or not boradRangeList[1] or not self.skillLineSfxs then + return + end + + local directionAndRange = {} + for _, info in ipairs(boradRangeList) do + if info.type == GConst.BattleConst.BOARD_RANGE_TYPE.RANDOM then + directionAndRange[GConst.BattleConst.BOARD_RANGE_TYPE.RANDOM] = info.range + elseif info.type == GConst.BattleConst.BOARD_RANGE_TYPE.UP or + info.type == GConst.BattleConst.BOARD_RANGE_TYPE.DOWN then + directionAndRange[GConst.BattleConst.BOARD_RANGE_TYPE.UP] = info.range + elseif info.type == GConst.BattleConst.BOARD_RANGE_TYPE.LEFT or + info.type == GConst.BattleConst.BOARD_RANGE_TYPE.RIGHT then + directionAndRange[GConst.BattleConst.BOARD_RANGE_TYPE.LEFT] = info.range + elseif info.type == GConst.BattleConst.BOARD_RANGE_TYPE.LEFT_UP or + info.type == GConst.BattleConst.BOARD_RANGE_TYPE.LEFT_DOWN then + directionAndRange[GConst.BattleConst.BOARD_RANGE_TYPE.LEFT_UP] = info.range + elseif info.type == GConst.BattleConst.BOARD_RANGE_TYPE.RIGHT_UP or + info.type == GConst.BattleConst.BOARD_RANGE_TYPE.RIGHT_DOWN then + directionAndRange[GConst.BattleConst.BOARD_RANGE_TYPE.RIGHT_UP] = info.range + end + end + + local pos = ModuleManager.BattleManager:getPosInfo(posId) + for dir, range in pairs(directionAndRange) do + local index = range * 10 + dir + local obj = self.skillLineSfxs[index] + if obj then + obj:setAnchoredPosition(pos.x, pos.y) + obj:setActive(true) + obj:play() + end + end + + if randomPosList then + local count = math.min(#randomPosList, 5) -- 特效最多5个 + self.skillLightSfxs.point:setAnchoredPosition(pos.x, pos.y) + self.skillLightSfxs.point:setActive(true) + self.skillLightSfxs.point:play() + for i = 1, count do + local tartgetPos = randomPosList[i] + tartgetPos = ModuleManager.BattleManager:getPosInfo(tartgetPos) + local obj = self.skillLightSfxs[20 + i] + if obj then + obj:setAnchoredPosition(tartgetPos.x, tartgetPos.y) + obj:setActive(true) + obj:play() + end + + obj = self.skillLightSfxs[10 + i] + local yOffset = tartgetPos.y - pos.y + local xOffset = tartgetPos.x - pos.x + local height = math.sqrt(xOffset * xOffset + yOffset * yOffset) + if obj then + obj:setAnchoredPosition(pos.x, pos.y) + obj:setLocalScaleX(0.3 * height / 94) + obj:setEulerAngles(0, 0, - math.deg(math.atan(xOffset, yOffset)) + 90) + obj:setActive(true) + obj:play() + end + end + end +end + +function BattleUI:playChangeElementSfx(posId, index) + if not self.changeElementSfxs then + return + end + + local pos = ModuleManager.BattleManager:getPosInfo(posId) + local obj = self.changeElementSfxs[index] + if obj then + obj:setAnchoredPosition(pos.x, pos.y) + obj:setActive(true) + obj:play() + end +end + function BattleUI:initTutorialNode() local uiMap = self.root:genAllChildren() self.tutorialNode = uiMap["battle_ui.tutorial_node"]