格子类型的一些配置改为配置表控制

This commit is contained in:
xiekaidong 2023-05-12 11:43:49 +08:00
parent c44ce67f07
commit 39a2eee61a
9 changed files with 203 additions and 87 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,
@ -726,12 +691,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

@ -892,12 +892,12 @@ function BattleController:onLinkOver()
else else
skillPosId = info.posId skillPosId = info.posId
end end
boomGridIds[info.posId] = BattleConst.AROUND_BOOM_TYPE.LINE boomGridIds[info.posId] = BattleConst.GRID_BREAK_CONDITION.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 if not boomGridIds[aroundPosId] then
boomGridIds[aroundPosId] = BattleConst.AROUND_BOOM_TYPE.ACOUND boomGridIds[aroundPosId] = BattleConst.GRID_BREAK_CONDITION.ACOUND
end end
end end
@ -935,7 +935,7 @@ function BattleController:onLinkOver()
influenceElementType[elementType] = true influenceElementType[elementType] = true
end end
else else
boomGridIds[posId] = BattleConst.AROUND_BOOM_TYPE.SKILL boomGridIds[posId] = BattleConst.GRID_BREAK_CONDITION.SKILL
end end
end end
end end
@ -944,17 +944,17 @@ function BattleController:onLinkOver()
for posId, boomType in pairs(boomGridIds) do for posId, boomType 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 if entity:tryBreakGrid(boomType) then
if BattleConst.GRID_TYPE_BREAK_SFX[gridType] 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
if entity:getIsIdle() then if entity:getIsIdle() then
@ -969,14 +969,14 @@ function BattleController:onLinkOver()
end end
else else
if entity:getIsIdle() then if entity:getIsIdle() then
if BattleConst.GRID_TYPE_BREAK_SFX[gridType] 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 end
end end
@ -985,9 +985,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)

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

@ -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,23 +86,28 @@ 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) function BattleGridEntity:tryBreakGrid(boomType)
if self:getIsIdle() then if self:getIsIdle() then
self:setGridType(BattleConst.GRID_TYPE.EMPTY) self:setGridType(BattleConst.GRID_TYPE.EMPTY)
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() if not self:canBreakByThisCondition(boomType) then
if beforeGridtype == BattleConst.GRID_TYPE.VINES and boomType <= BattleConst.AROUND_BOOM_TYPE.ACOUND then
return false return false
end end
self:addBreakCount(1)
if self:getBreakCount() < self:getCfgBreakCount() then
return false
end
local breakStayElement = self:getBreakStayElement()
self:setGridType(nextGridType) 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) self:setIsIdle(true)
end end
end end
@ -128,7 +139,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)
@ -149,6 +160,7 @@ end
function BattleGridEntity:setGridType(gridType) function BattleGridEntity:setGridType(gridType)
self.gridType = gridType self.gridType = gridType
self.breakCount = 0
self:setDirty() self:setDirty()
end end
@ -242,4 +254,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