From 3a0e442a930967515ba6d07dff800af259884d3c Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 10 Apr 2023 10:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E8=BF=94=E5=9B=9E=EF=BC=8C?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E6=97=B6=E7=95=8C=E9=9D=A2=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_manager.lua | 33 +++++++++++++++++++ .../battle/controller/battle_controller.lua | 16 +++++++-- lua/app/ui/battle/battle_ui.lua | 15 +++++++-- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index 705c0c37..d195f061 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -202,4 +202,37 @@ function BattleManager:_play(params, battleType) self.battleController:init(params) end +-- 结束战斗并退出 +function BattleManager:endBattleAndExit() + if self.battleController then + self.battleController:endBattleAndExit() + else + self:exitBattle() + end +end + +function BattleManager:exitBattle() + self:clear() + if self.returnFunc then + local returnFunc = self.returnFunc + self.returnFunc = nil + returnFunc() + else -- 没有指定返回则直接去主城 + UIManager:closeAllUI() + ModuleManager.MaincityManager:showMainCityUI() + end + self:performWithDelayGlobal(function() + Game:garbageCollect() + end, 0.02) +end + +function BattleManager:clear() + if self.battleController == nil then + return + end + self.battleController:clear() + self.battleController = nil + DataManager.BattleData:clear() +end + return BattleManager \ No newline at end of file diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 8a1511f3..42820502 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -135,6 +135,7 @@ function BattleController:onTouchEvent(eventType, posId) local entity = DataManager.BattleData:getGridEntity(info.posId) table.insert(cellList, entity:getCell()) end + self.battleUI:disableUITouch() self.battleUI:eliminationAni(cellList, function() self:onEliminationAniOver() end) @@ -214,7 +215,9 @@ function BattleController:fillBoard() end end - self.battleUI:fallGrid(pathMap) + self.battleUI:fallGrid(pathMap, function() + self.battleUI:enableUITouch() + end) end ---- 从一个点直接遍历所有相关的路径 @@ -317,8 +320,7 @@ function BattleController:findSkillInfluenceGrids(isFinal) local sequence = DataManager.BattleData:getGridSequence() for _, info in ipairs(sequence) do local entity = DataManager.BattleData:getGridEntity(info.posId) - -- local skillId = entity:getSkillId() - local skillId = 71 + local skillId = entity:getSkillId() if skillId then self:activeBoardSkill(info.posId, skillId, isFinal) end @@ -365,4 +367,12 @@ function BattleController:snapshotBoard() return snapshot end +function BattleController:clear() + +end + +function BattleController:endBattleAndExit() + ModuleManager.BattleManager:exitBattle() +end + return BattleController \ No newline at end of file diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index 120ba7ad..58660650 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -10,6 +10,7 @@ end function BattleUI:onLoadRootComplete() self:_display() + self:_addListeners() end function BattleUI:_display() @@ -20,7 +21,7 @@ end function BattleUI:_addListeners() local uiMap = self.root:genAllChildren() uiMap["battle_ui.close_btn"]:addClickListener(function() - self:initGridCell() + ModuleManager.BattleManager:endBattleAndExit() end) end @@ -113,8 +114,10 @@ function BattleUI:eliminationAni(cellList, callback) end end -function BattleUI:fallGrid(listInfo) +function BattleUI:fallGrid(listInfo, callback) + self.fallAniCount = 0 for posId, info in pairs(listInfo) do + self.fallAniCount = self.fallAniCount + 1 local entity = DataManager.BattleData:getGridEntity(posId) local cell = entity:getCell() local posId = entity:getPosId() @@ -130,6 +133,14 @@ function BattleUI:fallGrid(listInfo) baseObject:setAnchoredPosition(info[1].x, info[1].y) local count = #info cell.fallSeq:Append(baseObject:getTransform():DOLocalPath(info, GConst.BattleConst.ONE_STEP_TIME * count)) + cell.fallSeq:AppendCallback(function() + self.fallAniCount = self.fallAniCount - 1 + if self.fallAniCount == 0 then + if callback then + callback() + end + end + end) end end end