战斗返回,消除时界面屏蔽点击

This commit is contained in:
xiekaidong 2023-04-10 10:34:37 +08:00
parent aacf7bc803
commit 3a0e442a93
3 changed files with 59 additions and 5 deletions

View File

@ -202,4 +202,37 @@ function BattleManager:_play(params, battleType)
self.battleController:init(params) self.battleController:init(params)
end 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 return BattleManager

View File

@ -135,6 +135,7 @@ function BattleController:onTouchEvent(eventType, posId)
local entity = DataManager.BattleData:getGridEntity(info.posId) local entity = DataManager.BattleData:getGridEntity(info.posId)
table.insert(cellList, entity:getCell()) table.insert(cellList, entity:getCell())
end end
self.battleUI:disableUITouch()
self.battleUI:eliminationAni(cellList, function() self.battleUI:eliminationAni(cellList, function()
self:onEliminationAniOver() self:onEliminationAniOver()
end) end)
@ -214,7 +215,9 @@ function BattleController:fillBoard()
end end
end end
self.battleUI:fallGrid(pathMap) self.battleUI:fallGrid(pathMap, function()
self.battleUI:enableUITouch()
end)
end end
---- 从一个点直接遍历所有相关的路径 ---- 从一个点直接遍历所有相关的路径
@ -317,8 +320,7 @@ function BattleController:findSkillInfluenceGrids(isFinal)
local sequence = DataManager.BattleData:getGridSequence() local sequence = DataManager.BattleData:getGridSequence()
for _, info in ipairs(sequence) do for _, info in ipairs(sequence) do
local entity = DataManager.BattleData:getGridEntity(info.posId) local entity = DataManager.BattleData:getGridEntity(info.posId)
-- local skillId = entity:getSkillId() local skillId = entity:getSkillId()
local skillId = 71
if skillId then if skillId then
self:activeBoardSkill(info.posId, skillId, isFinal) self:activeBoardSkill(info.posId, skillId, isFinal)
end end
@ -365,4 +367,12 @@ function BattleController:snapshotBoard()
return snapshot return snapshot
end end
function BattleController:clear()
end
function BattleController:endBattleAndExit()
ModuleManager.BattleManager:exitBattle()
end
return BattleController return BattleController

View File

@ -10,6 +10,7 @@ end
function BattleUI:onLoadRootComplete() function BattleUI:onLoadRootComplete()
self:_display() self:_display()
self:_addListeners()
end end
function BattleUI:_display() function BattleUI:_display()
@ -20,7 +21,7 @@ end
function BattleUI:_addListeners() function BattleUI:_addListeners()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["battle_ui.close_btn"]:addClickListener(function() uiMap["battle_ui.close_btn"]:addClickListener(function()
self:initGridCell() ModuleManager.BattleManager:endBattleAndExit()
end) end)
end end
@ -113,8 +114,10 @@ function BattleUI:eliminationAni(cellList, callback)
end end
end end
function BattleUI:fallGrid(listInfo) function BattleUI:fallGrid(listInfo, callback)
self.fallAniCount = 0
for posId, info in pairs(listInfo) do for posId, info in pairs(listInfo) do
self.fallAniCount = self.fallAniCount + 1
local entity = DataManager.BattleData:getGridEntity(posId) local entity = DataManager.BattleData:getGridEntity(posId)
local cell = entity:getCell() local cell = entity:getCell()
local posId = entity:getPosId() local posId = entity:getPosId()
@ -130,6 +133,14 @@ function BattleUI:fallGrid(listInfo)
baseObject:setAnchoredPosition(info[1].x, info[1].y) baseObject:setAnchoredPosition(info[1].x, info[1].y)
local count = #info local count = #info
cell.fallSeq:Append(baseObject:getTransform():DOLocalPath(info, GConst.BattleConst.ONE_STEP_TIME * count)) 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 end
end end