From e1e2573d2361330a00ac84dffbb1c768ea1ab5e4 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 12 Apr 2023 10:24:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=A1=AB=E5=85=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/controller/battle_controller.lua | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index dfc731c0..e073b737 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -371,16 +371,36 @@ function BattleController:fillBoard() local pathMap = {} local columnCount = {} + local gridMap = {} for c = 1, BattleConst.COLUMN_COUNT do for r = BattleConst.ROW_COUNT, 1, -1 do local posId = ModuleManager.BattleManager:getPosId(r, c) local entity = DataManager.BattleData:getGridEntity(posId) if entity:getIsIdle() then - self:fillThisPos(posId, columnCount) + self:fillThisPos(posId, columnCount, gridMap) end end end + while true do + local find = false + for c = 1, BattleConst.COLUMN_COUNT do + local list = gridMap[c] + if list and list[1] then -- 此列有需要填充的元素 + local entity = table.remove(list, 1) + if entity then + DataManager.BattleData:setGridInfo(entity:getPosId(), self:getRandomGridInfo()) + end + find = true + end + end + + if not find then + break + end + end + + for c = 1, BattleConst.COLUMN_COUNT do for r = BattleConst.ROW_COUNT, 1, -1 do local posId = ModuleManager.BattleManager:getPosId(r, c) @@ -566,7 +586,7 @@ function BattleController:getSkillElementList(elementType, count, useAlternate) end ---- 从一个点直接遍历所有相关的路径 -function BattleController:fillThisPos(posId, columnCount) +function BattleController:fillThisPos(posId, columnCount, gridMap) local entity = DataManager.BattleData:getGridEntity(posId) if not entity or not entity:getIsIdle() then return @@ -598,7 +618,10 @@ function BattleController:fillThisPos(posId, columnCount) fallEntity:addPath({x = curPos.x, y = curPos.y}) DataManager.BattleData:exchangeGridEntities(posId, fallPosId) - DataManager.BattleData:setGridInfo(posId, self:getRandomGridInfo()) + if not gridMap[c] then + gridMap[c] = {} + end + table.insert(gridMap[c], fallEntity) else for index, fallPosId in ipairs(list) do local fallEntity = DataManager.BattleData:getGridEntity(fallPosId) @@ -608,7 +631,7 @@ function BattleController:fillThisPos(posId, columnCount) if fallEntity then if not fallEntity:isCantFallType() then if fallEntity:getIsIdle() then - self:fillThisPos(fallPosId, columnCount) + self:fillThisPos(fallPosId, columnCount, gridMap) end fallEntity = DataManager.BattleData:getGridEntity(fallPosId) if not fallEntity:getIsIdle() then @@ -621,7 +644,7 @@ function BattleController:fillThisPos(posId, columnCount) fallEntity:addPath({x = curPos.x, y = curPos.y}) DataManager.BattleData:exchangeGridEntities(posId, fallPosId) - self:fillThisPos(fallPosId, columnCount) + self:fillThisPos(fallPosId, columnCount, gridMap) return end end @@ -768,7 +791,7 @@ function BattleController:addHeroAttr(attrName, value) -- -- body -- elseif attrName == then -- -- body - -- elseif attrName == then + -- elseif attrName == then' -- -- body -- elseif attrName == then -- -- body From 4c752c0e782a41f651bd6680c55bce1c224887e0 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 12 Apr 2023 11:19:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/data_manager.lua | 1 - .../battle/controller/battle_controller.lua | 32 ++++++++++++++++--- lua/app/ui/battle/battle_ui.lua | 2 +- .../userdata/battle/battle_grid_entity.lua | 10 ++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index ddd8ba45..4bffa37d 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -65,7 +65,6 @@ function DataManager:clear() end self.cdCallBack = {} self.PlayerData:clear() - self.BattleData:clear() self.ChapterData:clear() self.HeroData:clear() self.BagData:clear() diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index e073b737..ec0f5e3e 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -318,7 +318,7 @@ function BattleController:onLinkOver() for posId, _ in pairs(DataManager.BattleData:getSkillInfluenceGrids()) do local entity = DataManager.BattleData:getGridEntity(posId) if not entity:getIsIdle() then - if entity:isEmptyType() then + if entity:isEmptyIdle() then entity:setIsIdle(true) if not eliminationPosIds[posId] then eliminationPosIds[posId] = true @@ -342,11 +342,12 @@ function BattleController:onLinkOver() if not eliminationPosIds[posId] then local entity = DataManager.BattleData:getGridEntity(posId) if entity then + local elementTypeInvalid = entity:isElmentTypeInvalid() entity:addAroundEliminationCount() if entity:getIsIdle() then eliminationPosIds[posId] = true - table.insert(sequence, {posId = posId}) - if not entity:getSkillId() 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 @@ -417,7 +418,10 @@ function BattleController:fillBoard() self.battleUI:enableUITouch() ---- 临时 - ModuleManager.BattleManager:showSelectSkillUI(self:getRandomSkillList()) + -- local list = {BattleConst.GRID_TYPE.SNOW_BOX, BattleConst.GRID_TYPE.SOLID_SNOW, BattleConst.GRID_TYPE.VINES, BattleConst.GRID_TYPE.ICE} + -- local gridType = list[math.random(1, 4)] + -- self:generateGridType(gridType) + -- ModuleManager.BattleManager:showSelectSkillUI(self:getRandomSkillList()) end) end @@ -524,6 +528,25 @@ function BattleController:generateSkill() end end +function BattleController:generateGridType(gridType) + if not gridType then + return + end + + local list = {} + local count = 0 + for posId, entity in pairs(DataManager.BattleData:getGridEnties()) do + if entity:isEmptyIdle() then + table.insert(list, entity) + count = count + 1 + end + end + if count > 0 then + local entity = list[math.random(1, count)] + DataManager.BattleData:setGridInfo(entity:getPosId(), {gridType = gridType, elementType = entity:getElementType()}) + end +end + function BattleController:getSkillElementList(elementType, count, useAlternate) local result = {} local gridEntities = DataManager.BattleData:getGridEnties() @@ -683,6 +706,7 @@ function BattleController:getRandomGridInfo() local index = GFunc.getRandomIndex(indexs) elementType = typeList[index] end + return {gridType = gridType, elementType = elementType} end diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index a0d3b155..bcb751d0 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -195,7 +195,7 @@ function BattleUI:eliminationAni(sequence, callback) if entity and entity:getCell() then local baseObject = entity:getCell():getBaseObject() baseObject:getTransform():SetAsLastSibling() - if entity:getSkillId() then + if entity:getSkillId() or info.noAni then baseObject:setAnchoredPositionX(DEFAULT_X) else self.eliminationAniSeq:Insert(index * 0.01, baseObject:getTransform():DOScale(1.3, 0.1)) diff --git a/lua/app/userdata/battle/battle_grid_entity.lua b/lua/app/userdata/battle/battle_grid_entity.lua index f73e06ab..b1a4c957 100644 --- a/lua/app/userdata/battle/battle_grid_entity.lua +++ b/lua/app/userdata/battle/battle_grid_entity.lua @@ -71,6 +71,9 @@ function BattleGridEntity:isEmptyType() return self.gridType == BattleConst.GRID_TYPE.EMPTY end +function BattleGridEntity:isElmentTypeInvalid() + return BattleConst.AROUND_ELIMINATION_TO_TYPE_COUNT[self.gridType] ~= nil +end function BattleGridEntity:getAroundEliminationCount() return self.aroundEliminationCount @@ -175,6 +178,13 @@ function BattleGridEntity:canInfluenceBySkill() return false end +function BattleGridEntity:isEmptyIdle() + if self:isEmptyType() and not self:getSkillId() then + return true + end + return false +end + function BattleGridEntity:setNeedElimination(need) self.needElimination = need self:setDirty()