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

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)
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

View File

@ -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

View File

@ -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