From ecdeca90ec3cb0fc009885bbb583a467d38a692f Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 19 Apr 2023 17:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E5=A4=A7=E6=B3=A2=E6=AC=A1=E8=8A=82?= =?UTF-8?q?=E5=A5=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/controller/battle_controller.lua | 63 +++++++++++-------- .../controller/battle_controller_stage.lua | 2 +- lua/app/ui/battle/battle_ui.lua | 26 ++++++++ 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index b6f46b6e..c638eb34 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -263,6 +263,17 @@ function BattleController:setTimeScale(timeScale) BattleHelper:setTimeScale(timeScale) end +function BattleController:_findNextDefUnit() + if self.isBossWave then -- 如果上一波是boss波次,则重新生成棋盘 + self:putBoardCacheSkill(function() + self:findNextDefUnit() + self:generateBoard() + end) + else + self:findNextDefUnit() + end +end + ---- start 回合步骤 function BattleController:enterNextWave() @@ -290,13 +301,7 @@ function BattleController:enterNextWave() end self.defTeam:prepare() - if self.isBossWave then -- 如果上一波是boss波次,则重新生成棋盘 - self:putBoardCacheSkill(function() - self:generateBoard() - end) - else - self:enterRoundBegin() - end + self:enterRoundBegin() self.isBossWave = self.defTeam:getMainUnit().unitEntity:getIsBoss() end @@ -351,7 +356,7 @@ function BattleController:enterAtkStepOver() if self.waveIndex >= self.maxWaveIndex then self:enterRoundEnd() else - self:findNextDefUnit() + self:enterRefreshBoard() end return end @@ -386,10 +391,8 @@ function BattleController:enterDefStepOver() if not defTeam or defTeam:getIsDead() then -- 怪物死了, 直接进入刷新逻辑 if self.waveIndex >= self.maxWaveIndex then self:enterRoundEnd() - else - self:findNextDefUnit() + return end - return end self:enterRefreshBoard() @@ -418,6 +421,10 @@ function BattleController:enterRoundEnd() self.atkTeam:onRoundEnd() self.defTeam:onRoundEnd() + self:onRoundEnd() +end + +function BattleController:onRoundEnd() if self.battleData:useAddlvCount() then ModuleManager.BattleManager:showSelectSkillUI(self:getRandomSkillList()) else @@ -684,7 +691,6 @@ function BattleController:fillBoard() end end - for c = 1, BattleConst.COLUMN_COUNT do for r = BattleConst.ROW_COUNT, 1, -1 do local posId = ModuleManager.BattleManager:getPosId(r, c) @@ -705,7 +711,17 @@ end function BattleController:onFillBoardOver() self:generateSkill(function() self.battleUI:refreshSkill() - self:enterRoundEnd() + local defTeam = self.battleData:getDefTeam() + if not defTeam or defTeam:getIsDead() then -- 怪物死了, 直接进入刷新逻辑 + if self.waveIndex >= self.maxWaveIndex then + self:enterRoundEnd() + else + self:_findNextDefUnit() + end + return + else + self:enterRoundEnd() + end end) end @@ -865,9 +881,12 @@ function BattleController:generateBoard() self.curBoardIndex = (self.curBoardIndex or 0) + 1 local board = boardList[self.curBoardIndex] - self.battleData:refreshBoard(board) - self.battleUI:initGridCell() - self:enterRoundBegin() + self.battleUI:switchBoard(function() + self.battleData:refreshBoard(board) + self.battleUI:initGridCell() + end, function() + self:enterRoundBegin() + end) end function BattleController:putBoardCacheSkill(callback) @@ -1226,11 +1245,7 @@ function BattleController:onSelectSkill(skillId) entity:gotUpSKill(skillId) end - if self.battleData:useAddlvCount() then - ModuleManager.BattleManager:showSelectSkillUI(self:getRandomSkillList()) - else - self:enterRoundBegin() - end + self:onRoundEnd() if self.battleUI then self.battleUI:refreshBoard() @@ -1258,8 +1273,6 @@ function BattleController:changeElementType(count, elementType) end function BattleController:addHeroAttr(attrName, value) - Logger.logHighlight("------addHeroAttr------ " .. attrName .. " " .. value) - Logger.logHighlight(self.battleData.atkTeam == nil) if not self.battleData or not self.battleData.atkTeam then return end @@ -1357,7 +1370,7 @@ function BattleController:findAttention() local mainElementType = gridEntity:getElementType() if skillId then local skillEntity = self.battleData:getSkillEntityBySkillId(skillId) - if skillEntity:ignoreElementType() then + if skillEntity:getIgnoreElementType() then mainElementType = nil end end @@ -1411,7 +1424,7 @@ function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementTyp local skillId = gridEntity:getSkillId() local skillEntity = self.battleData:getSkillEntityBySkillId(skillId) if skillEntity then - if skillEntity:ignoreElementType() or skillEntity:getPosition() == mainElementType then + if skillEntity:getIgnoreElementType() or skillEntity:getPosition() == mainElementType then local tempIdMap = GFunc.getTable(posIdMap) local newList = GFunc.getTable(lineList) local gotSkill = self:findLinkLine(aroundposId, tempIdMap, true, mainElementType, newList) diff --git a/lua/app/module/battle/controller/battle_controller_stage.lua b/lua/app/module/battle/controller/battle_controller_stage.lua index 61f6bc1b..ed5c16e3 100644 --- a/lua/app/module/battle/controller/battle_controller_stage.lua +++ b/lua/app/module/battle/controller/battle_controller_stage.lua @@ -41,7 +41,7 @@ function BattleControllerStage:_stageGenerateNextMonster() self.defTeam:addUnit(monsterComp, true) monsterComp:playEnterBattlefield(function() self:enterNextWave() - self:enterRefreshBoard() + self:onRoundEnd() end) self.battleUI:refreshDefHp(unitEntity:getHp(), unitEntity:getHpPercent()) end) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index fa42d686..3e234c5d 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -4,6 +4,8 @@ local GRID_CELL_PATH = "assets/prefabs/ui/battle/cell/grid_cell.prefab" local SKILL_NODE_CELL = "app/ui/battle/cell/skill_node_cell" local DEFAULT_X = 10000 +local BOARD_POS_UP = BF.Vector2(0, 47) +local BOARD_POS_DOWN = BF.Vector2(0, -740) function BattleUI:getPrefabPath() return "assets/prefabs/ui/battle/battle_ui.prefab" @@ -307,6 +309,27 @@ function BattleUI:onInitGridCellOver() end end +function BattleUI:switchBoard(downCallback, callback) + if self.switchBoardSeq then + self.switchBoardSeq:Kill() + self.switchBoardSeq = nil + end + + self.switchBoardSeq = self.root:createBindTweenSequence() + self.switchBoardSeq:Append(self.boardNode:getTransform():DOAnchorPos(BOARD_POS_DOWN, 0.5)) + self.switchBoardSeq:AppendCallback(function() + if downCallback then + downCallback() + end + end) + self.switchBoardSeq:Append(self.boardNode:getTransform():DOAnchorPos(BOARD_POS_UP, 0.5)) + self.switchBoardSeq:AppendCallback(function() + if callback then + callback() + end + end) +end + function BattleUI:setController(controller) self.battleController = controller end @@ -477,6 +500,9 @@ function BattleUI:fallGrid(listInfo, callback) end) end end + if self.fallAniCount == 0 and callback then + callback() + end end function BattleUI:cacheSkillAni(skillInfo, isPop, callback)