diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 4edb85ec..9ee52200 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -1113,6 +1113,7 @@ function BattleUnitComp:onSkillTakeEffect(skill) end end if succ then + self.team:addCombo() if skill:getIsNormalType() then -- 普攻攻击成功的话 self:checkPassiveEvent(PASSIVE_EVENT.USE_NORMAL_SKILL, target) elseif skill:getIsActiveType() then diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 8d65832f..d063a89f 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -260,6 +260,14 @@ function BattleController:showBuffTips(side) end end +function BattleController:showCombo(count) + self.battleUI:showCombo(count) +end + +function BattleController:hideCombo() + self.battleUI:hideCombo() +end + function BattleController:prepareFight() local count = 0 local totalCount = 3 @@ -493,7 +501,12 @@ function BattleController:enterAtkStep() end) end +function BattleController:getIsAtkStep() + return self.roundStep == BattleConst.BATTLE_ROUND_STEP.ON_ATK_STEP +end + function BattleController:enterAtkStepOver() + self:hideCombo() self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ATK_STEP_OVER local defTeam = self.battleData:getDefTeam() diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 6a721b39..b0f94843 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -1,4 +1,5 @@ local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle" +local BattleConst = require "app/module/battle/battle_const" local BattleHelper = require "app/module/battle/helper/battle_helper" local BattleTeam = class("BattleTeam") @@ -12,6 +13,7 @@ function BattleTeam:init(side, battleController) self.sameBuffCount = {} self.shieldBuffList = {} self.loopFxMap = {} + self.comboCount = 0 end function BattleTeam:addUnit(unit, isMainUnit) @@ -169,6 +171,7 @@ function BattleTeam:onRoundEnd() v:onRoundEnd() end self:doBuffWork() + self.comboCount = 0 end function BattleTeam:addShield(buffEffect) @@ -367,6 +370,17 @@ function BattleTeam:setCentralizedAttack(centralizedAttack) self.centralizedAttack = centralizedAttack end +function BattleTeam:addCombo() + if self.side ~= BattleConst.SIDE_ATK then + return + end + if not self.battleController:getIsAtkStep() then + return + end + self.comboCount = self.comboCount + 1 + self.battleController:showCombo(self.comboCount) +end + function BattleTeam:tick(dt) for k, v in ipairs(self.unitList) do v:tick(dt) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 2dfbb361..ad257393 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -52,6 +52,7 @@ function BattleUI:_display() self:initBuff() self:initBattlefield() self:initNumberNode() + self:initComboNode() self:initHpNode() self:initFxNode() self:hideGenerateSkillGridCells() @@ -379,6 +380,60 @@ function BattleUI:getBattleNumberBlue() return self.battleNumberBlue end +function BattleUI:initComboNode() + self.comboNode = self.uiMap["battle_ui.top_node.combo"] + self.comboNodeVisible = false + self.comboNode:setVisible(false) + self.comboBg1 = self.uiMap["battle_ui.top_node.combo.bg.bg_1"] + self.comboBg2 = self.uiMap["battle_ui.top_node.combo.bg.bg_2"] + self.comboBg3 = self.uiMap["battle_ui.top_node.combo.bg.bg_3"] + self.comboTx1 = self.uiMap["battle_ui.top_node.combo.move_root.text_1"] + self.comboTxComp1 = self.comboTx1:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT) + self.comboTx2 = self.uiMap["battle_ui.top_node.combo.move_root.text_2"] + self.comboTxComp2 = self.comboTx2:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT) +end + +function BattleUI:hideCombo() + if not self.comboNodeVisible then + return + end + self.comboNodeVisible = false + if self.comboSid then + self:unscheduleGlobal(self.comboSid) + end + self.comboSid = self:performWithDelayGlobal(function() + self.comboSid = nil + self.comboNode:setVisible(false) + end, 0.5) +end + +function BattleUI:showCombo(count) + if count > 99 then + count = 99 + end + self.comboNodeVisible = true + self.comboNode:setVisible(true) + if count <= 5 then + self.comboBg1:setVisible(true) + self.comboBg2:setVisible(false) + self.comboBg3:setVisible(false) + self.comboTx1:setText(GConst.INT_TO_STRING[count], self.comboTxComp1) + self.comboTx2:setText(GConst.EMPTY_STRING, self.comboTxComp2) + elseif count <= 10 then + self.comboBg1:setVisible(false) + self.comboBg2:setVisible(true) + self.comboBg3:setVisible(false) + self.comboTx1:setText(GConst.INT_TO_STRING[count], self.comboTxComp1) + self.comboTx2:setText(GConst.EMPTY_STRING, self.comboTxComp2) + else + self.comboBg1:setVisible(false) + self.comboBg2:setVisible(false) + self.comboBg3:setVisible(true) + self.comboTx1:setText(GConst.EMPTY_STRING, self.comboTxComp1) + self.comboTx2:setText(GConst.INT_TO_STRING[count], self.comboTxComp2) + end +end + function BattleUI:initFxNode() self.fxNode = self.uiMap["battle_ui.battle_root.batttle_fx_node"] end