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

This commit is contained in:
chenxi 2023-04-12 11:56:48 +08:00
commit 39fed0bb6d
4 changed files with 68 additions and 12 deletions

View File

@ -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()

View File

@ -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
@ -371,16 +372,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)
@ -397,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
@ -504,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()
@ -566,7 +609,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 +641,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 +654,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 +667,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
@ -660,6 +706,7 @@ function BattleController:getRandomGridInfo()
local index = GFunc.getRandomIndex(indexs)
elementType = typeList[index]
end
return {gridType = gridType, elementType = elementType}
end
@ -768,7 +815,7 @@ function BattleController:addHeroAttr(attrName, value)
-- -- body
-- elseif attrName == then
-- -- body
-- elseif attrName == then
-- elseif attrName == then'
-- -- body
-- elseif attrName == then
-- -- body

View File

@ -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))

View File

@ -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()