boss机制棋盘效果处理

This commit is contained in:
xiekaidong 2023-06-02 22:28:22 +08:00
parent 9f9bb18fec
commit 44ff406135
6 changed files with 181 additions and 42 deletions

View File

@ -34,14 +34,22 @@ function EffectObject:play()
self.effectHelper:Play() self.effectHelper:Play()
end end
function EffectObject:playComplete(complete, customTime) function EffectObject:playComplete(complete, customTime, customCallback)
self.effectHelper:Play() self.effectHelper:Play()
local duration = customTime or self:getDuration() local duration = self:getDuration()
if self.playCompleteSeq then if self.playCompleteSeq then
self.playCompleteSeq:Kill() self.playCompleteSeq:Kill()
self.playCompleteSeq = nil self.playCompleteSeq = nil
end end
self.playCompleteSeq = self:createBindTweenSequence() self.playCompleteSeq = self:createBindTweenSequence()
if customTime then
self.playCompleteSeq:AppendInterval(customTime)
self.playCompleteSeq:AppendCallback(customCallback)
duration = duration - customTime
if duration <= 0 then
duration = 0.01
end
end
self.playCompleteSeq:AppendInterval(duration) self.playCompleteSeq:AppendInterval(duration)
self.playCompleteSeq:AppendCallback(complete) self.playCompleteSeq:AppendCallback(complete)
end end

View File

@ -759,6 +759,16 @@ BattleConst.OUTLINE_SFX = {
BattleConst.LINE_SFX = "assets/prefabs/effects/battle/sfx_piece_line_b01.prefab" BattleConst.LINE_SFX = "assets/prefabs/effects/battle/sfx_piece_line_b01.prefab"
BattleConst.CHANGE_ELEMENT_SFX = "assets/prefabs/effects/battle/sfx_skill_b02.prefab" BattleConst.CHANGE_ELEMENT_SFX = "assets/prefabs/effects/battle/sfx_skill_b02.prefab"
BattleConst.LINK_SMOKE = "assets/prefabs/effects/battle/sfx_piece_smoke_b01.prefab" BattleConst.LINK_SMOKE = "assets/prefabs/effects/battle/sfx_piece_smoke_b01.prefab"
BattleConst.LINK_SMOKE = "assets/prefabs/effects/battle/sfx_piece_smoke_b01.prefab"
BattleConst.GRID_KILL_SFX = {
[BattleConst.ELEMENT_TYPE.RED] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b04.prefab",
[BattleConst.ELEMENT_TYPE.YELLOW] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b05.prefab",
[BattleConst.ELEMENT_TYPE.GREEN] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b02.prefab",
[BattleConst.ELEMENT_TYPE.BLUE] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b01.prefab",
[BattleConst.ELEMENT_TYPE.PURPLE] = "assets/prefabs/effects/battle/sfx_piece_qizi_posui_b03.prefab",
skill = "assets/prefabs/effects/battle/sfx_piece_skill_posui_b01.prefab",
line = "assets/prefabs/effects/battle/sfx_piece_xiaochu_b01.prefab",
}
BattleConst.BATTLE_TASK_FIELD = { BattleConst.BATTLE_TASK_FIELD = {
SKILL_BOX_OPEN = "skill_box", -- 技能宝箱打开次数(神灯) SKILL_BOX_OPEN = "skill_box", -- 技能宝箱打开次数(神灯)

View File

@ -263,6 +263,7 @@ function BattleController:init(params)
self.taskProgress = {} self.taskProgress = {}
self.waveRoundCount = {} self.waveRoundCount = {}
self.lastRoundBreakedGridType = {} self.lastRoundBreakedGridType = {}
self.waitingFillCount = 0
self.chapterId = self:getChapterId() self.chapterId = self:getChapterId()
self.waveIndex = 0 self.waveIndex = 0
@ -720,7 +721,13 @@ function BattleController:enterRefreshBoard(isRoundBeginCheck, callback)
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_REFRESH_BOARD self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_REFRESH_BOARD
end end
self.onFillBoardOverCallback = callback self.onFillBoardOverCallback = callback
self:fillBoard(isRoundBeginCheck) self.isRoundBeginCheck = isRoundBeginCheck
if self.isRoundBeginCheck and self.waitingFillCount > 0 then
self.isWaitingFill = true
return
end
self:fillBoard(self.isRoundBeginCheck)
end end
function BattleController:enterRoundEnd() function BattleController:enterRoundEnd()
@ -1251,6 +1258,8 @@ function BattleController:fillBoard(isRoundBeginCheck)
self.battleUI:fallGrid(self.fillBoardPathMap, isRoundBeginCheck, function() self.battleUI:fallGrid(self.fillBoardPathMap, isRoundBeginCheck, function()
self:onFillBoardOver(isRoundBeginCheck) self:onFillBoardOver(isRoundBeginCheck)
self.isRoundBeginCheck = nil
self.isWaitingFill = false
end) end)
end end
@ -2476,11 +2485,22 @@ function BattleController:getTaskProgress()
return self.taskProgress return self.taskProgress
end end
function BattleController:addFillWaitingCount()
self.waitingFillCount = self.waitingFillCount + 1
end
function BattleController:reduceFillWaitingCount()
self.waitingFillCount = self.waitingFillCount - 1
end
function BattleController:_tick(dt) function BattleController:_tick(dt)
self.realTime = self.realTime + dt self.realTime = self.realTime + dt
if self.isPause then if self.isPause then
return return
end end
if self.waitingFillCount <= 0 and self.isWaitingFill and self.isRoundBeginCheck then
self:fillBoard(self.isRoundBeginCheck)
end
self.time = self.time + dt self.time = self.time + dt
self.atkTeam:tick(dt) self.atkTeam:tick(dt)
self.defTeam:tick(dt) self.defTeam:tick(dt)

View File

@ -138,15 +138,17 @@ local function _takeRandomKillSkillGrid(atkUnitComp, skillEntity, battleControll
end end
end end
if listCount > count then -- 处理表现
local removeCount = listCount - count for index, posId in ipairs(list) do
for i = 1, removeCount do if index > count then
table.remove(list, math.random(1, listCount)) break
listCount = listCount - 1
end end
battleController.battleUI:showGridEffectSfx(posId, BattleConst.GRID_KILL_SFX.skill, function()
local entity = battleData:getGridEntity(posId)
entity:setIsIdle(true)
battleController.battleUI:removeOneGridOutOfScreen(posId)
end, 0.08)
end end
battleController:killGrids(list)
end end
local function _takeShuffleBoard(atkUnitComp, skillEntity, battleController) local function _takeShuffleBoard(atkUnitComp, skillEntity, battleController)
@ -168,24 +170,27 @@ local function _takeRandomKillRowOrColumn(atkUnitComp, skillEntity, battleContro
if count <= 0 then if count <= 0 then
return return
end end
local rCount = math.random(0, count)
local listCount = 0 local cCount = count - rCount
local list = {}
local rowMap = {} local rowMap = {}
local columnMap = {} local columnMap = {}
local rList = {}
local rListCount = 0
local cList = {}
local cListCount = 0
for posId, entity in pairs(battleData:getGridEnties()) do for posId, entity in pairs(battleData:getGridEnties()) do
if entity:isEmptyIdle() then if entity:isEmptyIdle() then
local rc = ModuleManager.BattleManager:getPosRC(posId) local rc = ModuleManager.BattleManager:getPosRC(posId)
local r = rc.r local r = rc.r
local c = rc.c local c = rc.c
if not rowMap[r] then if not rowMap[r] then
table.insert(list, {r = r}) table.insert(rList, r)
listCount = listCount + 1 rListCount = rListCount + 1
rowMap[r] = {} rowMap[r] = {}
end end
if not columnMap[c] then if not columnMap[c] then
table.insert(list, {c = c}) table.insert(cList, c)
listCount = listCount + 1 cListCount = cListCount + 1
columnMap[c] = {} columnMap[c] = {}
end end
table.insert(rowMap[r], posId) table.insert(rowMap[r], posId)
@ -194,23 +199,60 @@ local function _takeRandomKillRowOrColumn(atkUnitComp, skillEntity, battleContro
end end
local infoList = {} local infoList = {}
for i = 1, count do rCount = math.min(rCount, rListCount)
if not list[1] then cCount = math.min(cCount, cListCount)
break for i = 1, rCount do
end local r = table.remove(rList, math.random(1, rListCount))
local info = table.remove(list, math.random(1, listCount)) rListCount = rListCount - 1
listCount = listCount - 1 if rowMap[r] then
if info.r then table.insert(infoList, {
info.posList = rowMap[info.r] r = true,
elseif info.c then centerPos = ModuleManager.BattleManager:getPosId(r, 4),
info.posList = columnMap[info.c] posList = rowMap[r]
end })
if info.posList then
table.insert(infoList, info)
end end
end end
battleController:killRowOrColumn(infoList) for i = 1, cCount do
local c = table.remove(cList, math.random(1, cListCount))
cListCount = cListCount - 1
if columnMap[c] then
table.insert(infoList, {
c = true,
centerPos = ModuleManager.BattleManager:getPosId(4, c),
posList = columnMap[c]
})
end
end
local temp_map = {}
-- 处理表现
for index, info in ipairs(infoList) do
for _, posId in ipairs(info.posList) do
if not temp_map[posId] then
battleController:addFillWaitingCount()
temp_map[posId] = true
end
end
local zEuler = 0
if info.c then
zEuler = 90
end
battleController.battleUI:showGridEffectSfx(info.centerPos, BattleConst.GRID_KILL_SFX.line, function()
for _, posId in ipairs(info.posList) do
local entity = battleData:getGridEntity(posId)
entity:setIsIdle(true)
if entity:getCell() then
entity:getCell():doScale(0, 1, function()
battleController:reduceFillWaitingCount()
battleController.battleUI:removeOneGridOutOfScreen(posId)
entity:getCell():hideAni()
end)
end
end
end, 1, zEuler)
end
end end
local function _takeKillMaxElementAndHeal(atkUnitComp, skillEntity, battleController) local function _takeKillMaxElementAndHeal(atkUnitComp, skillEntity, battleController)
@ -254,7 +296,20 @@ local function _takeKillMaxElementAndHeal(atkUnitComp, skillEntity, battleContro
local heal = count * effectNum * atkUnitComp.unitEntity:getAtk() // GConst.BattleConst.DEFAULT_FACTOR local heal = count * effectNum * atkUnitComp.unitEntity:getAtk() // GConst.BattleConst.DEFAULT_FACTOR
atkUnitComp:takeDamageOrCure(atkUnitComp, heal, BattleConst.EFFECT_TYPE.HEAL, 0, BattleConst.SPECIAL_DAMAGE_OR_CURE_TYPE.KILL_MAX_ELEMENT_AND_HEAL) atkUnitComp:takeDamageOrCure(atkUnitComp, heal, BattleConst.EFFECT_TYPE.HEAL, 0, BattleConst.SPECIAL_DAMAGE_OR_CURE_TYPE.KILL_MAX_ELEMENT_AND_HEAL)
battleController:killGrids(list) -- 处理表现
for _, posId in ipairs(list) do
if BattleConst.GRID_KILL_SFX[maxElement] then
battleController.battleUI:showGridEffectSfx(posId, BattleConst.GRID_KILL_SFX[maxElement], function()
local entity = battleData:getGridEntity(posId)
entity:setIsIdle(true)
battleController.battleUI:removeOneGridOutOfScreen(posId)
end, 0.08)
else
local entity = battleData:getGridEntity(posId)
entity:setIsIdle(true)
battleController.battleUI:removeOneGridOutOfScreen(posId)
end
end
end end
@ -305,6 +360,7 @@ local function _takeKillRowAndColumn(atkUnitComp, skillEntity, battleController)
if rowMap[r] then if rowMap[r] then
table.insert(infoList, { table.insert(infoList, {
r = r, r = r,
centerPos = ModuleManager.BattleManager:getPosId(r, 4),
posList = rowMap[r] posList = rowMap[r]
}) })
end end
@ -316,12 +372,39 @@ local function _takeKillRowAndColumn(atkUnitComp, skillEntity, battleController)
if columnMap[c] then if columnMap[c] then
table.insert(infoList, { table.insert(infoList, {
c = c, c = c,
centerPos = ModuleManager.BattleManager:getPosId(4, c),
posList = columnMap[c] posList = columnMap[c]
}) })
end end
end end
battleController:killRowOrColumn(infoList) local temp_map = {}
-- 处理表现
for index, info in ipairs(infoList) do
for _, posId in ipairs(info.posList) do
if not temp_map[posId] then
battleController:addFillWaitingCount()
temp_map[posId] = true
end
end
local zEuler = 0
if info.c then
zEuler = 90
end
battleController.battleUI:showGridEffectSfx(info.centerPos, BattleConst.GRID_KILL_SFX.line, function()
for _, posId in ipairs(info.posList) do
local entity = battleData:getGridEntity(posId)
entity:setIsIdle(true)
if entity:getCell() then
entity:getCell():doScale(0, 1, function()
battleController:reduceFillWaitingCount()
battleController.battleUI:removeOneGridOutOfScreen(posId)
entity:getCell():hideAni()
end)
end
end
end, 1, zEuler)
end
end end
local function _takeAddSkillEnergy(atkUnitComp, skillEntity, battleController) local function _takeAddSkillEnergy(atkUnitComp, skillEntity, battleController)

View File

@ -1082,15 +1082,18 @@ function BattleUI:dealGridEffectSfx(time, info, breakSfxNameIndexMap, entity)
end end
end end
function BattleUI:showGridEffectSfx(posId, sfxName, callback) function BattleUI:showGridEffectSfx(posId, sfxName, callback, customTime, zEuler)
self:getSfxGridEffect(sfxName, function(info) self:getSfxGridEffect(sfxName, function(info)
info.isIdle = false info.isIdle = false
local pos = ModuleManager.BattleManager:getPosInfo(posId) local pos = ModuleManager.BattleManager:getPosInfo(posId)
customTime = customTime or info.obj:getDuration()
info.obj:setLocalPosition(pos.x, pos.y, 0) info.obj:setLocalPosition(pos.x, pos.y, 0)
info.obj:setLocalEulerAngles(0, 0, zEuler)
info.obj:setActive(true) info.obj:setActive(true)
info.obj:playComplete(function() info.obj:playComplete(function()
info.isIdle = true info.isIdle = true
info.obj:setActive(false) info.obj:setActive(false)
end, customTime, function()
if callback then if callback then
callback() callback()
end end
@ -1313,11 +1316,15 @@ end
function BattleUI:removeGridOutOfScreen(posIdList) function BattleUI:removeGridOutOfScreen(posIdList)
for _, posId in ipairs(posIdList) do for _, posId in ipairs(posIdList) do
self:removeOneGridOutOfScreen(posId)
end
end
function BattleUI:removeOneGridOutOfScreen(posId)
local entity = DataManager.BattleData:getGridEntity(posId) local entity = DataManager.BattleData:getGridEntity(posId)
local cell = entity:getCell() local cell = entity:getCell()
cell:getBaseObject():setAnchoredPositionX(DEFAULT_X) cell:getBaseObject():setAnchoredPositionX(DEFAULT_X)
end end
end
function BattleUI:fallGrid(listInfo, isRoundBeginCheck, callback) function BattleUI:fallGrid(listInfo, isRoundBeginCheck, callback)
if isRoundBeginCheck then if isRoundBeginCheck then
@ -2317,11 +2324,6 @@ function BattleUI:clear()
self.bossEnterAniSeq:Kill() self.bossEnterAniSeq:Kill()
self.bossEnterAniSeq = nil self.bossEnterAniSeq = nil
end end
if self.showGridEffectSfxSid then
self:unscheduleGlobal(self.showGridEffectSfxSid)
self.showGridEffectSfxSid = nil
end
end end
return BattleUI return BattleUI

View File

@ -1,6 +1,7 @@
local GridCell = class("GridCell", BaseCell) local GridCell = class("GridCell", BaseCell)
function GridCell:refresh(gridEntity, curElement, skillPosId) function GridCell:refresh(gridEntity, curElement, skillPosId)
self:clearDoScale()
self.gridEntity = gridEntity self.gridEntity = gridEntity
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
local downBg = uiMap["grid_cell.touch_node.ani_node.down_bg"] local downBg = uiMap["grid_cell.touch_node.ani_node.down_bg"]
@ -215,6 +216,7 @@ function GridCell:showAni()
end end
function GridCell:hideAni() function GridCell:hideAni()
self:clearDoScale()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
if not self.aniComp then if not self.aniComp then
self.aniComp = uiMap["grid_cell.touch_node.ani_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR) self.aniComp = uiMap["grid_cell.touch_node.ani_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
@ -223,6 +225,20 @@ function GridCell:hideAni()
self:resetTranform() self:resetTranform()
end end
function GridCell:doScale(targetScale, time, callback)
self:clearDoScale()
self.doScaleSeq = self.baseObject:createBindTweenSequence()
self.doScaleSeq:Append(self.baseObject:getTransform():DOScale(targetScale, time))
self.doScaleSeq:AppendCallback(callback)
end
function GridCell:clearDoScale()
if self.doScaleSeq then
self.doScaleSeq:Kill()
self.doScaleSeq = nil
end
end
function GridCell:setOrder(uiOder) function GridCell:setOrder(uiOder)
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
for elementType, name in pairs(GConst.BattleConst.OUTLINE_SFX) do for elementType, name in pairs(GConst.BattleConst.OUTLINE_SFX) do