From 39a2eee61adba17bfb74d14bdc58483e78752845 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Fri, 12 May 2023 11:43:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=AD=90=E7=B1=BB=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E9=85=8D=E7=BD=AE=E6=94=B9=E4=B8=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=A1=A8=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/config/grid_type.lua | 66 +++++++++++++ lua/app/config/grid_type.lua.meta | 10 ++ lua/app/module/battle/battle_const.lua | 43 +------- lua/app/module/battle/battle_manager.lua | 8 -- .../battle/controller/battle_controller.lua | 30 +++--- lua/app/module/gm/gm_const.lua | 6 ++ lua/app/ui/battle/battle_ui.lua | 26 ++--- lua/app/ui/battle/cell/grid_cell.lua | 2 +- .../userdata/battle/battle_grid_entity.lua | 99 +++++++++++++++++-- 9 files changed, 203 insertions(+), 87 deletions(-) create mode 100644 lua/app/config/grid_type.lua create mode 100644 lua/app/config/grid_type.lua.meta diff --git a/lua/app/config/grid_type.lua b/lua/app/config/grid_type.lua new file mode 100644 index 00000000..4c35925e --- /dev/null +++ b/lua/app/config/grid_type.lua @@ -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 \ No newline at end of file diff --git a/lua/app/config/grid_type.lua.meta b/lua/app/config/grid_type.lua.meta new file mode 100644 index 00000000..8095e791 --- /dev/null +++ b/lua/app/config/grid_type.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c31a614f69d4d7e4397b5b92ba1fb4d2 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 69064439..40793fa4 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -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, @@ -726,12 +691,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 \ No newline at end of file diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index eaca0ae0..5eed3db4 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -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] = {} diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 0df29d44..b52cdd01 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -892,12 +892,12 @@ function BattleController:onLinkOver() else skillPosId = info.posId 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] for _, aroundPosId in ipairs(outline) do if not boomGridIds[aroundPosId] then - boomGridIds[aroundPosId] = BattleConst.AROUND_BOOM_TYPE.ACOUND + boomGridIds[aroundPosId] = BattleConst.GRID_BREAK_CONDITION.ACOUND end end @@ -935,7 +935,7 @@ function BattleController:onLinkOver() influenceElementType[elementType] = true end else - boomGridIds[posId] = BattleConst.AROUND_BOOM_TYPE.SKILL + boomGridIds[posId] = BattleConst.GRID_BREAK_CONDITION.SKILL end end end @@ -944,17 +944,17 @@ function BattleController:onLinkOver() for posId, boomType in pairs(boomGridIds) do local entity = self.battleData:getGridEntity(posId) if entity then - local gridType = entity:getGridType() + local breakSfxName = entity:getBreakSfx() local elementTypeInvalid = entity:isElmentTypeInvalid() - if entity:addAroundEliminationCount(boomType) then - if BattleConst.GRID_TYPE_BREAK_SFX[gridType] then + if entity:tryBreakGrid(boomType) then + if breakSfxName then if not gridBreakSfxInfo then gridBreakSfxInfo = {} end - if not gridBreakSfxInfo[gridType] then - gridBreakSfxInfo[gridType] = {} + if not gridBreakSfxInfo[breakSfxName] then + gridBreakSfxInfo[breakSfxName] = {} end - table.insert(gridBreakSfxInfo[gridType], posId) + table.insert(gridBreakSfxInfo[breakSfxName], posId) end if entity:getIsIdle() then @@ -969,14 +969,14 @@ function BattleController:onLinkOver() end else if entity:getIsIdle() then - if BattleConst.GRID_TYPE_BREAK_SFX[gridType] then + if breakSfxName then if not gridBreakSfxInfo then gridBreakSfxInfo = {} end - if not gridBreakSfxInfo[gridType] then - gridBreakSfxInfo[gridType] = {} + if not gridBreakSfxInfo[breakSfxName] then + gridBreakSfxInfo[breakSfxName] = {} end - table.insert(gridBreakSfxInfo[gridType], posId) + table.insert(gridBreakSfxInfo[breakSfxName], posId) end end end @@ -985,9 +985,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) diff --git a/lua/app/module/gm/gm_const.lua b/lua/app/module/gm/gm_const.lua index 62ed2290..5ab9179a 100644 --- a/lua/app/module/gm/gm_const.lua +++ b/lua/app/module/gm/gm_const.lua @@ -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 \ No newline at end of file diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index d28929cf..1646bad7 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -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) diff --git a/lua/app/ui/battle/cell/grid_cell.lua b/lua/app/ui/battle/cell/grid_cell.lua index b31bcb07..0a8528cd 100644 --- a/lua/app/ui/battle/cell/grid_cell.lua +++ b/lua/app/ui/battle/cell/grid_cell.lua @@ -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 diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index 89d4dd8d..b24b7057 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -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,23 +86,28 @@ 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) +function BattleGridEntity:tryBreakGrid(boomType) if self:getIsIdle() then self:setGridType(BattleConst.GRID_TYPE.EMPTY) 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 + if not self:canBreakByThisCondition(boomType) then return false end + self:addBreakCount(1) + if self:getBreakCount() < self:getCfgBreakCount() then + 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 end @@ -128,7 +139,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) @@ -149,6 +160,7 @@ end function BattleGridEntity:setGridType(gridType) self.gridType = gridType + self.breakCount = 0 self:setDirty() end @@ -242,4 +254,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 \ No newline at end of file