Merge branch 'dev' of git.juzugame.com:b6-client/b6-lua into dev

This commit is contained in:
chenxi 2023-05-12 21:07:07 +08:00
commit 7e26dee2d3
10 changed files with 534 additions and 281 deletions

View File

@ -0,0 +1,66 @@
local grid_type = {
[0]={
["can_fall"]=1
},
[1]={
["icon"]="battle_hinder_4",
["can_fall"]=0,
["cant_link"]=1,
["element_invalid"]=1
},
[2]={
["icon"]="stone_2",
["next_type"]=0,
["break_condition"]={
1,
3
},
["break_count"]=1,
["cant_link"]=1,
["element_invalid"]=1,
["break_sfx"]="sfx_piece_za_b01"
},
[3]={
["icon"]="stone_1",
["next_type"]=2,
["break_condition"]={
1,
3
},
["break_count"]=2,
["cant_link"]=1,
["element_invalid"]=1,
["break_sfx"]="sfx_piece_za_b01"
},
[4]={
["icon"]="vine",
["next_type"]=0,
["break_condition"]={
2,
3
},
["break_count"]=2,
["break_sfx"]="sfx_piece_za_b03"
},
[5]={
["icon"]="ice",
["next_type"]=0,
["break_condition"]={
1,
3
},
["break_count"]=1,
["break_stay_element"]=1,
["cant_link"]=1,
["break_sfx"]="sfx_piece_za_b02"
},
[6]={
["icon"]="ice",
["can_fall"]=1,
["cant_link"]=1
}
}
local config = {
data=grid_type,count=7
}
return config

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c31a614f69d4d7e4397b5b92ba1fb4d2
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -362,47 +362,12 @@ BattleConst.GRID_TYPE = {
LOCK = 6, LOCK = 6,
} }
BattleConst.GRID_TYPE_ICON = { BattleConst.GRID_BREAK_CONDITION = {
[BattleConst.GRID_TYPE.SNOW_BOX] = "stone_2",
[BattleConst.GRID_TYPE.SOLID_SNOW] = "stone_1",
[BattleConst.GRID_TYPE.VINES] = "vine",
[BattleConst.GRID_TYPE.ICE] = "ice",
}
---- 周围格子或自己消除一次后会变成什么格子
BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT = {
[BattleConst.GRID_TYPE.SNOW_BOX] = BattleConst.GRID_TYPE.EMPTY,
[BattleConst.GRID_TYPE.SOLID_SNOW] = BattleConst.GRID_TYPE.SNOW_BOX,
[BattleConst.GRID_TYPE.VINES] = BattleConst.GRID_TYPE.EMPTY,
[BattleConst.GRID_TYPE.ICE] = BattleConst.GRID_TYPE.EMPTY,
}
BattleConst.ELEMENT_TYPE_INVALID = {
[BattleConst.GRID_TYPE.SNOW_BOX] = true,
[BattleConst.GRID_TYPE.SOLID_SNOW] = true,
}
BattleConst.AROUND_BOOM_TYPE = {
ACOUND = 1, ACOUND = 1,
LINE = 2, LINE = 2,
SKILL = 3, SKILL = 3,
} }
---- 不可下落的格子类型
BattleConst.CANT_FALL_GRID_TYPE = {
[BattleConst.GRID_TYPE.OBSTACLE] = true,
[BattleConst.GRID_TYPE.VINES] = true,
[BattleConst.GRID_TYPE.ICE] = true,
}
---- 不可链接的格子类型
BattleConst.CANT_LINK_GRID_TYPE = {
[BattleConst.GRID_TYPE.OBSTACLE] = true,
[BattleConst.GRID_TYPE.SNOW_BOX] = true,
[BattleConst.GRID_TYPE.SOLID_SNOW] = true,
[BattleConst.GRID_TYPE.ICE] = true,
}
---- 元素类型 ---- 元素类型
BattleConst.ELEMENT_TYPE = { BattleConst.ELEMENT_TYPE = {
NONE = 0, NONE = 0,
@ -728,12 +693,6 @@ 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.GRID_TYPE_BREAK_SFX = {
[BattleConst.GRID_TYPE.SNOW_BOX] = "assets/prefabs/effects/battle/sfx_piece_za_b01.prefab",
[BattleConst.GRID_TYPE.SOLID_SNOW] = "assets/prefabs/effects/battle/sfx_piece_za_b01.prefab",
[BattleConst.GRID_TYPE.VINES] = "assets/prefabs/effects/battle/sfx_piece_za_b03.prefab",
[BattleConst.GRID_TYPE.ICE] = "assets/prefabs/effects/battle/sfx_piece_za_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"
return BattleConst return BattleConst

View File

@ -106,14 +106,6 @@ function BattleManager:getElementIcon(elementType)
return GConst.ATLAS_PATH.BATTLE, icon return GConst.ATLAS_PATH.BATTLE, icon
end end
function BattleManager:getGridTypeIcon(gridType)
local icon = GConst.BattleConst.GRID_TYPE_ICON[gridType]
if not icon then
return GConst.ATLAS_PATH.COMMON, "common_alpha"
end
return GConst.ATLAS_PATH.BATTLE, icon
end
function BattleManager:getPosId(row, column) function BattleManager:getPosId(row, column)
if not BattleConst.RC_2_POS_ID[row] then if not BattleConst.RC_2_POS_ID[row] then
BattleConst.RC_2_POS_ID[row] = {} BattleConst.RC_2_POS_ID[row] = {}

View File

@ -13,6 +13,7 @@ local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle"
local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
local BUFF_NAME_TO_ATTR = BattleConst.BUFF_NAME_TO_ATTR local BUFF_NAME_TO_ATTR = BattleConst.BUFF_NAME_TO_ATTR
local GRID_BREAK_CONDITION = BattleConst.GRID_BREAK_CONDITION
-- *************各个子模块的战斗需要重写的方法 START************* -- *************各个子模块的战斗需要重写的方法 START*************
function BattleController:getChapterId() function BattleController:getChapterId()
@ -99,22 +100,26 @@ function BattleController:onLinkChange()
end end
local sequence = self.battleData:getGridSequence() local sequence = self.battleData:getGridSequence()
local elementTypeMap = {}
local posIdMap = {}
local mainElementType local mainElementType
local count = 0 local boomGridIds = {}
for _, info in ipairs(sequence) do
posIdMap[info.posId] = true
local entity = self.battleData:getGridEntity(info.posId)
if not entity:getSkillId() then for index, info in ipairs(sequence) do
local elementType = entity:getElementType() local entity = self.battleData:getGridEntity(info.posId)
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 if not mainElementType then
mainElementType = elementType local skillId = entity:getSkillId()
if not skillId then
mainElementType = entity:getElementType()
break
else
local skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
mainElementType = entity:getElementType(skillEntity)
break
end
end end
count = count + 1
end end
local count = #sequence
for index, info in ipairs(sequence) do for index, info in ipairs(sequence) do
local entity = self.battleData:getGridEntity(info.posId) local entity = self.battleData:getGridEntity(info.posId)
if entity:getCell() then if entity:getCell() then
@ -139,25 +144,36 @@ function BattleController:onLinkChange()
entity:getCell():showAni() entity:getCell():showAni()
end end
end end
self:setGridBreakCondition(boomGridIds, info.posId, GRID_BREAK_CONDITION.LINE)
end end
for posId, cell in pairs(needFalsePosMap) do for posId, cell in pairs(needFalsePosMap) do
cell:showHighLight(false) cell:showHighLight(false)
end end
local influenceMap = {}
for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do
local entity = self.battleData:getGridEntity(posId) local entity = self.battleData:getGridEntity(posId)
if not influenceMap[posId] and info.direction ~= BattleConst.BOARD_RANGE_TYPE.RANDOM then if info.direction ~= BattleConst.BOARD_RANGE_TYPE.RANDOM then
posIdMap[posId] = true
influenceMap[posId] = true
if not entity:getSkillId() then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
end
if entity:getCell() then if entity:getCell() then
entity:getCell():showCircle(true) entity:getCell():showCircle(true)
end end
self:setGridBreakCondition(boomGridIds, info.posId, GRID_BREAK_CONDITION.SKILL)
end
end
local elementTypeMap = {}
for posId, boomTypes in pairs(boomGridIds) do
local entity = self.battleData:getGridEntity(posId)
if entity then
local elementTypeInvalid = entity:isElmentTypeInvalid()
local breaked, isIdle = entity:tryBreakGrid(boomTypes, true)
if isIdle then
if not entity:getSkillId() and not elementTypeInvalid then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
end
end
end end
end end
@ -721,10 +737,7 @@ function BattleController:onLinkEnter(entity, posId, isVirtual)
local snapshot = self.battleData:removeGridSequence(lastPosId) local snapshot = self.battleData:removeGridSequence(lastPosId)
if snapshot then -- 如果有快照,则恢复一次 if snapshot then -- 如果有快照,则恢复一次
for posId, info in pairs(snapshot) do for posId, info in pairs(snapshot) do
local entity = self.battleData:getGridEntity(posId) self.battleData:setInfoBySnapshop(posId, info)
if entity then
entity:setInfoBySnapshop(info)
end
end end
end end
@ -847,10 +860,7 @@ function BattleController:clearGridSequence()
local snapshot = self.battleData:getFirstSequenceSnapshot() local snapshot = self.battleData:getFirstSequenceSnapshot()
if snapshot then -- 如果有快照,则恢复一次 if snapshot then -- 如果有快照,则恢复一次
for posId, info in pairs(snapshot) do for posId, info in pairs(snapshot) do
local entity = self.battleData:getGridEntity(posId) self.battleData:setInfoBySnapshop(posId, info)
if entity then
entity:setInfoBySnapshop(info)
end
end end
end end
@ -875,108 +885,79 @@ function BattleController:onLinkOver()
end end
local elementTypeMap = {} local elementTypeMap = {}
local eliminationPosIds = {}
local boomGridIds = {} local boomGridIds = {}
local lineCount = 0 local lineCount = 0
local skillPosId local skillPosId
local randomPosList local randomPosList
for _, info in ipairs(sequence) do for _, info in ipairs(sequence) do
if not eliminationPosIds[info.posId] then local entity = self.battleData:getGridEntity(info.posId)
local entity = self.battleData:getGridEntity(info.posId) if entity:getSkillId() then
if not entity:getSkillId() then skillPosId = info.posId
local elementType = entity:getElementType() else
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 linkElementType = entity:getElementType()
linkElementType = elementType end
lineCount = lineCount + 1 self:setGridBreakCondition(boomGridIds, info.posId, GRID_BREAK_CONDITION.LINE)
else
skillPosId = info.posId
end
boomGridIds[info.posId] = BattleConst.AROUND_BOOM_TYPE.LINE
local outline = BattleConst.UP_DOWN_LEFT_RIGHT[info.posId] local outline = BattleConst.UP_DOWN_LEFT_RIGHT[info.posId]
for _, aroundPosId in ipairs(outline) do for _, aroundPosId in ipairs(outline) do
if not boomGridIds[aroundPosId] then self:setGridBreakCondition(boomGridIds, aroundPosId, GRID_BREAK_CONDITION.ACOUND)
boomGridIds[aroundPosId] = BattleConst.AROUND_BOOM_TYPE.ACOUND
end
end
local entity = self.battleData:getGridEntity(info.posId)
entity:setIsIdle(true)
eliminationPosIds[info.posId] = true
end end
end end
sequence = {}
for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do
local entity = self.battleData:getGridEntity(posId) local entity = self.battleData:getGridEntity(posId)
if not entity:getIsIdle() then if not entity:getIsIdle() then
if entity:isEmptyIdle() then if entity:isEmptyIdle() then
entity:setIsIdle(true)
if not eliminationPosIds[posId] then
eliminationPosIds[posId] = true
table.insert(sequence, {posId = posId})
if not entity:getSkillId() then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
end
end
if info.direction == BattleConst.BOARD_RANGE_TYPE.RANDOM then if info.direction == BattleConst.BOARD_RANGE_TYPE.RANDOM then
if not randomPosList then if not randomPosList then
randomPosList = {} randomPosList = {}
end end
table.insert(randomPosList, posId) table.insert(randomPosList, posId)
end end
if not entity:getSkillId() then
local elementType = entity:getElementType()
if not influenceElementType then
influenceElementType = {}
end
influenceElementType[elementType] = true
end
else
boomGridIds[posId] = BattleConst.AROUND_BOOM_TYPE.SKILL
end end
self:setGridBreakCondition(boomGridIds, posId, GRID_BREAK_CONDITION.SKILL)
end end
end end
local gridBreakSfxInfo local gridBreakSfxInfo
for posId, boomType in pairs(boomGridIds) do for posId, boomTypes in pairs(boomGridIds) do
local entity = self.battleData:getGridEntity(posId) local entity = self.battleData:getGridEntity(posId)
if entity then if entity then
local gridType = entity:getGridType() local breakSfxName = entity:getBreakSfx()
local elementTypeInvalid = entity:isElmentTypeInvalid() local elementTypeInvalid = entity:isElmentTypeInvalid()
if entity:addAroundEliminationCount(boomType) then local breaked, isIdle = entity:tryBreakGrid(boomTypes)
if BattleConst.GRID_TYPE_BREAK_SFX[gridType] then if breaked then
if breakSfxName then
if not gridBreakSfxInfo then if not gridBreakSfxInfo then
gridBreakSfxInfo = {} gridBreakSfxInfo = {}
end end
if not gridBreakSfxInfo[gridType] then if not gridBreakSfxInfo[breakSfxName] then
gridBreakSfxInfo[gridType] = {} gridBreakSfxInfo[breakSfxName] = {}
end end
table.insert(gridBreakSfxInfo[gridType], posId) table.insert(gridBreakSfxInfo[breakSfxName], posId)
end end
end
if entity:getIsIdle() then if isIdle then
if not eliminationPosIds[posId] then table.insert(sequence, {posId = posId, noAni = elementTypeInvalid})
eliminationPosIds[posId] = true if not entity:getSkillId() and not elementTypeInvalid then
table.insert(sequence, {posId = posId, noAni = elementTypeInvalid}) local elementType = entity:getElementType()
if not entity:getSkillId() and not elementTypeInvalid then elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
local elementType = entity:getElementType() end
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
if not entity:getSkillId() then
if boomTypes[GRID_BREAK_CONDITION.SKILL] then
local elementType = entity:getElementType()
if not influenceElementType then
influenceElementType = {}
end end
influenceElementType[elementType] = true
end end
end
else if boomTypes[GRID_BREAK_CONDITION.LINE] then
if entity:getIsIdle() then lineCount = lineCount + 1
if BattleConst.GRID_TYPE_BREAK_SFX[gridType] then
if not gridBreakSfxInfo then
gridBreakSfxInfo = {}
end
if not gridBreakSfxInfo[gridType] then
gridBreakSfxInfo[gridType] = {}
end
table.insert(gridBreakSfxInfo[gridType], posId)
end end
end end
end end
@ -985,9 +966,9 @@ function BattleController:onLinkOver()
---- 播放碎裂特效 ---- 播放碎裂特效
if gridBreakSfxInfo then if gridBreakSfxInfo then
for gridType, list in pairs(gridBreakSfxInfo) do for breakSfxName, list in pairs(gridBreakSfxInfo) do
for index, posId in ipairs(list) do for index, posId in ipairs(list) do
self.battleUI:getSfxGridBreak(gridType, index, function(obj) self.battleUI:getSfxGridBreak(breakSfxName, index, function(obj)
local pos = ModuleManager.BattleManager:getPosInfo(posId) local pos = ModuleManager.BattleManager:getPosInfo(posId)
obj:setLocalScale(38, 38, 38) obj:setLocalScale(38, 38, 38)
obj:setLocalPosition(pos.x, pos.y, 0) obj:setLocalPosition(pos.x, pos.y, 0)
@ -1015,6 +996,19 @@ function BattleController:onLinkOver()
self.eliminateTotalCount = self.eliminateTotalCount + 1 self.eliminateTotalCount = self.eliminateTotalCount + 1
end end
function BattleController:setGridBreakCondition(gridMap, posId, condition)
if not gridMap[posId] then
gridMap[posId] = {}
gridMap[posId][condition] = true
return true
end
if gridMap[posId][condition] then
return false
end
gridMap[posId][condition] = true
return true
end
function BattleController:fillBoard(isRoundBeginCheck) function BattleController:fillBoard(isRoundBeginCheck)
local pathMap = {} local pathMap = {}
local columnCount = {} local columnCount = {}
@ -1821,8 +1815,8 @@ function BattleController:shuffleBoard(callback)
else else
local resetList = {} local resetList = {}
for posId, entity in pairs(self.battleData:getGridEnties()) do for posId, entity in pairs(self.battleData:getGridEnties()) do
if entity:isEmptyIdle() then if entity:isCanFallStatus() then
table.insert(resetList, posId) table.insert(resetList, entity)
end end
end end
local resetInfo = self:resetGrids(resetList) local resetInfo = self:resetGrids(resetList)
@ -1842,7 +1836,7 @@ function BattleController:shuffleBoard(callback)
self.resetGridSid = ModuleManager.BattleManager:performWithDelayGlobal(function() self.resetGridSid = ModuleManager.BattleManager:performWithDelayGlobal(function()
local count = 1 local count = 1
for posId, info in pairs(resetInfo) do for posId, info in pairs(resetInfo) do
self.battleData:setGridInfo(posId, info) self.battleData:setInfoBySnapshop(posId, info)
self.battleUI:playChangeElementSfx(posId, count) self.battleUI:playChangeElementSfx(posId, count)
count = count + 1 count = count + 1
end end
@ -1862,8 +1856,9 @@ function BattleController:getShuffleBoardInfo()
local posMap = {} local posMap = {}
local anySkillCount = 0 local anySkillCount = 0
local gridEntityCountMap = {} local gridEntityCountMap = {}
local gridEntityCantLinkMap = {}
for posId, entity in pairs(self.battleData:getGridEnties()) do for posId, entity in pairs(self.battleData:getGridEnties()) do
if not entity:isCantFallType() and not entity:getIsIdle() then if entity:isCanFallStatus() then
if entity:getSkillId() then if entity:getSkillId() then
local skillEntity = self.battleData:getSkillEntityBySkillId(entity:getSkillId()) local skillEntity = self.battleData:getSkillEntityBySkillId(entity:getSkillId())
local elementType = skillEntity:getPosition() local elementType = skillEntity:getPosition()
@ -1885,6 +1880,9 @@ function BattleController:getShuffleBoardInfo()
end end
table.insert(gridEntityList[elementType], entity) table.insert(gridEntityList[elementType], entity)
gridEntityCountMap[elementType] = (gridEntityCountMap[elementType] or 0) + 1 gridEntityCountMap[elementType] = (gridEntityCountMap[elementType] or 0) + 1
if not entity:canLink() then
gridEntityCantLinkMap[elementType] = (gridEntityCountMap[elementType] or 0) + 1
end
end end
table.insert(posList, posId) table.insert(posList, posId)
posMap[posId] = true posMap[posId] = true
@ -1909,30 +1907,44 @@ function BattleController:getShuffleBoardInfo()
local find = false local find = false
for elementType, list in pairs(gridEntityList) do for elementType, list in pairs(gridEntityList) do
local count = gridEntityCountMap[elementType] or 0 local count = gridEntityCountMap[elementType] or 0
if count + anySkillCount >= needCount then local cantLinkCount = gridEntityCantLinkMap[elementType] or 0
local skillCount = 0
if anySkillCount > 0 then
skillCount = 1
end
if count + skillCount - cantLinkCount >= needCount then
local haveSkill = false local haveSkill = false
local listCount = 0 local listCount = 0
tempList = {} tempList = {}
find = false find = false
local add = false
for _, entity in ipairs(list) do for _, entity in ipairs(list) do
if entity:getSkillId() and haveSkill then add = false
break if haveSkill then
if not entity:getSkillId() then
add = entity:canLink()
end
else
if entity:getSkillId() then
haveSkill = true
add = entity:canLink()
end
end end
if entity:getSkillId() then if add then
haveSkill = true table.insert(tempList, entity)
end listCount = listCount + 1
table.insert(tempList, entity)
listCount = listCount + 1 if listCount >= needCount then -- 可连接的 普通的元素+元素技能
if listCount >= needCount then -- 普通的元素+元素技能 find = true
find = true break
break end
end end
end end
if listCount >= needCount then -- 普通的元素+元素技能 if listCount >= needCount then -- 可连接的 普通的元素+元素技能
find = true find = true
break break
elseif not haveSkill and anySkillCount > 0 then -- 普通元素 + 任意元素技能 elseif not haveSkill and skillCount > 0 then -- 可连接的 普通元素 + 任意元素技能
table.insert(tempList, anySkillList[1]) table.insert(tempList, anySkillList[1])
listCount = listCount + 1 listCount = listCount + 1
if listCount >= needCount then if listCount >= needCount then
@ -1949,44 +1961,9 @@ function BattleController:getShuffleBoardInfo()
end end
function BattleController:shufflePos(tempList, posMap, needCount, posList) function BattleController:shufflePos(tempList, posMap, needCount, posList)
local list = {} local gotPos, useMap, list = self:findCanLinkPosList(posMap, needCount)
local count = 0
local gotPos = false
for posId, status in pairs(posMap) do
list = {}
count = 0
local findPodId = posId
local temp = {}
while true do
local aounrdList = BattleConst.GRID_OUT_LINE_POS_ID[findPodId]
if not aounrdList then
break
end
local got = false
for id, status in pairs(aounrdList) do
if posMap[id] and not temp[id] then
table.insert(list, id)
count = count + 1
temp[id] = true
findPodId = id
got = true
break
end
end
if not got then
break
end
if count >= needCount then
gotPos = true
break
end
end
if gotPos then
break
end
end
if gotPos then if gotPos and list[1] then
local changeInfo = {} local changeInfo = {}
local usedPos = {} local usedPos = {}
local setedPos = {} local setedPos = {}
@ -2047,23 +2024,148 @@ function BattleController:findAttention()
return find, pathList return find, pathList
end end
function BattleController:_dealResetGridsDataFunc(posList)
local posMap = {}
local lockElementMap = {}
local emptyCount = 0
local keepSnapList = {}
local keepSnapSkillList = {}
local emptySnapList = {}
for _, entity in ipairs(posList) do
local posId = entity:getPosId()
posMap[posId] = entity
if entity:isEmptyIdle() then
emptyCount = emptyCount + 1
table.insert(emptySnapList, entity:getSnapshoptInfo())
elseif entity:isLock() and not entity:getSkillId() then
lockElementMap[entity:getElementType()] = true
emptyCount = emptyCount + 1
local snapInfo = entity:getSnapshoptInfo()
snapInfo.gridType = BattleConst.GRID_TYPE.EMPTY
table.insert(emptySnapList, snapInfo)
else
if entity:getSkillId() then
table.insert(keepSnapSkillList, entity:getSnapshoptInfo())
else
table.insert(keepSnapList, entity:getSnapshoptInfo())
end
end
end
return posMap, lockElementMap, emptyCount, keepSnapList, keepSnapSkillList, emptySnapList
end
function BattleController:_dealResetGridsDataFunc2(useMap, emptySnapList, mainElement, backupSkill, keepSnapList, posMap, canRandomElmentList, elementCount, lockElementMap)
local resetPosInfo = {}
for posId, _ in pairs(useMap) do
local snapInfo
if emptySnapList[1] then
snapInfo = table.remove(emptySnapList)
snapInfo.elementType = mainElement
snapInfo.posId = posId
snapInfo.gridType = BattleConst.GRID_TYPE.EMPTY
else
snapInfo = backupSkill
end
resetPosInfo[posId] = snapInfo
end
for _, snap in ipairs(emptySnapList) do
table.insert(keepSnapList, snap)
end
keepSnapList = table.shuffle(keepSnapList)
for posId, entity in pairs(posMap) do
if not useMap[posId] then
local snapInfo
if keepSnapList[1] then
snapInfo = table.remove(keepSnapList)
snapInfo.posId = posId
if not snapInfo.skillId or snapInfo.skillId <= 0 then
if snapInfo.gridType == BattleConst.GRID_TYPE.EMPTY then
snapInfo.elementType = canRandomElmentList[math.random(1, elementCount)]
if lockElementMap[snapInfo.elementType] then
snapInfo.gridType = BattleConst.GRID_TYPE.LOCK
end
end
end
end
if snapInfo then
resetPosInfo[posId] = snapInfo
end
end
end
return resetPosInfo
end
function BattleController:resetGrids(posList) function BattleController:resetGrids(posList)
local needCount = self:getMinEliminationCount() local needCount = self:getMinEliminationCount()
if not posList[needCount] then if not posList[needCount] then
return return
end end
local posMap = {} local posMap, lockElementMap, emptyCount, keepSnapList, keepSnapSkillList, emptySnapList = self:_dealResetGridsDataFunc(posList)
for _, posId in ipairs(posList) do
posMap[posId] = true local canUseSkillCount = 0
if keepSnapSkillList[1] then -- 技能可以直接链接, 不判断元素技能了
canUseSkillCount = 1
end end
if emptyCount + canUseSkillCount < needCount then -- 格子不够
return
end
local backupSkill
if emptyCount < needCount then
backupSkill = table.remove(keepSnapSkillList)
end
for _, snap in ipairs(keepSnapSkillList) do
table.insert(keepSnapList, snap)
end
local gotPos, useMap = self:findCanLinkPosList(posMap, needCount)
if not gotPos then
return
end
local canRandomElmentList = {}
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
if not lockElementMap[typeNum] and not self:getSealElementType()[typeNum] and self.battleData:getSkillEntityByElement(typeNum) then
table.insert(canRandomElmentList, typeNum)
end
end
if not canRandomElmentList[1] then
return
end
local elementCount = #canRandomElmentList
local mainElement = canRandomElmentList[math.random(1, elementCount)]
for typeNum, _ in pairs(lockElementMap) do
table.insert(canRandomElmentList, typeNum)
elementCount = elementCount + 1
end
local resetPosInfo = self:_dealResetGridsDataFunc2(useMap, emptySnapList, mainElement, backupSkill, keepSnapList, posMap, canRandomElmentList, elementCount, lockElementMap)
return resetPosInfo
end
function BattleController:findCanLinkPosList(posMap, needCount)
local list = {}
local useMap = {} local useMap = {}
local gotPosList = false local gotPos = false
for _, posId in ipairs(posList) do for posId, _ in pairs(posMap) do
list = {}
useMap = {} useMap = {}
local count = 0 local count = 0
local findPodId = posId local findPodId = posId
gotPosList = false gotPos = false
while true do while true do
local aounrdList = BattleConst.GRID_OUT_LINE_POS_ID[findPodId] local aounrdList = BattleConst.GRID_OUT_LINE_POS_ID[findPodId]
if not aounrdList then if not aounrdList then
@ -2072,6 +2174,7 @@ function BattleController:resetGrids(posList)
local got = false local got = false
for id, status in pairs(aounrdList) do for id, status in pairs(aounrdList) do
if posMap[id] and not useMap[id] then if posMap[id] and not useMap[id] then
table.insert(list, id)
count = count + 1 count = count + 1
useMap[id] = true useMap[id] = true
findPodId = id findPodId = id
@ -2083,43 +2186,17 @@ function BattleController:resetGrids(posList)
break break
end end
if count >= needCount then if count >= needCount then
gotPosList = true gotPos = true
break break
end end
end end
if gotPosList then if gotPos then
break break
end end
end end
if not gotPosList then return gotPos, useMap, list
return
end
local canRandomElmentList = {}
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
if not self:getSealElementType()[typeNum] and self.battleData:getSkillEntityByElement(typeNum) then
table.insert(canRandomElmentList, typeNum)
end
end
if not canRandomElmentList[1] then
return
end
local elementCount = #canRandomElmentList
local mainElement = canRandomElmentList[math.random(1, elementCount)]
local resetPosInfo = {}
for posId, _ in pairs(posMap) do
if useMap[posId] then
resetPosInfo[posId] = {gridType = BattleConst.GRID_TYPE.EMPTY, elementType = mainElement}
else
resetPosInfo[posId] = {gridType = BattleConst.GRID_TYPE.EMPTY, elementType = canRandomElmentList[math.random(1, elementCount)]}
end
end
return resetPosInfo
end end
function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementType, lineList) function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementType, lineList)

View File

@ -54,6 +54,12 @@ Example: time_diff 0]],
Example: add_time_diff 1000]], Example: add_time_diff 1000]],
type = "add_time_diff" type = "add_time_diff"
}, },
{
title = "挑战章节",
desc = [[ type:chapter
Example: chapter 5 10 1 2 ]],
type = "chapter"
},
} }
return GMConst return GMConst

View File

@ -1457,8 +1457,8 @@ function BattleUI:hideAllSfxLine()
end end
end end
function BattleUI:getSfxGridBreak(gridType, index, func) function BattleUI:getSfxGridBreak(breakSfxPath, index, func)
if not GConst.BattleConst.GRID_TYPE_BREAK_SFX[gridType] then if not breakSfxPath then
return return
end end
@ -1467,21 +1467,21 @@ function BattleUI:getSfxGridBreak(gridType, index, func)
if not self.root.gridBreakSfxObjs then if not self.root.gridBreakSfxObjs then
self.root.gridBreakSfxObjs = {} self.root.gridBreakSfxObjs = {}
end end
if not self.root.gridBreakSfxObjs[gridType] then if not self.root.gridBreakSfxObjs[breakSfxPath] then
self.root.gridBreakSfxObjs[gridType] = {} self.root.gridBreakSfxObjs[breakSfxPath] = {}
end end
if self.root.gridBreakSfxObjs[gridType][index] then if self.root.gridBreakSfxObjs[breakSfxPath][index] then
if self.root.gridBreakSfxObjs[gridType][index].obj and func then if self.root.gridBreakSfxObjs[breakSfxPath][index].obj and func then
local obj = self.root.gridBreakSfxObjs[gridType][index].obj local obj = self.root.gridBreakSfxObjs[breakSfxPath][index].obj
obj:setActive(true) obj:setActive(true)
func(obj) func(obj)
end end
else else
self.root.gridBreakSfxObjs[gridType][index] = { self.root.gridBreakSfxObjs[breakSfxPath][index] = {
isLoaded = true isLoaded = true
} }
EffectManager:loadUIEffectAsync(GConst.BattleConst.GRID_TYPE_BREAK_SFX[gridType], self, self.gridNode, GConst.UI_EFFECT_ORDER.LEVEL1, function(obj) EffectManager:loadUIEffectAsync(breakSfxPath, self, self.gridNode, GConst.UI_EFFECT_ORDER.LEVEL1, function(obj)
self.root.gridBreakSfxObjs[gridType][index].obj = obj self.root.gridBreakSfxObjs[breakSfxPath][index].obj = obj
if self.hidingAllSfxGridBreak then if self.hidingAllSfxGridBreak then
obj:setActive(false) obj:setActive(false)
else else
@ -1498,7 +1498,7 @@ function BattleUI:hideAllSfxGridBreak()
if not self.root.gridBreakSfxObjs then if not self.root.gridBreakSfxObjs then
return return
end end
for gridType, map in pairs(self.root.gridBreakSfxObjs) do for breakSfxPath, map in pairs(self.root.gridBreakSfxObjs) do
for index, info in pairs(map) do for index, info in pairs(map) do
if info.obj then if info.obj then
info.obj:setActive(false) info.obj:setActive(false)
@ -1698,7 +1698,7 @@ end
function BattleUI:initUISfxs() function BattleUI:initUISfxs()
if self.root.gridBreakSfxObjs then if self.root.gridBreakSfxObjs then
for gridType, map in pairs(self.root.gridBreakSfxObjs) do for breakSfxPath, map in pairs(self.root.gridBreakSfxObjs) do
for index, info in pairs(map) do for index, info in pairs(map) do
if info.obj then if info.obj then
info.obj:setActive(true) info.obj:setActive(true)
@ -1832,7 +1832,7 @@ function BattleUI:hideAllBoardSfxs()
end end
if self.root.gridBreakSfxObjs then if self.root.gridBreakSfxObjs then
for gridType, map in pairs(self.root.gridBreakSfxObjs) do for breakSfxPath, map in pairs(self.root.gridBreakSfxObjs) do
for index, info in pairs(map) do for index, info in pairs(map) do
if info.obj then if info.obj then
info.obj:setActive(false) info.obj:setActive(false)

View File

@ -29,7 +29,7 @@ function GridCell:refresh(gridEntity, curElement, skillPosId)
if self.lastGridType ~= gridEntity:getGridType() then if self.lastGridType ~= gridEntity:getGridType() then
self.lastGridType = gridEntity:getGridType() self.lastGridType = gridEntity:getGridType()
local atlas, icon = ModuleManager.BattleManager:getGridTypeIcon(self.lastGridType) local atlas, icon = gridEntity:getIcon()
uiMap["grid_cell.touch_node.ani_node.up_bg"]:setSprite(atlas, icon) uiMap["grid_cell.touch_node.ani_node.up_bg"]:setSprite(atlas, icon)
end end

View File

@ -127,7 +127,6 @@ function BattleData:initRogueSkills()
end end
function BattleData:refreshBoard(board, blockIcon) function BattleData:refreshBoard(board, blockIcon)
self.elementTypeMap = {}
for i, info in ipairs(board) do for i, info in ipairs(board) do
local r = 1 local r = 1
local c = 1 local c = 1
@ -154,9 +153,6 @@ function BattleData:refreshBoard(board, blockIcon)
else else
self.gridEntities[data.posId] = BATTLE_GRID_ENTITY:create(data) self.gridEntities[data.posId] = BATTLE_GRID_ENTITY:create(data)
end end
if self.gridEntities[data.posId]:canLink() then
self.elementTypeMap[data.elementType] = (self.elementTypeMap[data.elementType] or 0) + 1
end
self.gridEntities[data.posId]:determineIdleStatus() self.gridEntities[data.posId]:determineIdleStatus()
self.gridEntities[data.posId]:setObstacleIcon(blockIcon) self.gridEntities[data.posId]:setObstacleIcon(blockIcon)
end end
@ -175,13 +171,21 @@ function BattleData:clear()
self:clearGridSequence() self:clearGridSequence()
self.gridEntities = {} self.gridEntities = {}
self.elementTypeMap = {} -- 同元素得格子数量
self.skillMap = {} self.skillMap = {}
self.selectSkillMap = {} self.selectSkillMap = {}
end end
function BattleData:getElementTypeMap() function BattleData:getElementTypeMap()
return self.elementTypeMap local elementTypeMap = {}
if self.gridEntities then
for posId, entity in pairs(self.gridEntities) do
if entity:canLink() then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
end
end
end
return elementTypeMap
end end
function BattleData:getGridSequence() function BattleData:getGridSequence()
@ -306,29 +310,26 @@ function BattleData:setGridInfo(posId, gridInfo)
return return
end end
if entity:canLink() then
local elementType = entity:getElementType()
self.elementTypeMap[elementType] = (self.elementTypeMap[elementType] or 0) - 1
if self.elementTypeMap[elementType] < 0 then
self.elementTypeMap[elementType] = 0
end
end
if gridInfo.gridType then if gridInfo.gridType then
entity:setGridType(gridInfo.gridType) entity:setGridType(gridInfo.gridType)
end end
if gridInfo.elementType then if gridInfo.elementType then
entity:setElementType(gridInfo.elementType) entity:setElementType(gridInfo.elementType)
if entity:canLink() then
self.elementTypeMap[gridInfo.elementType] = (self.elementTypeMap[gridInfo.elementType] or 0) + 1
end
end end
entity:setSkilId() -- 清除skillId entity:setSkilId() -- 清除skillId
entity:determineIdleStatus() entity:determineIdleStatus()
end end
function BattleData:setInfoBySnapshop(posId, snapInfo)
local entity = self.gridEntities[posId]
if not entity then
return
end
entity:setInfoBySnapshop(snapInfo)
end
function BattleData:getSkillEntities() function BattleData:getSkillEntities()
return self.skillMap return self.skillMap
end end

View File

@ -1,6 +1,8 @@
local BattleGridEntity = class("BattleGridEntity", BaseData) local BattleGridEntity = class("BattleGridEntity", BaseData)
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
local GRID_TYPE_CFG = ConfigManager:getConfig("grid_type")
function BattleGridEntity:ctor(data) function BattleGridEntity:ctor(data)
self:clear() self:clear()
self.posId = data.posId or 0 self.posId = data.posId or 0
@ -9,6 +11,7 @@ function BattleGridEntity:ctor(data)
self.skillId = data.skillId self.skillId = data.skillId
self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数 self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数
self.isIdle = false self.isIdle = false
self.breakCount = 0
self.data.isDirty = false self.data.isDirty = false
self:determineIdleStatus() self:determineIdleStatus()
end end
@ -19,6 +22,7 @@ function BattleGridEntity:clear()
self.skillId = nil self.skillId = nil
self.linkSkillCount = 0 -- 任意链接技能激活次数 self.linkSkillCount = 0 -- 任意链接技能激活次数
self.isIdle = false self.isIdle = false
self.breakCount = 0
self.data.isDirty = false self.data.isDirty = false
end end
@ -30,6 +34,7 @@ function BattleGridEntity:getSnapshoptInfo()
isIdle = self.isIdle, isIdle = self.isIdle,
skillId = self.skillId, skillId = self.skillId,
linkSkillCount = self.linkSkillCount, linkSkillCount = self.linkSkillCount,
breakCount = self.breakCount,
} }
end end
@ -40,6 +45,7 @@ function BattleGridEntity:setInfoBySnapshop(snapshot)
self.isIdle = snapshot.isIdle self.isIdle = snapshot.isIdle
self.skillId = snapshot.skillId self.skillId = snapshot.skillId
self.linkSkillCount = snapshot.linkSkillCount self.linkSkillCount = snapshot.linkSkillCount
self.breakCount = snapshot.breakCount
self:setDirty() self:setDirty()
end end
@ -68,7 +74,7 @@ function BattleGridEntity:getElementType(skillEntity)
end end
function BattleGridEntity:isCantFallType() function BattleGridEntity:isCantFallType()
return not self:isEmptyType() return self:getGridTypeConfig().can_fall ~= 1
end end
function BattleGridEntity:isObstacleType() function BattleGridEntity:isObstacleType()
@ -80,28 +86,79 @@ function BattleGridEntity:isEmptyType()
end end
function BattleGridEntity:isElmentTypeInvalid() function BattleGridEntity:isElmentTypeInvalid()
return BattleConst.ELEMENT_TYPE_INVALID[self.gridType] ~= nil return self:getGridTypeConfig().element_invalid == 1
end end
function BattleGridEntity:addAroundEliminationCount(boomType) ---- 返回值1为true 返回值2为是否为idle状态返回值1为false时没有返回值2
function BattleGridEntity:tryBreakGrid(boomTypes, onlyCheck)
if self:getIsIdle() then if self:getIsIdle() then
self:setGridType(BattleConst.GRID_TYPE.EMPTY) if not onlyCheck then
self:setGridType(BattleConst.GRID_TYPE.EMPTY)
end
return false return false
end end
local nextGridType = BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType] local nextGridType = self:getNextGridType()
if nextGridType then if nextGridType then
local beforeGridtype = self:getGridType() local canbreak = false
if beforeGridtype == BattleConst.GRID_TYPE.VINES and boomType <= BattleConst.AROUND_BOOM_TYPE.ACOUND then for boomType, _ in pairs(boomTypes) do
if self:canBreakByThisCondition(boomType) then
canbreak = true
break
end
end
if not canbreak then
return false return false
end end
self:setGridType(nextGridType) if not onlyCheck then
if nextGridType == BattleConst.GRID_TYPE.EMPTY and beforeGridtype ~= BattleConst.GRID_TYPE.ICE then self:addBreakCount(1)
self:setIsIdle(true) if self:getBreakCount() < self:getCfgBreakCount() then
self:setDirty()
return false
end
local breakStayElement = self:getBreakStayElement()
self:setGridType(nextGridType)
if nextGridType == BattleConst.GRID_TYPE.EMPTY and not breakStayElement then
self:setIsIdle(true)
end
else
if self:getBreakCount() + 1 < self:getCfgBreakCount() then
return false
end
local breakStayElement = self:getBreakStayElement()
if nextGridType == BattleConst.GRID_TYPE.EMPTY and not breakStayElement then
return true, true
else
return true, false
end
end
else
if self:getSkillId() then
if boomTypes[BattleConst.GRID_BREAK_CONDITION.LINE] then -- 技能破碎逻辑为,链接消除
if not onlyCheck then
self:setIsIdle(true)
end
else
return false
end
else
if self:isEmptyIdle() and (boomTypes[BattleConst.GRID_BREAK_CONDITION.LINE] or boomTypes[BattleConst.GRID_BREAK_CONDITION.SKILL]) then -- 空类型/带技能破碎逻辑为,链接消除 置为闲置即消除
if not onlyCheck then
self:setIsIdle(true)
end
else -- 不可破碎类型
return false
end
end end
end end
self:setDirty() if not onlyCheck then
return true self:setDirty()
return true, self:getIsIdle()
else
return true, true
end
end end
function BattleGridEntity:getPos() function BattleGridEntity:getPos()
@ -128,7 +185,7 @@ function BattleGridEntity:canLink()
if self:getIsIdle() then if self:getIsIdle() then
return false return false
end end
return not BattleConst.CANT_LINK_GRID_TYPE[self.gridType] return self:getGridTypeConfig().cant_link ~= 1
end end
function BattleGridEntity:addPath(singlePath) function BattleGridEntity:addPath(singlePath)
@ -148,8 +205,11 @@ function BattleGridEntity:clearPath()
end end
function BattleGridEntity:setGridType(gridType) function BattleGridEntity:setGridType(gridType)
self.gridType = gridType if self.gridType ~= gridType then
self:setDirty() self.gridType = gridType
self.breakCount = 0
self:setDirty()
end
end end
function BattleGridEntity:setElementType(elementType) function BattleGridEntity:setElementType(elementType)
@ -191,6 +251,17 @@ function BattleGridEntity:isNotObstacleIdle()
return false return false
end end
function BattleGridEntity:isCanFallStatus()
if not self:isCantFallType() and not self:getIsIdle() then
return true
end
return false
end
function BattleGridEntity:isLock()
return self.gridType == BattleConst.GRID_TYPE.LOCK
end
function BattleGridEntity:getNeedElimination() function BattleGridEntity:getNeedElimination()
return self.needElimination return self.needElimination
end end
@ -242,4 +313,75 @@ function BattleGridEntity:setObstacleIcon(icon)
self.obstacleIcon = icon self.obstacleIcon = icon
end end
function BattleGridEntity:getGridTypeConfig()
if not self.gridCfg or self.lastGridType ~= self.gridType then
self.lastGridType = self.gridType
self.gridCfg = GRID_TYPE_CFG[self.lastGridType]
self.breakConditionMap = {}
if self.gridCfg.break_condition then
for _, condition in ipairs(self.gridCfg.break_condition) do
self.breakConditionMap[condition] = true
end
end
end
return self.gridCfg
end
function BattleGridEntity:getNextGridType()
return self:getGridTypeConfig().next_type
end
function BattleGridEntity:getIcon()
local icon = self:getGridTypeConfig().icon
if not icon then
return GConst.ATLAS_PATH.COMMON, "common_alpha"
end
return GConst.ATLAS_PATH.BATTLE, icon
end
function BattleGridEntity:getBreakSfx()
local sfxName = self:getGridTypeConfig().break_sfx
if not sfxName then
return
end
if not self.cacheBreakSfxPaths then
self.cacheBreakSfxPaths = {}
end
if not self.cacheBreakSfxPaths[sfxName] then
self.cacheBreakSfxPaths[sfxName] = "assets/prefabs/effects/battle/" .. sfxName .. ".prefab"
end
return self.cacheBreakSfxPaths[sfxName]
end
function BattleGridEntity:getBreakConditionMap()
self:getGridTypeConfig()
return self.breakConditionMap
end
function BattleGridEntity:canBreakByThisCondition(condition)
self:getGridTypeConfig()
if not self.breakConditionMap then
return false
end
return self.breakConditionMap[condition] == true
end
function BattleGridEntity:getBreakStayElement()
return self:getGridTypeConfig().break_stay_element == 1
end
function BattleGridEntity:getCfgBreakCount()
return self:getGridTypeConfig().break_count or 0
end
function BattleGridEntity:getBreakCount()
return self.breakCount
end
function BattleGridEntity:addBreakCount(count)
self.breakCount = self.breakCount + count
end
return BattleGridEntity return BattleGridEntity