From 7118b8790abbfaa1bf1355274d1e5ab781935dd1 Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 19 Apr 2023 21:07:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=83=8C=E6=99=AF=E7=A7=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/component/battle_unit_comp.lua | 2 ++ .../battle/controller/battle_controller.lua | 4 ++++ lua/app/ui/battle/battle_ui.lua | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index ff5d5c9c..e03be351 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -514,6 +514,8 @@ function BattleUnitComp:enterEnterBattlefieldState() self.targetX = BattleConst.INIT_POS_X self.moveDirection = -1 end + local time = math.abs(self.targetX - self.positionX)/BattleConst.MOVE_SPEED + self.battleController:moveBattlefield(time) else self:playAnimation(SPINE_ANIMATION_NAME.BORN, false, false) self.waitTime = self:getAnimationDuration(SPINE_ANIMATION_NAME.BORN) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index a49ac45e..2516e12c 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -179,6 +179,10 @@ function BattleController:setIsPauseHpProgress(value) self.battleUI:setIsPauseHpProgress(value) end +function BattleController:moveBattlefield(time) + self.battleUI:moveBattlefield(time) +end + function BattleController:prepareFight() local count = 0 local totalCount = 3 diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 76065c31..a30106b7 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -66,6 +66,19 @@ function BattleUI:loadBg(bgName) end) end +function BattleUI:moveBattlefield(time) + local width = self.bg:fastGetSizeDelta() + self.bg:setAnchoredPositionX(width/4) + if self.bgMoveTween == nil then + self.bgMoveTween = self.bg:getTransform():DOAnchorPosX(-width/4, time) + self.bgMoveTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE) + self.bgMoveTween:SetAutoKill(false) + else + self.bgMoveTween:ChangeEndValue(width*3/4, time, true) + self.bgMoveTween:Restart() + end +end + function BattleUI:initSkill() if self.skillNodeCells then return @@ -750,6 +763,10 @@ function BattleUI:clear() self.hpProgressYellowRightTween:Kill() self.hpProgressYellowRightTween = nil end + if self.bgMoveTween then + self.bgMoveTween:Kill() + self.bgMoveTween = nil + end if self.battleNumberNode then self.battleNumberNode:removeAllChildren() end From 1fad0b8c47b8eb4ed578f94da3aca8a0b0bf1de3 Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 19 Apr 2023 21:32:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8A=A0=E6=88=90=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/component/battle_unit_comp.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 6ba54273..1a38fb52 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -252,9 +252,14 @@ function BattleUnitComp:useAssistingSkill(count, delay, callback) callback() return end - self.assistingDmgAddition = count local attrName = GConst.MATCH_ATTACK_NAME[self:getMatchType()] - self.assistingDmgAddCount = self.unitEntity:addAttr(attrName, count*DEFAULT_FACTOR, true) + self.assistingDmgAddition = count - 1 + if self.assistingDmgAddition <= 0 then + self.assistingDmgAddition = 0 + self.assistingDmgAddCount = 0 + else + self.assistingDmgAddCount = self.unitEntity:addAttr(attrName, self.assistingDmgAddition*DEFAULT_FACTOR, true) + end self.actionOverCallback = callback if delay > 0 then self.waitTime = delay From a6b3df378f2ade0f6ded23638b6f1b145bf78a3b Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 19 Apr 2023 22:20:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?buff=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/white_res_manager.lua | 14 +-- lua/app/global/global_const.lua | 1 + .../battle/component/battle_unit_comp.lua | 5 + .../battle/controller/battle_controller.lua | 8 ++ lua/app/module/battle/team/battle_team.lua | 25 ++++ lua/app/ui/battle/battle_ui.lua | 112 ++++++++++++++++++ .../battle/skill/battle_buff_entity.lua | 4 + 7 files changed, 158 insertions(+), 11 deletions(-) diff --git a/lua/app/common/white_res_manager.lua b/lua/app/common/white_res_manager.lua index 9eeb5be2..87297896 100644 --- a/lua/app/common/white_res_manager.lua +++ b/lua/app/common/white_res_manager.lua @@ -7,18 +7,10 @@ local GAME_RES_WHITE_LIST = { GConst.ATLAS_PATH.COMMON, -- icon GConst.ATLAS_PATH.ICON_SKILL, + GConst.ATLAS_PATH.ICON_SKILL_ROGUE, GConst.ATLAS_PATH.ICON_ITEM, - GConst.ATLAS_PATH.ICON_EQUIP, - GConst.ATLAS_PATH.ICON_AVATAR, - GConst.ATLAS_PATH.ICON_RUNE, - GConst.ATLAS_PATH.ICON_LEGACY, - -- hero - GConst.SPINE_ASSET_PATH.P0001, - GConst.SPINE_ASSET_PATH.P0002, - GConst.SPINE_ASSET_PATH.P0003, - GConst.SPINE_ASSET_PATH.P0004, - -- 战斗伤害字体 - "assets/arts/fonts/tmpfonts/battle/font_battle_sdf.asset", + GConst.ATLAS_PATH.ICON_HERO, + GConst.ATLAS_PATH.ICON_BUFF, } ---- 预加载游戏资源 diff --git a/lua/app/global/global_const.lua b/lua/app/global/global_const.lua index 79812edc..c2dee294 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -175,6 +175,7 @@ GConst.ATLAS_PATH = { ICON_SKILL = "assets/arts/atlas/icon/skill.asset", ICON_HERO = "assets/arts/atlas/icon/hero.asset", ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset", + ICON_BUFF = "assets/arts/atlas/icon/buff.asset", } GConst.TOUCH_EVENT = { diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 1a38fb52..097dab83 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -477,6 +477,7 @@ function BattleUnitComp:exitDeadState() end function BattleUnitComp:enterDeadState() + self:removeAllBuff() local aniName = SPINE_ANIMATION_NAME.DEAD self.deadTime = self:getAnimationDuration(aniName) + 0.1 self:playAnimation(aniName, false, false) @@ -915,6 +916,10 @@ function BattleUnitComp:updateBuffState(buff, num) self.team:updateBuffState(buff, num) end +function BattleUnitComp:removeAllBuff() + self.team:removeAllBuff() +end + function BattleUnitComp:onSkillTakeEffect(skill) skill:endUse() local effectList = skill:getEffectList() diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index ade02988..20b5adec 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -183,6 +183,14 @@ function BattleController:moveBattlefield(time) self.battleUI:moveBattlefield(time) end +function BattleController:refreshBuff(side, buffList) + self.battleUI:refreshBuff(side, buffList) +end + +function BattleController:clearBuff(side) + self.battleUI:clearBuff(side) +end + function BattleController:prepareFight() local count = 0 local totalCount = 3 diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 276468be..3194ea9b 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -156,6 +156,7 @@ function BattleTeam:handleShield(reduceShield, unit) return end + local needReedRefreshBuff = false local shieldNum = 0 local currShieldBuff = self.shieldBuffList[1] while currShieldBuff do @@ -170,6 +171,9 @@ function BattleTeam:handleShield(reduceShield, unit) currShieldBuff.result = 0 for k, v in ipairs(self.buffList) do if v == currShieldBuff then + if not needReedRefreshBuff and currShieldBuff.buff:getIcon() then + needReedRefreshBuff = true + end self:updateBuffState(currShieldBuff.buff, -1) BattleBuffHandle.removeBuff(unit, currShieldBuff) currShieldBuff = nil @@ -182,11 +186,31 @@ function BattleTeam:handleShield(reduceShield, unit) end currShieldBuff = self.shieldBuffList[1] end + if needReedRefreshBuff then + self.battleController:refreshBuff(self.side, self.buffList) + end end function BattleTeam:addBuff(buffEffect) table.insert(self.buffList, buffEffect) self:updateBuffState(buffEffect.buff, 1) + if buffEffect.buff:getIcon() then + self.battleController:refreshBuff(self.side, self.buffList) + end +end + +function BattleTeam:removeAllBuff() + local buffEffect = nil + local count = #self.buffList + for i = count, 1, -1 do + buffEffect = self.buffList[i] + if buffEffect then + self:updateBuffState(buffEffect.buff, -1) + table.remove(self.buffList, i) + BattleBuffHandle.removeBuff(self, buffEffect) + end + end + self.battleController:clearBuff(self.side) end function BattleTeam:doBuffWork() @@ -205,6 +229,7 @@ function BattleTeam:doBuffWork() BattleBuffHandle.removeBuff(self.mainUnit, buffEffect) end end + self.battleController:refreshBuff(self.side, self.buffList) end function BattleTeam:updateBuffState(buff, num) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index cd704898..0411e385 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -34,6 +34,7 @@ function BattleUI:_display() self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"] self:initBg() self:initSkill() + self:initBuff() self:initBattlefield() self:initNumberNode() self:initHpNode() @@ -101,6 +102,117 @@ function BattleUI:initSkill() uiMap["battle_ui.bg_2.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout() end +function BattleUI:initBuff() + self.atkBuffIconList = { + self.uiMap["battle_ui.top_node.buff_l.buff_1"], + self.uiMap["battle_ui.top_node.buff_l.buff_2"], + self.uiMap["battle_ui.top_node.buff_l.buff_3"], + self.uiMap["battle_ui.top_node.buff_l.buff_4"], + self.uiMap["battle_ui.top_node.buff_l.buff_5"], + } + for k, v in ipairs(self.atkBuffIconList) do + v:setLocalScale(0, 0, 0) + end + self.atkBuffTextList = { + self.uiMap["battle_ui.top_node.buff_l.text_1"], + self.uiMap["battle_ui.top_node.buff_l.text_2"], + self.uiMap["battle_ui.top_node.buff_l.text_3"], + self.uiMap["battle_ui.top_node.buff_l.text_4"], + self.uiMap["battle_ui.top_node.buff_l.text_5"], + } + for k, v in ipairs(self.atkBuffTextList) do + v:setText(GConst.EMPTY_STRING) + end + self.defBuffIconList = { + self.uiMap["battle_ui.top_node.buff_r.buff_1"], + self.uiMap["battle_ui.top_node.buff_r.buff_2"], + self.uiMap["battle_ui.top_node.buff_r.buff_3"], + self.uiMap["battle_ui.top_node.buff_r.buff_4"], + self.uiMap["battle_ui.top_node.buff_r.buff_5"], + } + for k, v in ipairs(self.atkBuffIconList) do + v:setLocalScale(0, 0, 0) + end + self.defBuffTextList = { + self.uiMap["battle_ui.top_node.buff_r.text_1"], + self.uiMap["battle_ui.top_node.buff_r.text_2"], + self.uiMap["battle_ui.top_node.buff_r.text_3"], + self.uiMap["battle_ui.top_node.buff_r.text_4"], + self.uiMap["battle_ui.top_node.buff_r.text_5"], + } + for k, v in ipairs(self.defBuffTextList) do + v:setText(GConst.EMPTY_STRING) + end +end + +function BattleUI:refreshBuff(side, buffList) + if side == GConst.BattleConst.SIDE_ATK then + local buffObj = nil + local count = #buffList + local buffIconCount = #self.atkBuffIconList + local index = 1 + for i = 1, count do + buffObj = buffList[i] + if buffObj and buffObj.buff:getIcon() then + local icon = self.atkBuffIconList[index] + local text = self.atkBuffTextList[index] + icon:setLocalScale(1, 1, 1) + icon:setTexture(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon()) + text:setText(buffObj.round) + index = index + 1 + if index > buffIconCount then + break + end + end + end + for i = index, buffIconCount do + self.atkBuffIconList[i]:setLocalScale(0, 0, 0) + self.atkBuffTextList[i]:setText(GConst.EMPTY_STRING) + end + else + local buffObj = nil + local count = #buffList + local buffIconCount = #self.defBuffIconList + local index = 1 + for i = 1, count do + buffObj = buffList[i] + if buffObj and buffObj.buff:getIcon() then + local icon = self.defBuffIconList[index] + local text = self.defBuffTextList[index] + icon:setLocalScale(1, 1, 1) + icon:setTexture(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon()) + text:setText(buffObj.round) + index = index + 1 + if index > buffIconCount then + break + end + end + end + for i = index, buffIconCount do + self.defBuffIconList[i]:setLocalScale(0, 0, 0) + self.defBuffTextList[i]:setText(GConst.EMPTY_STRING) + end + end +end + +function BattleUI:clearBuff(side) + if side == GConst.BattleConst.SIDE_ATK then + for k, v in ipairs(self.atkBuffIconList) do + v:setLocalScale(0, 0, 0) + end + for k, v in ipairs(self.atkBuffTextList) do + v:setText(GConst.EMPTY_STRING) + end + else + for k, v in ipairs(self.defBuffIconList) do + v:setLocalScale(0, 0, 0) + end + for k, v in ipairs(self.defBuffTextList) do + v:setText(GConst.EMPTY_STRING) + end + end +end + function BattleUI:initBattlefield() self.battleNode = self.uiMap["battle_ui.battle_node"] end diff --git a/lua/app/userdata/battle/skill/battle_buff_entity.lua b/lua/app/userdata/battle/skill/battle_buff_entity.lua index a124cbfd..e6fcc344 100644 --- a/lua/app/userdata/battle/skill/battle_buff_entity.lua +++ b/lua/app/userdata/battle/skill/battle_buff_entity.lua @@ -66,4 +66,8 @@ function BattleBuffEntity:setTargetSide(side) self.targetSide = side end +function BattleBuffEntity:getIcon() + return self.buffInfo.icon +end + return BattleBuffEntity \ No newline at end of file