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,
}
BattleConst.GRID_TYPE_ICON = {
[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 = {
BattleConst.GRID_BREAK_CONDITION = {
ACOUND = 1,
LINE = 2,
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 = {
NONE = 0,
@ -728,12 +693,6 @@ BattleConst.OUTLINE_SFX = {
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.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"
return BattleConst

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@ function GridCell:refresh(gridEntity, curElement, skillPosId)
if self.lastGridType ~= gridEntity:getGridType() then
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)
end

View File

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

View File

@ -1,6 +1,8 @@
local BattleGridEntity = class("BattleGridEntity", BaseData)
local BattleConst = GConst.BattleConst
local GRID_TYPE_CFG = ConfigManager:getConfig("grid_type")
function BattleGridEntity:ctor(data)
self:clear()
self.posId = data.posId or 0
@ -9,6 +11,7 @@ function BattleGridEntity:ctor(data)
self.skillId = data.skillId
self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数
self.isIdle = false
self.breakCount = 0
self.data.isDirty = false
self:determineIdleStatus()
end
@ -19,6 +22,7 @@ function BattleGridEntity:clear()
self.skillId = nil
self.linkSkillCount = 0 -- 任意链接技能激活次数
self.isIdle = false
self.breakCount = 0
self.data.isDirty = false
end
@ -30,6 +34,7 @@ function BattleGridEntity:getSnapshoptInfo()
isIdle = self.isIdle,
skillId = self.skillId,
linkSkillCount = self.linkSkillCount,
breakCount = self.breakCount,
}
end
@ -40,6 +45,7 @@ function BattleGridEntity:setInfoBySnapshop(snapshot)
self.isIdle = snapshot.isIdle
self.skillId = snapshot.skillId
self.linkSkillCount = snapshot.linkSkillCount
self.breakCount = snapshot.breakCount
self:setDirty()
end
@ -68,7 +74,7 @@ function BattleGridEntity:getElementType(skillEntity)
end
function BattleGridEntity:isCantFallType()
return not self:isEmptyType()
return self:getGridTypeConfig().can_fall ~= 1
end
function BattleGridEntity:isObstacleType()
@ -80,28 +86,79 @@ function BattleGridEntity:isEmptyType()
end
function BattleGridEntity:isElmentTypeInvalid()
return BattleConst.ELEMENT_TYPE_INVALID[self.gridType] ~= nil
return self:getGridTypeConfig().element_invalid == 1
end
function BattleGridEntity:addAroundEliminationCount(boomType)
---- 返回值1为true 返回值2为是否为idle状态返回值1为false时没有返回值2
function BattleGridEntity:tryBreakGrid(boomTypes, onlyCheck)
if self:getIsIdle() then
if not onlyCheck then
self:setGridType(BattleConst.GRID_TYPE.EMPTY)
end
return false
end
local nextGridType = BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType]
local nextGridType = self:getNextGridType()
if nextGridType then
local beforeGridtype = self:getGridType()
if beforeGridtype == BattleConst.GRID_TYPE.VINES and boomType <= BattleConst.AROUND_BOOM_TYPE.ACOUND then
local canbreak = false
for boomType, _ in pairs(boomTypes) do
if self:canBreakByThisCondition(boomType) then
canbreak = true
break
end
end
if not canbreak then
return false
end
if not onlyCheck then
self:addBreakCount(1)
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 beforeGridtype ~= BattleConst.GRID_TYPE.ICE then
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
if not onlyCheck then
self:setDirty()
return true
return true, self:getIsIdle()
else
return true, true
end
end
function BattleGridEntity:getPos()
@ -128,7 +185,7 @@ function BattleGridEntity:canLink()
if self:getIsIdle() then
return false
end
return not BattleConst.CANT_LINK_GRID_TYPE[self.gridType]
return self:getGridTypeConfig().cant_link ~= 1
end
function BattleGridEntity:addPath(singlePath)
@ -148,8 +205,11 @@ function BattleGridEntity:clearPath()
end
function BattleGridEntity:setGridType(gridType)
if self.gridType ~= gridType then
self.gridType = gridType
self.breakCount = 0
self:setDirty()
end
end
function BattleGridEntity:setElementType(elementType)
@ -191,6 +251,17 @@ function BattleGridEntity:isNotObstacleIdle()
return false
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()
return self.needElimination
end
@ -242,4 +313,75 @@ function BattleGridEntity:setObstacleIcon(icon)
self.obstacleIcon = icon
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