Merge branch 'battle' into dev
This commit is contained in:
commit
30908425ca
@ -362,6 +362,29 @@ function table.shuffle(t)
|
|||||||
return tab
|
return tab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function table.clear(t)
|
||||||
|
if not t then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if type(t) ~= "table" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for key, v in pairs(t) do
|
||||||
|
t[key] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function table.clearOrCreate(t)
|
||||||
|
if not t then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
if type(t) ~= "table" then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
table.clear(t)
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
---查找一个满足条件的元素
|
---查找一个满足条件的元素
|
||||||
function table.find(t, predict)
|
function table.find(t, predict)
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
|
|||||||
@ -134,10 +134,10 @@ end
|
|||||||
|
|
||||||
function BattleController:onLinkChange()
|
function BattleController:onLinkChange()
|
||||||
self.battleUI:hideAllSfxLine()
|
self.battleUI:hideAllSfxLine()
|
||||||
local needFalsePosMap = {}
|
self.linkChangeNeedFalsePosMap = table.clearOrCreate(self.linkChangeNeedFalsePosMap)
|
||||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
if entity:getCell() then
|
if entity:getCell() then
|
||||||
needFalsePosMap[posId] = entity:getCell()
|
self.linkChangeNeedFalsePosMap[posId] = entity:getCell()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -162,8 +162,8 @@ function BattleController:onLinkChange()
|
|||||||
if entity:getCell() then
|
if entity:getCell() then
|
||||||
entity:getCell():showHighLight(true, mainElementType, self.battleUI)
|
entity:getCell():showHighLight(true, mainElementType, self.battleUI)
|
||||||
end
|
end
|
||||||
if needFalsePosMap[info.posId] then
|
if self.linkChangeNeedFalsePosMap[info.posId] then
|
||||||
needFalsePosMap[info.posId] = nil
|
self.linkChangeNeedFalsePosMap[info.posId] = nil
|
||||||
end
|
end
|
||||||
if index < count then
|
if index < count then
|
||||||
local nextPosId = sequence[index + 1].posId
|
local nextPosId = sequence[index + 1].posId
|
||||||
@ -183,7 +183,7 @@ function BattleController:onLinkChange()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for posId, cell in pairs(needFalsePosMap) do
|
for posId, cell in pairs(self.linkChangeNeedFalsePosMap) do
|
||||||
cell:showHighLight(false)
|
cell:showHighLight(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -982,58 +982,58 @@ function BattleController:calculateCurElimination(onlyCheck)
|
|||||||
if skillId then
|
if skillId then
|
||||||
skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
|
skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
|
||||||
end
|
end
|
||||||
local breakedMap = {}
|
self.breakedMap = table.clearOrCreate(self.breakedMap)
|
||||||
local boomGridIds = {}
|
self.boomGridIds = table.clearOrCreate(self.boomGridIds)
|
||||||
local sequenceMap = {}
|
self.sequenceMap = table.clearOrCreate(self.sequenceMap)
|
||||||
|
self.aniSequence = table.clearOrCreate(self.aniSequence)
|
||||||
for idx, info in ipairs(sequence) do
|
for idx, info in ipairs(sequence) do
|
||||||
sequenceMap[info.posId] = idx
|
self.sequenceMap[info.posId] = idx
|
||||||
end
|
end
|
||||||
|
|
||||||
local time = 0
|
local time = 0
|
||||||
local skillTime = BattleConst.SKILL_ELIMINATION_TIME
|
local skillTime = BattleConst.SKILL_ELIMINATION_TIME
|
||||||
local aniSequence = {}
|
|
||||||
for idx, info in ipairs(sequence) do
|
for idx, info in ipairs(sequence) do
|
||||||
local posId = info.posId
|
local posId = info.posId
|
||||||
self:dealGridBreak(posId, GRID_BREAK_CONDITION.LINE, time, breakedMap, sequenceMap, aniSequence, boomGridIds, onlyCheck)
|
self:dealGridBreak(posId, GRID_BREAK_CONDITION.LINE, time, self.breakedMap, self.sequenceMap, self.aniSequence, self.boomGridIds, onlyCheck)
|
||||||
time = time + BattleConst.ELIMINATION_INTERVAL
|
time = time + BattleConst.ELIMINATION_INTERVAL
|
||||||
end
|
end
|
||||||
|
|
||||||
local randomPosList, influenceElementTypeMap
|
local randomPosList, influenceElementTypeMap
|
||||||
for i, info in ipairs(aniSequence) do
|
for i, info in ipairs(self.aniSequence) do
|
||||||
if info.isSkill then
|
if info.isSkill then
|
||||||
randomPosList, influenceElementTypeMap = self:dealSkillElement(info.timeIdx + skillTime, breakedMap, sequenceMap, aniSequence, boomGridIds, onlyCheck)
|
randomPosList, influenceElementTypeMap = self:dealSkillElement(info.timeIdx + skillTime, self.breakedMap, self.sequenceMap, self.aniSequence, self.boomGridIds, onlyCheck)
|
||||||
local aniUnit = aniSequence[i]
|
local aniUnit = self.aniSequence[i]
|
||||||
aniUnit.rangeList = skillEntity:getBoardRange()
|
aniUnit.rangeList = skillEntity:getBoardRange()
|
||||||
aniUnit.randomPosList = randomPosList
|
aniUnit.randomPosList = randomPosList
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local lineCount = 0
|
self.elementTypeMap = table.clearOrCreate(self.elementTypeMap)
|
||||||
local elementTypeMap = {}
|
self.effectGridMap = table.clearOrCreate(self.effectGridMap)
|
||||||
local linkElementType
|
local linkElementType
|
||||||
|
local lineCount = 0
|
||||||
local gridEntities = self.battleData:getGridEnties()
|
local gridEntities = self.battleData:getGridEnties()
|
||||||
local effectGridMap = {}
|
for _, info in ipairs(self.aniSequence) do
|
||||||
for _, info in ipairs(aniSequence) do
|
|
||||||
local entity = gridEntities[info.posId]
|
local entity = gridEntities[info.posId]
|
||||||
local elementType = entity:getElementType()
|
local elementType = entity:getElementType()
|
||||||
if not info.noAni and info.isIdle then
|
if not info.noAni and info.isIdle then
|
||||||
if not info.isSkill then
|
if not info.isSkill then
|
||||||
if not entity:isElmentTypeInvalid() then
|
if not entity:isElmentTypeInvalid() then
|
||||||
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
|
self.elementTypeMap[elementType] = (self.elementTypeMap[elementType] or 0) + 1
|
||||||
end
|
end
|
||||||
if boomGridIds[info.posId] and boomGridIds[info.posId][GRID_BREAK_CONDITION.LINE] then
|
if self.boomGridIds[info.posId] and self.boomGridIds[info.posId][GRID_BREAK_CONDITION.LINE] then
|
||||||
lineCount = lineCount + 1
|
lineCount = lineCount + 1
|
||||||
linkElementType = elementType
|
linkElementType = elementType
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if entity:getEffectType() and info.isIdle then
|
if entity:getEffectType() and info.isIdle then
|
||||||
effectGridMap[info.posId] = true
|
self.effectGridMap[info.posId] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return aniSequence, influenceElementTypeMap, lineCount, elementTypeMap, linkElementType, effectGridMap
|
return self.aniSequence, influenceElementTypeMap, lineCount, self.elementTypeMap, linkElementType, self.effectGridMap
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:dealGridBreak(posId, condition, time, breakedMap, sequenceMap, aniSequence, gridMap, onlyCheck)
|
function BattleController:dealGridBreak(posId, condition, time, breakedMap, sequenceMap, aniSequence, gridMap, onlyCheck)
|
||||||
@ -1081,7 +1081,7 @@ function BattleController:dealGridBreak(posId, condition, time, breakedMap, sequ
|
|||||||
if entity:getEffectType() then
|
if entity:getEffectType() then
|
||||||
local succ, list = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(posId, gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_GRID_BREAK, self, onlyCheck)
|
local succ, list = BATTLE_GRID_EFFECT_HANDLE.gridEffectOn(posId, gridEntities, BattleConst.GRID_EFFECT_TRIGGER_TYPE.ON_GRID_BREAK, self, onlyCheck)
|
||||||
if list then
|
if list then
|
||||||
aniUnit.aniPosList = {}
|
aniUnit.aniPosList = table.clearOrCreate(aniUnit.aniPosList)
|
||||||
aniUnit.overCallback = aniUnit.callback
|
aniUnit.overCallback = aniUnit.callback
|
||||||
aniUnit.callback = nil
|
aniUnit.callback = nil
|
||||||
for index, id in ipairs(list) do
|
for index, id in ipairs(list) do
|
||||||
@ -1173,15 +1173,15 @@ function BattleController:tryShowSelectSkillComp(needDelay, onlyCommonSkill)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:fillBoard(isRoundBeginCheck)
|
function BattleController:fillBoard(isRoundBeginCheck)
|
||||||
local pathMap = {}
|
self.fillBoardPathMap = table.clearOrCreate(self.fillBoardPathMap)
|
||||||
local columnCount = {}
|
self.fillColumnCount = table.clearOrCreate(self.fillColumnCount)
|
||||||
local gridMap = {}
|
self.fillGridMap = table.clearOrCreate(self.fillGridMap)
|
||||||
for c = 1, BattleConst.COLUMN_COUNT do
|
for c = 1, BattleConst.COLUMN_COUNT do
|
||||||
for r = BattleConst.ROW_COUNT, 1, -1 do
|
for r = BattleConst.ROW_COUNT, 1, -1 do
|
||||||
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
||||||
local entity = self.battleData:getGridEntity(posId)
|
local entity = self.battleData:getGridEntity(posId)
|
||||||
if entity:getIsIdle() then
|
if entity:getIsIdle() then
|
||||||
self:fillThisPos(posId, columnCount, gridMap)
|
self:fillThisPos(posId, self.fillColumnCount, self.fillGridMap)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1189,7 +1189,7 @@ function BattleController:fillBoard(isRoundBeginCheck)
|
|||||||
while true do
|
while true do
|
||||||
local find = false
|
local find = false
|
||||||
for c = 1, BattleConst.COLUMN_COUNT do
|
for c = 1, BattleConst.COLUMN_COUNT do
|
||||||
local list = gridMap[c]
|
local list = self.fillGridMap[c]
|
||||||
if list and list[1] then -- 此列有需要填充的元素
|
if list and list[1] then -- 此列有需要填充的元素
|
||||||
local entity = table.remove(list, 1)
|
local entity = table.remove(list, 1)
|
||||||
if entity then
|
if entity then
|
||||||
@ -1209,13 +1209,13 @@ function BattleController:fillBoard(isRoundBeginCheck)
|
|||||||
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
||||||
local entity = self.battleData:getGridEntity(posId)
|
local entity = self.battleData:getGridEntity(posId)
|
||||||
if #entity:getPath() > 0 then
|
if #entity:getPath() > 0 then
|
||||||
pathMap[posId] = entity:getPath()
|
self.fillBoardPathMap[posId] = entity:getPath()
|
||||||
entity:clearPath()
|
entity:clearPath()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.battleUI:fallGrid(pathMap, isRoundBeginCheck, function()
|
self.battleUI:fallGrid(self.fillBoardPathMap, isRoundBeginCheck, function()
|
||||||
self:onFillBoardOver(isRoundBeginCheck)
|
self:onFillBoardOver(isRoundBeginCheck)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -1333,24 +1333,24 @@ function BattleController:popBoardCacheSkill(callback)
|
|||||||
local skillList, skillCount = self.battleData:getCacheBoardSkill()
|
local skillList, skillCount = self.battleData:getCacheBoardSkill()
|
||||||
self.battleData:clearCacheBoardSkill()
|
self.battleData:clearCacheBoardSkill()
|
||||||
if self.battleUI and skillCount > 0 then
|
if self.battleUI and skillCount > 0 then
|
||||||
local posidList = {}
|
self.popSkillPosIdList = table.clearOrCreate(self.popSkillPosIdList)
|
||||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
if entity:isEmptyIdle() and not entity:getIsIdle() then
|
if entity:isEmptyIdle() and not entity:getIsIdle() then
|
||||||
table.insert(posidList, posId)
|
table.insert(self.popSkillPosIdList, posId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
posidList = table.shuffle(posidList)
|
self.popSkillPosIdList = table.shuffle(self.popSkillPosIdList)
|
||||||
local newSkillId = {}
|
self.popNewSkillId = table.shuffle(self.popNewSkillId)
|
||||||
for index, info in ipairs(skillList) do
|
for index, info in ipairs(skillList) do
|
||||||
if posidList[1] then
|
if self.popSkillPosIdList[1] then
|
||||||
newSkillId[index] = info
|
self.popNewSkillId[index] = info
|
||||||
newSkillId[index].posId = table.remove(posidList)
|
self.popNewSkillId[index].posId = table.remove(self.popSkillPosIdList)
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.battleUI:cacheSkillAni(newSkillId, true, callback)
|
self.battleUI:cacheSkillAni(self.popNewSkillId, true, callback)
|
||||||
else
|
else
|
||||||
if callback then
|
if callback then
|
||||||
callback()
|
callback()
|
||||||
@ -1359,18 +1359,18 @@ function BattleController:popBoardCacheSkill(callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:generateSkill(callback)
|
function BattleController:generateSkill(callback)
|
||||||
local map = {}
|
self.generateSkillMap = table.clearOrCreate(self.generateSkillMap)
|
||||||
local excludeMap = {}
|
self.generateExcludeMap = table.clearOrCreate(self.generateExcludeMap)
|
||||||
for _, skillEntity in pairs(self.battleData:getSkillEntities()) do
|
for _, skillEntity in pairs(self.battleData:getSkillEntities()) do
|
||||||
if skillEntity:getEnergyEnough() then
|
if skillEntity:getEnergyEnough() then
|
||||||
local list = self:getSkillElementList(skillEntity:getPosition(), 1, true, excludeMap)
|
local list = self:getSkillElementList(skillEntity:getPosition(), 1, true, self.generateExcludeMap)
|
||||||
if list[1] then
|
if list[1] then
|
||||||
map[skillEntity:getPosition()] =
|
self.generateSkillMap[skillEntity:getPosition()] =
|
||||||
{
|
{
|
||||||
skillId = skillEntity:getSkillId(),
|
skillId = skillEntity:getSkillId(),
|
||||||
posId = list[1]
|
posId = list[1]
|
||||||
}
|
}
|
||||||
excludeMap[list[1]] = true
|
self.generateExcludeMap[list[1]] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1382,8 +1382,8 @@ function BattleController:generateSkill(callback)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.battleUI:generateSkillAni(map, function()
|
self.battleUI:generateSkillAni(self.generateSkillMap, function()
|
||||||
for elementType, info in pairs(map) do
|
for elementType, info in pairs(self.generateSkillMap) do
|
||||||
self:setGridSkillId(info.posId, info.skillId)
|
self:setGridSkillId(info.posId, info.skillId)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1409,28 +1409,28 @@ function BattleController:generateGridType(skillTypeParameter, monsterPos)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local list = {}
|
self.generateGridTypeList = table.clearOrCreate(self.generateGridTypeList)
|
||||||
local count = 0
|
local count = 0
|
||||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
if entity:isEmptyIdle() then
|
if entity:isEmptyIdle() then
|
||||||
table.insert(list, entity)
|
table.insert(self.generateGridTypeList, entity)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
list = table.shuffle(list)
|
self.generateGridTypeList = table.shuffle(self.generateGridTypeList)
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
local map = {}
|
self.generateGridTypeMap = table.clearOrCreate(self.generateGridTypeMap)
|
||||||
local minCount = math.min(skillTypeParameter[2], count)
|
local minCount = math.min(skillTypeParameter[2], count)
|
||||||
for i = minCount, 1, -1 do
|
for i = minCount, 1, -1 do
|
||||||
local entity = table.remove(list, math.random(1, i))
|
local entity = table.remove(self.generateGridTypeList, math.random(1, i))
|
||||||
map[entity:getPosId()] = {
|
self.generateGridTypeMap[entity:getPosId()] = {
|
||||||
gridType = skillTypeParameter[1],
|
gridType = skillTypeParameter[1],
|
||||||
elementType = entity:getElementType()
|
elementType = entity:getElementType()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
self.battleUI:showMonsterSkillAni(map, monsterPos, function()
|
self.battleUI:showMonsterSkillAni(self.generateGridTypeMap, monsterPos, function()
|
||||||
for posId, info in pairs(map) do
|
for posId, info in pairs(self.generateGridTypeMap) do
|
||||||
self.battleData:setGridInfo(posId, info)
|
self.battleData:setGridInfo(posId, info)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -1438,64 +1438,70 @@ function BattleController:generateGridType(skillTypeParameter, monsterPos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:lockElement(lcokElementType, isUnlock)
|
function BattleController:lockElement(lcokElementType, isUnlock)
|
||||||
local elementTypeMap = {}
|
if not self.lockElementElementTypeMap then
|
||||||
local list
|
self.lockElementElementTypeMap = table.clearOrCreate(self.lockElementElementTypeMap)
|
||||||
local lockElementMap
|
else
|
||||||
|
for k, v in pairs(self.lockElementElementTypeMap) do
|
||||||
|
self.lockElementElementTypeMap[k] = table.clearOrCreate(self.lockElementElementTypeMap[k])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not self.lockElementMap then
|
||||||
|
self.lockElementMap = table.clearOrCreate(self.lockElementMap)
|
||||||
|
else
|
||||||
|
for k, v in pairs(self.lockElementMap) do
|
||||||
|
self.lockElementMap[k] = table.clearOrCreate(self.lockElementMap[k])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.lockElementList = table.clearOrCreate(self.lockElementList)
|
||||||
local locked = false
|
local locked = false
|
||||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
local elementType = entity:getElementType()
|
local elementType = entity:getElementType()
|
||||||
if not isUnlock then
|
if not isUnlock then
|
||||||
if entity:isEmptyIdle() then
|
if entity:isEmptyIdle() then
|
||||||
if not elementTypeMap[elementType] then
|
local elementTypeMapUnit = self.lockElementElementTypeMap[elementType]
|
||||||
elementTypeMap[elementType] = {}
|
if not elementTypeMapUnit or not elementTypeMapUnit[1] then
|
||||||
|
self.lockElementElementTypeMap[elementType] = table.clearOrCreate(self.lockElementElementTypeMap[elementType])
|
||||||
|
elementTypeMapUnit = self.lockElementElementTypeMap[elementType]
|
||||||
if not isUnlock then
|
if not isUnlock then
|
||||||
if not list then
|
table.insert(self.lockElementList, elementType)
|
||||||
list = {}
|
|
||||||
end
|
|
||||||
table.insert(list, elementType)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(elementTypeMap[elementType], posId)
|
table.insert(elementTypeMapUnit, posId)
|
||||||
end
|
end
|
||||||
if entity:isLock() then
|
if entity:isLock() then
|
||||||
locked = true
|
locked = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if entity:isLock() then
|
if entity:isLock() then
|
||||||
if not lockElementMap then
|
if not self.lockElementMap[elementType] then
|
||||||
lockElementMap = {}
|
self.lockElementMap[elementType] = table.clearOrCreate(self.lockElementMap[elementType])
|
||||||
end
|
end
|
||||||
if not lockElementMap[elementType] then
|
table.insert(self.lockElementMap[elementType], posId)
|
||||||
lockElementMap[elementType] = {}
|
|
||||||
end
|
|
||||||
table.insert(lockElementMap[elementType], posId)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if isUnlock then
|
if isUnlock then
|
||||||
if lockElementMap then
|
for elementType, list in pairs(self.lockElementMap) do
|
||||||
for elementType, list in pairs(lockElementMap) do
|
|
||||||
self.battleData:cacheLockElement(elementType, nil)
|
self.battleData:cacheLockElement(elementType, nil)
|
||||||
for _, posId in ipairs(list) do
|
for _, posId in ipairs(list) do
|
||||||
self.battleData:setGridType(posId, BattleConst.GRID_TYPE.EMPTY)
|
self.battleData:setGridType(posId, BattleConst.GRID_TYPE.EMPTY)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if locked then -- 锁定过就不新锁了
|
if locked then -- 锁定过就不新锁了
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local elementType = lcokElementType
|
local elementType = lcokElementType
|
||||||
if elementType == BattleConst.ELEMENT_TYPE.NONE then
|
if elementType == BattleConst.ELEMENT_TYPE.NONE then
|
||||||
if not list or not list[1] then
|
if not self.lockElementList[1] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elementType = list[math.random(1, #list)]
|
elementType = self.lockElementList[math.random(1, #self.lockElementList)]
|
||||||
end
|
end
|
||||||
self.battleData:cacheLockElement(elementType, true)
|
self.battleData:cacheLockElement(elementType, true)
|
||||||
local list = elementTypeMap[elementType]
|
local list = self.lockElementElementTypeMap[elementType]
|
||||||
if list then
|
if list then
|
||||||
for _, posId in ipairs(list) do
|
for _, posId in ipairs(list) do
|
||||||
self.battleData:setGridType(posId, BattleConst.GRID_TYPE.LOCK)
|
self.battleData:setGridType(posId, BattleConst.GRID_TYPE.LOCK)
|
||||||
@ -1505,14 +1511,14 @@ function BattleController:lockElement(lcokElementType, isUnlock)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:getSkillElementList(elementType, count, useAlternate, excludeMap)
|
function BattleController:getSkillElementList(elementType, count, useAlternate, excludeMap)
|
||||||
local result = {}
|
self.getSkillElementListResult = table.clearOrCreate(self.getSkillElementListResult)
|
||||||
local gridEntities = self.battleData:getGridEnties()
|
local gridEntities = self.battleData:getGridEnties()
|
||||||
if not gridEntities then
|
if not gridEntities then
|
||||||
return result
|
return self.getSkillElementListResult
|
||||||
end
|
end
|
||||||
|
|
||||||
local sameElementList = {}
|
self.getSkillElementListSameElementList = table.clearOrCreate(self.getSkillElementListSameElementList)
|
||||||
local alternateList = {}
|
self.getSkillElementListAlternateList = table.clearOrCreate(self.getSkillElementListAlternateList)
|
||||||
local addCount = 0
|
local addCount = 0
|
||||||
|
|
||||||
for row = 1, BattleConst.ROW_COUNT do
|
for row = 1, BattleConst.ROW_COUNT do
|
||||||
@ -1521,48 +1527,48 @@ function BattleController:getSkillElementList(elementType, count, useAlternate,
|
|||||||
local entity = gridEntities[posId]
|
local entity = gridEntities[posId]
|
||||||
if entity and entity:canChangeInfo() and not excludeMap[posId] then
|
if entity and entity:canChangeInfo() and not excludeMap[posId] then
|
||||||
if entity:getElementType() == elementType then
|
if entity:getElementType() == elementType then
|
||||||
table.insert(sameElementList, posId)
|
table.insert(self.getSkillElementListSameElementList, posId)
|
||||||
else
|
else
|
||||||
table.insert(alternateList, posId)
|
table.insert(self.getSkillElementListAlternateList, posId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local remainCount = count - addCount
|
local remainCount = count - addCount
|
||||||
if remainCount <= 0 then
|
if remainCount <= 0 then
|
||||||
return result
|
return self.getSkillElementListResult
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, remainCount do
|
for i = 1, remainCount do
|
||||||
if not sameElementList[i] then
|
if not self.getSkillElementListSameElementList[i] then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
table.insert(result, table.remove(sameElementList, math.random(1, #sameElementList)))
|
table.insert(self.getSkillElementListResult, table.remove(self.getSkillElementListSameElementList, math.random(1, #self.getSkillElementListSameElementList)))
|
||||||
addCount = addCount + 1
|
addCount = addCount + 1
|
||||||
if addCount >= count then
|
if addCount >= count then
|
||||||
return result
|
return self.getSkillElementListResult
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if addCount < count and useAlternate then
|
if addCount < count and useAlternate then
|
||||||
for i = 1, count - addCount do
|
for i = 1, count - addCount do
|
||||||
if not alternateList[1] then
|
if not self.getSkillElementListAlternateList[1] then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
table.insert(result, table.remove(alternateList, math.random(1, #alternateList)))
|
table.insert(self.getSkillElementListResult, table.remove(self.getSkillElementListAlternateList, math.random(1, #self.getSkillElementListAlternateList)))
|
||||||
addCount = addCount + 1
|
addCount = addCount + 1
|
||||||
if addCount >= count then
|
if addCount >= count then
|
||||||
return result
|
return self.getSkillElementListResult
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if addCount >= count then
|
if addCount >= count then
|
||||||
return result
|
return self.getSkillElementListResult
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return self.getSkillElementListResult
|
||||||
end
|
end
|
||||||
|
|
||||||
---- 从一个点直接遍历所有相关的路径
|
---- 从一个点直接遍历所有相关的路径
|
||||||
@ -1641,21 +1647,21 @@ function BattleController:getRandomGridInfo()
|
|||||||
elementType = table.remove(fixedRandomList, 1)
|
elementType = table.remove(fixedRandomList, 1)
|
||||||
else
|
else
|
||||||
local map = self.battleData:getElementTypeMap()
|
local map = self.battleData:getElementTypeMap()
|
||||||
local indexs = {}
|
self.getRandomGridInfoIndexs = table.clearOrCreate(self.getRandomGridInfoIndexs)
|
||||||
local typeList = {}
|
self.getRandomGridInfoTypeList = table.clearOrCreate(self.getRandomGridInfoTypeList)
|
||||||
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
|
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
|
||||||
if not self:getSealElementType()[typeNum] and self.battleData:getSkillEntityByElement(typeNum) then
|
if not self:getSealElementType()[typeNum] and self.battleData:getSkillEntityByElement(typeNum) then
|
||||||
local weight = ((map[typeNum] or 0) + 1) * BattleConst.ELEMENT_WIGHT
|
local weight = ((map[typeNum] or 0) + 1) * BattleConst.ELEMENT_WIGHT
|
||||||
if weight > BattleConst.MAX_ELEMENT_WIGHT then
|
if weight > BattleConst.MAX_ELEMENT_WIGHT then
|
||||||
weight = BattleConst.MAX_ELEMENT_WIGHT
|
weight = BattleConst.MAX_ELEMENT_WIGHT
|
||||||
end
|
end
|
||||||
table.insert(indexs, weight)
|
table.insert(self.getRandomGridInfoIndexs, weight)
|
||||||
table.insert(typeList, typeNum)
|
table.insert(self.getRandomGridInfoTypeList, typeNum)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local index = GFunc.getRandomIndex(indexs)
|
local index = GFunc.getRandomIndex(self.getRandomGridInfoIndexs)
|
||||||
elementType = typeList[index]
|
elementType = self.getRandomGridInfoTypeList[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
return {gridType = gridType, elementType = elementType}
|
return {gridType = gridType, elementType = elementType}
|
||||||
@ -1671,10 +1677,10 @@ function BattleController:findSkillInfluenceGrids()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local sequence = self.battleData:getGridSequence()
|
local sequence = self.battleData:getGridSequence()
|
||||||
local sequenceEntities = {}
|
self.skillInfluenceGridsSequenceEntities = table.clearOrCreate(self.skillInfluenceGridsSequenceEntities)
|
||||||
for _, info in ipairs(sequence) do
|
for _, info in ipairs(sequence) do
|
||||||
local entity = self.battleData:getGridEntity(info.posId)
|
local entity = self.battleData:getGridEntity(info.posId)
|
||||||
table.insert(sequenceEntities, entity)
|
table.insert(self.skillInfluenceGridsSequenceEntities, entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, info in ipairs(sequence) do
|
for _, info in ipairs(sequence) do
|
||||||
@ -1683,7 +1689,7 @@ function BattleController:findSkillInfluenceGrids()
|
|||||||
if skillId then
|
if skillId then
|
||||||
local skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
|
local skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
|
||||||
if skillEntity then
|
if skillEntity then
|
||||||
BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, self.battleData:getGridEnties(), sequenceEntities, self)
|
BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, self.battleData:getGridEnties(), self.skillInfluenceGridsSequenceEntities, self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1696,14 +1702,13 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
end
|
end
|
||||||
|
|
||||||
getCount = getCount or BattleConst.SKILL_SELECT_COUNT
|
getCount = getCount or BattleConst.SKILL_SELECT_COUNT
|
||||||
local result = {}
|
self.randomSkillList = table.clearOrCreate(self.randomSkillList)
|
||||||
|
self.randomSkillMap = table.clearOrCreate(self.randomSkillMap)
|
||||||
|
self.randomSkillNewSkillPool = table.clearOrCreate(self.randomSkillNewSkillPool)
|
||||||
|
self.randomSkillSkillWeight = table.clearOrCreate(self.randomSkillSkillWeight)
|
||||||
local cfg = ConfigManager:getConfig("skill_rogue")
|
local cfg = ConfigManager:getConfig("skill_rogue")
|
||||||
local skillPool = self.battleData:getSkillPool()
|
local skillPool = self.battleData:getSkillPool()
|
||||||
local map = {}
|
|
||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
local newSkillPool = {}
|
|
||||||
local skillWeight = {}
|
|
||||||
|
|
||||||
if not onlyCommonSkill then
|
if not onlyCommonSkill then
|
||||||
for elementType, list in pairs(skillPool) do -- 先遍历一下未解锁的技能
|
for elementType, list in pairs(skillPool) do -- 先遍历一下未解锁的技能
|
||||||
@ -1711,12 +1716,12 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
local skillEntity = self.battleData:getSkillEntityByElement(elementType)
|
local skillEntity = self.battleData:getSkillEntityByElement(elementType)
|
||||||
if skillEntity then
|
if skillEntity then
|
||||||
local skillId = skillEntity:getUnlockId()
|
local skillId = skillEntity:getUnlockId()
|
||||||
if skillId and not map[skillId] then
|
if skillId and not self.randomSkillMap[skillId] then
|
||||||
local skillCfg = cfg[skillId]
|
local skillCfg = cfg[skillId]
|
||||||
table.insert(newSkillPool, skillId)
|
table.insert(self.randomSkillNewSkillPool, skillId)
|
||||||
table.insert(skillWeight, skillCfg.weight)
|
table.insert(self.randomSkillSkillWeight, skillCfg.weight)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
map[skillId] = true
|
self.randomSkillMap[skillId] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1724,19 +1729,19 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
|
|
||||||
if count >= 3 then -- 如果未解锁的技能大于等于3,则直接返回三个解锁技能
|
if count >= 3 then -- 如果未解锁的技能大于等于3,则直接返回三个解锁技能
|
||||||
for i = 1, 3 do
|
for i = 1, 3 do
|
||||||
local index = GFunc.getRandomIndex(skillWeight)
|
local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
|
||||||
local skillId = table.remove(newSkillPool, index)
|
local skillId = table.remove(self.randomSkillNewSkillPool, index)
|
||||||
table.remove(skillWeight, index)
|
table.remove(self.randomSkillSkillWeight, index)
|
||||||
count = count - 1
|
count = count - 1
|
||||||
table.insert(result, skillId)
|
table.insert(self.randomSkillList, skillId)
|
||||||
end
|
end
|
||||||
|
|
||||||
return table.shuffle(result)
|
return table.shuffle(self.randomSkillList)
|
||||||
end
|
end
|
||||||
|
|
||||||
if excludeMap then
|
if excludeMap then
|
||||||
for skillId, _ in pairs(excludeMap) do
|
for skillId, _ in pairs(excludeMap) do
|
||||||
map[skillId] = true
|
self.randomSkillMap[skillId] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1746,11 +1751,11 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
local skillCfg = cfg[skillId]
|
local skillCfg = cfg[skillId]
|
||||||
if skillCfg and (not skillCfg.limit_times or self.battleData:getSkillCount(skillId) < skillCfg.limit_times) then
|
if skillCfg and (not skillCfg.limit_times or self.battleData:getSkillCount(skillId) < skillCfg.limit_times) then
|
||||||
|
|
||||||
if not map[skillId] and (not skillCfg.unlock or self.battleData:getSkillCount(skillCfg.unlock) > 0) then
|
if not self.randomSkillMap[skillId] and (not skillCfg.unlock or self.battleData:getSkillCount(skillCfg.unlock) > 0) then
|
||||||
table.insert(newSkillPool, skillId)
|
table.insert(self.randomSkillNewSkillPool, skillId)
|
||||||
table.insert(skillWeight, skillCfg.weight)
|
table.insert(self.randomSkillSkillWeight, skillCfg.weight)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
map[skillId] = true
|
self.randomSkillMap[skillId] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1758,11 +1763,11 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
end
|
end
|
||||||
|
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
local index = GFunc.getRandomIndex(skillWeight)
|
local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
|
||||||
local skillId = table.remove(newSkillPool, index)
|
local skillId = table.remove(self.randomSkillNewSkillPool, index)
|
||||||
table.remove(skillWeight, index)
|
table.remove(self.randomSkillSkillWeight, index)
|
||||||
count = count - 1
|
count = count - 1
|
||||||
table.insert(result, skillId)
|
table.insert(self.randomSkillList, skillId)
|
||||||
getCount = getCount - 1
|
getCount = getCount - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1771,9 +1776,9 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
if not self:getNotInvolvedSkills()[skillId] then
|
if not self:getNotInvolvedSkills()[skillId] then
|
||||||
if info.universal then
|
if info.universal then
|
||||||
if not info.limit_times or self.battleData:getSkillCount(skillId) < info.limit_times then
|
if not info.limit_times or self.battleData:getSkillCount(skillId) < info.limit_times then
|
||||||
if not map[skillId] then
|
if not self.randomSkillMap[skillId] then
|
||||||
table.insert(newSkillPool, skillId)
|
table.insert(self.randomSkillNewSkillPool, skillId)
|
||||||
table.insert(skillWeight, info.weight)
|
table.insert(self.randomSkillSkillWeight, info.weight)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1782,17 +1787,17 @@ function BattleController:getRandomSkillList(getCount, onlyCommonSkill, excludeM
|
|||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, getCount do
|
for i = 1, getCount do
|
||||||
local index = GFunc.getRandomIndex(skillWeight)
|
local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
|
||||||
local skillId = table.remove(newSkillPool, index)
|
local skillId = table.remove(self.randomSkillNewSkillPool, index)
|
||||||
table.remove(skillWeight, index)
|
table.remove(self.randomSkillSkillWeight, index)
|
||||||
count = count - 1
|
count = count - 1
|
||||||
table.insert(result, skillId)
|
table.insert(self.randomSkillList, skillId)
|
||||||
if count <= 0 then
|
if count <= 0 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
result = table.shuffle(result)
|
local result = table.shuffle(self.randomSkillList)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1835,10 +1840,10 @@ function BattleController:selectSKillNextToStep()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:changeElementType(count, elementType)
|
function BattleController:changeElementType(count, elementType)
|
||||||
local map = {}
|
self.changeElementTypeMap = table.clearOrCreate(self.changeElementTypeMap)
|
||||||
for _, entity in pairs(self.battleData:getGridEnties()) do
|
for _, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
if entity:canChangeInfo() and entity:getElementType() ~= elementType then
|
if entity:canChangeInfo() and entity:getElementType() ~= elementType then
|
||||||
map[entity] = elementType
|
self.changeElementTypeMap[entity] = elementType
|
||||||
count = count - 1
|
count = count - 1
|
||||||
if count <= 0 then
|
if count <= 0 then
|
||||||
break
|
break
|
||||||
@ -1846,7 +1851,7 @@ function BattleController:changeElementType(count, elementType)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:changeElementTypeByMap(map)
|
self:changeElementTypeByMap(self.changeElementTypeMap)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:changeElementTypeByMap(changeMap)
|
function BattleController:changeElementTypeByMap(changeMap)
|
||||||
@ -1872,12 +1877,12 @@ function BattleController:killGrids(posIdList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:killRowOrColumn(infoList)
|
function BattleController:killRowOrColumn(infoList)
|
||||||
local map = {}
|
self.killRowOrColumnMap = table.clearOrCreate(self.killRowOrColumnMap)
|
||||||
for _, info in ipairs(infoList) do
|
for _, info in ipairs(infoList) do
|
||||||
if info.posList then
|
if info.posList then
|
||||||
for i, posId in ipairs(info.posList) do
|
for i, posId in ipairs(info.posList) do
|
||||||
if not map[posId] then
|
if not self.killRowOrColumnMap[posId] then
|
||||||
map[posId] = true
|
self.killRowOrColumnMap[posId] = true
|
||||||
local entity = DataManager.BattleData:getGridEntity(posId)
|
local entity = DataManager.BattleData:getGridEntity(posId)
|
||||||
entity:setIsIdle(true)
|
entity:setIsIdle(true)
|
||||||
end
|
end
|
||||||
@ -1945,13 +1950,13 @@ function BattleController:shuffleBoard(callback)
|
|||||||
self.battleData:setGridEntitiesPosId(changeInfo)
|
self.battleData:setGridEntitiesPosId(changeInfo)
|
||||||
self.battleUI:shuffleBoard(changeInfo, callback)
|
self.battleUI:shuffleBoard(changeInfo, callback)
|
||||||
else
|
else
|
||||||
local resetList = {}
|
self.resetList = table.clearOrCreate(self.resetList)
|
||||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
if entity:isCanFallStatus() then
|
if entity:isCanFallStatus() then
|
||||||
table.insert(resetList, entity)
|
table.insert(self.resetList, entity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local resetInfo = self:resetGrids(resetList)
|
local resetInfo = self:resetGrids(self.resetList)
|
||||||
if not resetInfo then
|
if not resetInfo then
|
||||||
if EDITOR_MODE then
|
if EDITOR_MODE then
|
||||||
Logger.logHighlight("----- 处于无法消除状态 -----")
|
Logger.logHighlight("----- 处于无法消除状态 -----")
|
||||||
@ -1982,47 +1987,52 @@ function BattleController:shuffleBoard(callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:getShuffleBoardInfo()
|
function BattleController:getShuffleBoardInfo()
|
||||||
local posList = {}
|
self.shuffleBoardPosList = table.clearOrCreate(self.shuffleBoardPosList)
|
||||||
local gridEntityList = {}
|
self.shuffleBoardAnySkillList = table.clearOrCreate(self.shuffleBoardAnySkillList)
|
||||||
local anySkillList = {}
|
self.shuffleBoardPosMap = table.clearOrCreate(self.shuffleBoardPosMap)
|
||||||
local posMap = {}
|
self.shuffleBoardCountMap = table.clearOrCreate(self.shuffleBoardCountMap)
|
||||||
|
self.shuffleBoardCantLinkMap = table.clearOrCreate(self.shuffleBoardCantLinkMap)
|
||||||
|
if not self.shuffleBoardList then
|
||||||
|
self.shuffleBoardList = table.clearOrCreate(self.shuffleBoardList)
|
||||||
|
else
|
||||||
|
for elementType, _ in pairs(self.shuffleBoardList) do
|
||||||
|
self.shuffleBoardList[elementType] = table.clearOrCreate(self.shuffleBoardList[elementType])
|
||||||
|
end
|
||||||
|
end
|
||||||
local anySkillCount = 0
|
local anySkillCount = 0
|
||||||
local gridEntityCountMap = {}
|
|
||||||
local gridEntityCantLinkMap = {}
|
|
||||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
if entity:isCanFallStatus() then
|
if entity:isCanFallStatus() then
|
||||||
if entity:getSkillId() then
|
if entity:getSkillId() then
|
||||||
local skillEntity = self.battleData:getSkillEntityBySkillId(entity:getSkillId())
|
local skillEntity = self.battleData:getSkillEntityBySkillId(entity:getSkillId())
|
||||||
local elementType = skillEntity:getPosition()
|
local elementType = skillEntity:getPosition()
|
||||||
if skillEntity:getIgnoreElementType() then
|
if skillEntity:getIgnoreElementType() then
|
||||||
table.insert(anySkillList, entity)
|
table.insert(self.shuffleBoardAnySkillList, entity)
|
||||||
anySkillCount = anySkillCount + 1
|
anySkillCount = anySkillCount + 1
|
||||||
else
|
else
|
||||||
if not gridEntityList[elementType] then
|
if not self.shuffleBoardList[elementType] then
|
||||||
gridEntityList[elementType] = {}
|
self.shuffleBoardList[elementType] = table.clearOrCreate(self.shuffleBoardList[elementType])
|
||||||
gridEntityCountMap[elementType] = 0
|
|
||||||
end
|
end
|
||||||
table.insert(gridEntityList[elementType], entity)
|
table.insert(self.shuffleBoardList[elementType], entity)
|
||||||
gridEntityCountMap[elementType] = (gridEntityCountMap[elementType] or 0) + 1
|
self.shuffleBoardCountMap[elementType] = (self.shuffleBoardCountMap[elementType] or 0) + 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local elementType = entity:getElementType()
|
local elementType = entity:getElementType()
|
||||||
if not gridEntityList[elementType] then
|
if not self.shuffleBoardList[elementType] then
|
||||||
gridEntityList[elementType] = {}
|
self.shuffleBoardList[elementType] = table.clearOrCreate(self.shuffleBoardList[elementType])
|
||||||
end
|
end
|
||||||
table.insert(gridEntityList[elementType], entity)
|
table.insert(self.shuffleBoardList[elementType], entity)
|
||||||
gridEntityCountMap[elementType] = (gridEntityCountMap[elementType] or 0) + 1
|
self.shuffleBoardCountMap[elementType] = (self.shuffleBoardCountMap[elementType] or 0) + 1
|
||||||
if not entity:canLink() then
|
if not entity:canLink() then
|
||||||
gridEntityCantLinkMap[elementType] = (gridEntityCountMap[elementType] or 0) + 1
|
self.shuffleBoardCantLinkMap[elementType] = (self.shuffleBoardCantLinkMap[elementType] or 0) + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(posList, posId)
|
table.insert(self.shuffleBoardPosList, posId)
|
||||||
posMap[posId] = true
|
self.shuffleBoardPosMap[posId] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for elementType, list in pairs(gridEntityList) do
|
for elementType, list in pairs(self.shuffleBoardList) do
|
||||||
table.sort(gridEntityList[elementType], function(a, b)
|
table.sort(self.shuffleBoardList[elementType], function(a, b)
|
||||||
if a:getSkillId() and not b:getSkillId() then
|
if a:getSkillId() and not b:getSkillId() then
|
||||||
return false
|
return false
|
||||||
elseif not a:getSkillId() and b:getSkillId() then
|
elseif not a:getSkillId() and b:getSkillId() then
|
||||||
@ -2035,11 +2045,10 @@ function BattleController:getShuffleBoardInfo()
|
|||||||
|
|
||||||
|
|
||||||
local needCount = self:getMinEliminationCount()
|
local needCount = self:getMinEliminationCount()
|
||||||
local tempList
|
|
||||||
local find = false
|
local find = false
|
||||||
for elementType, list in pairs(gridEntityList) do
|
for elementType, list in pairs(self.shuffleBoardList) do
|
||||||
local count = gridEntityCountMap[elementType] or 0
|
local count = self.shuffleBoardCountMap[elementType] or 0
|
||||||
local cantLinkCount = gridEntityCantLinkMap[elementType] or 0
|
local cantLinkCount = self.shuffleBoardCantLinkMap[elementType] or 0
|
||||||
local skillCount = 0
|
local skillCount = 0
|
||||||
if anySkillCount > 0 then
|
if anySkillCount > 0 then
|
||||||
skillCount = 1
|
skillCount = 1
|
||||||
@ -2047,7 +2056,7 @@ function BattleController:getShuffleBoardInfo()
|
|||||||
if count + skillCount - cantLinkCount >= needCount then
|
if count + skillCount - cantLinkCount >= needCount then
|
||||||
local haveSkill = false
|
local haveSkill = false
|
||||||
local listCount = 0
|
local listCount = 0
|
||||||
tempList = {}
|
self.shuffleBoardTempList = table.clearOrCreate(self.shuffleBoardList)
|
||||||
find = false
|
find = false
|
||||||
local add = false
|
local add = false
|
||||||
for _, entity in ipairs(list) do
|
for _, entity in ipairs(list) do
|
||||||
@ -2063,7 +2072,7 @@ function BattleController:getShuffleBoardInfo()
|
|||||||
add = entity:canLink()
|
add = entity:canLink()
|
||||||
end
|
end
|
||||||
if add then
|
if add then
|
||||||
table.insert(tempList, entity)
|
table.insert(self.shuffleBoardTempList, entity)
|
||||||
listCount = listCount + 1
|
listCount = listCount + 1
|
||||||
|
|
||||||
if listCount >= needCount then -- 可连接的 普通的元素+元素技能
|
if listCount >= needCount then -- 可连接的 普通的元素+元素技能
|
||||||
@ -2077,7 +2086,7 @@ function BattleController:getShuffleBoardInfo()
|
|||||||
find = true
|
find = true
|
||||||
break
|
break
|
||||||
elseif not haveSkill and skillCount > 0 then -- 可连接的 普通元素 + 任意元素技能
|
elseif not haveSkill and skillCount > 0 then -- 可连接的 普通元素 + 任意元素技能
|
||||||
table.insert(tempList, anySkillList[1])
|
table.insert(self.shuffleBoardTempList, self.shuffleBoardAnySkillList[1])
|
||||||
listCount = listCount + 1
|
listCount = listCount + 1
|
||||||
if listCount >= needCount then
|
if listCount >= needCount then
|
||||||
find = true
|
find = true
|
||||||
@ -2088,7 +2097,7 @@ function BattleController:getShuffleBoardInfo()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if find then
|
if find then
|
||||||
return self:shufflePos(tempList, posMap, needCount, posList)
|
return self:shufflePos(self.shuffleBoardTempList, self.shuffleBoardPosMap, needCount, self.shuffleBoardPosList)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2096,53 +2105,51 @@ function BattleController:shufflePos(tempList, posMap, needCount, posList)
|
|||||||
local gotPos, useMap, list = self:findCanLinkPosList(posMap, needCount)
|
local gotPos, useMap, list = self:findCanLinkPosList(posMap, needCount)
|
||||||
|
|
||||||
if gotPos and list[1] then
|
if gotPos and list[1] then
|
||||||
local changeInfo = {}
|
self.shufflePosInfo = table.clearOrCreate(self.shufflePosInfo)
|
||||||
local usedPos = {}
|
self.shufflerPosUsedPos = table.clearOrCreate(self.shufflerPosUsedPos)
|
||||||
local setedPos = {}
|
self.shufflerSetedPos = table.clearOrCreate(self.shufflerSetedPos)
|
||||||
for index, entity in ipairs(tempList) do
|
for index, entity in ipairs(tempList) do
|
||||||
changeInfo[entity:getPosId()] = list[index]
|
self.shufflePosInfo[entity:getPosId()] = list[index]
|
||||||
usedPos[list[index]] = true
|
self.shufflerPosUsedPos[list[index]] = true
|
||||||
setedPos[entity:getPosId()] = true
|
self.shufflerSetedPos[entity:getPosId()] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local newList = {}
|
self.shufflePosList1 = table.clearOrCreate(self.shufflePosList1)
|
||||||
local newList2 = {}
|
self.shufflePosList2 = table.clearOrCreate(self.shufflePosList2)
|
||||||
for index = #posList, 1, -1 do
|
for index = #posList, 1, -1 do
|
||||||
local posId = posList[index]
|
local posId = posList[index]
|
||||||
if not usedPos[posId] then
|
if not self.shufflerPosUsedPos[posId] then
|
||||||
table.insert(newList2, posId)
|
table.insert(self.shufflePosList2, posId)
|
||||||
end
|
end
|
||||||
if not setedPos[posId] then
|
if not self.shufflerSetedPos[posId] then
|
||||||
table.insert(newList, posId)
|
table.insert(self.shufflePosList1, posId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
newList2 = table.shuffle(newList2)
|
self.shufflePosList2 = table.shuffle(self.shufflePosList2)
|
||||||
for index, posId in ipairs(newList) do
|
for index, posId in ipairs(self.shufflePosList1) do
|
||||||
if not newList2[index] then
|
if not self.shufflePosList2[index] then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
changeInfo[posId] = newList2[index]
|
self.shufflePosInfo[posId] = self.shufflePosList2[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
return changeInfo
|
return self.shufflePosInfo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:findAttention()
|
function BattleController:findAttention()
|
||||||
local find = false
|
local find = false
|
||||||
local posIdMap = {}
|
|
||||||
local pathList
|
|
||||||
for r = 1, GConst.BattleConst.ROW_COUNT do
|
for r = 1, GConst.BattleConst.ROW_COUNT do
|
||||||
for c = 1, GConst.BattleConst.COLUMN_COUNT do
|
for c = 1, GConst.BattleConst.COLUMN_COUNT do
|
||||||
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
||||||
local gridEntity = self.battleData:getGridEntity(posId)
|
local gridEntity = self.battleData:getGridEntity(posId)
|
||||||
local mainElementType = gridEntity:getElementType()
|
local mainElementType = gridEntity:getElementType()
|
||||||
if gridEntity:canChangeInfo() then
|
if gridEntity:canChangeInfo() then
|
||||||
pathList = {}
|
self.findAttentionPathList = table.clearOrCreate(self.findAttentionPathList)
|
||||||
posIdMap = {}
|
self.findAttentionPosIdMap = table.clearOrCreate(self.findAttentionPosIdMap)
|
||||||
self:findLinkLine(posId, posIdMap, false, mainElementType, pathList)
|
self:findLinkLine(posId, self.findAttentionPosIdMap, false, mainElementType, self.findAttentionPathList)
|
||||||
if table.nums(pathList) >= self:getMinEliminationCount() then
|
if table.nums(self.findAttentionPathList) >= self:getMinEliminationCount() then
|
||||||
find = true
|
find = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -2153,42 +2160,42 @@ function BattleController:findAttention()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return find, pathList
|
return find, self.findAttentionPathList
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:_dealResetGridsDataFunc(posList)
|
function BattleController:_dealResetGridsDataFunc(posList)
|
||||||
local posMap = {}
|
self.dealResetFunc1PosMap = table.clearOrCreate(self.dealResetFunc1PosMap)
|
||||||
local lockElementMap = {}
|
self.dealResetFunc1LockElementMap = table.clearOrCreate(self.dealResetFunc1LockElementMap)
|
||||||
|
self.dealResetFunc1KeepSnapList = table.clearOrCreate(self.dealResetFunc1KeepSnapList)
|
||||||
|
self.dealResetFunc1KeepSnapSkillList = table.clearOrCreate(self.dealResetFunc1KeepSnapSkillList)
|
||||||
|
self.dealResetFunc1EmptySnapList = table.clearOrCreate(self.dealResetFunc1EmptySnapList)
|
||||||
local emptyCount = 0
|
local emptyCount = 0
|
||||||
local keepSnapList = {}
|
|
||||||
local keepSnapSkillList = {}
|
|
||||||
local emptySnapList = {}
|
|
||||||
for _, entity in ipairs(posList) do
|
for _, entity in ipairs(posList) do
|
||||||
local posId = entity:getPosId()
|
local posId = entity:getPosId()
|
||||||
posMap[posId] = entity
|
self.dealResetFunc1PosMap[posId] = entity
|
||||||
if entity:isEmptyIdle() then
|
if entity:isEmptyIdle() then
|
||||||
emptyCount = emptyCount + 1
|
emptyCount = emptyCount + 1
|
||||||
table.insert(emptySnapList, entity:getSnapshoptInfo())
|
table.insert(self.dealResetFunc1EmptySnapList, entity:getSnapshoptInfo())
|
||||||
elseif entity:isLock() and not entity:getSkillId() then
|
elseif entity:isLock() and not entity:getSkillId() then
|
||||||
lockElementMap[entity:getElementType()] = true
|
self.dealResetFunc1LockElementMap[entity:getElementType()] = true
|
||||||
emptyCount = emptyCount + 1
|
emptyCount = emptyCount + 1
|
||||||
local snapInfo = entity:getSnapshoptInfo()
|
local snapInfo = entity:getSnapshoptInfo()
|
||||||
snapInfo.gridType = BattleConst.GRID_TYPE.EMPTY
|
snapInfo.gridType = BattleConst.GRID_TYPE.EMPTY
|
||||||
table.insert(emptySnapList, snapInfo)
|
table.insert(self.dealResetFunc1EmptySnapList, snapInfo)
|
||||||
else
|
else
|
||||||
if entity:getSkillId() then
|
if entity:getSkillId() then
|
||||||
table.insert(keepSnapSkillList, entity:getSnapshoptInfo())
|
table.insert(self.dealResetFunc1KeepSnapSkillList, entity:getSnapshoptInfo())
|
||||||
else
|
else
|
||||||
table.insert(keepSnapList, entity:getSnapshoptInfo())
|
table.insert(self.dealResetFunc1KeepSnapList, entity:getSnapshoptInfo())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return posMap, lockElementMap, emptyCount, keepSnapList, keepSnapSkillList, emptySnapList
|
return self.dealResetFunc1PosMap, self.dealResetFunc1LockElementMap, emptyCount, self.dealResetFunc1KeepSnapList, self.dealResetFunc1KeepSnapSkillList, self.dealResetFunc1EmptySnapList
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:_dealResetGridsDataFunc2(useMap, emptySnapList, mainElement, backupSkill, keepSnapList, posMap, canRandomElmentList, elementCount, lockElementMap)
|
function BattleController:_dealResetGridsDataFunc2(useMap, emptySnapList, mainElement, backupSkill, keepSnapList, posMap, canRandomElmentList, elementCount, lockElementMap)
|
||||||
local resetPosInfo = {}
|
self.dealResetFunc2ResetPosInfo = table.clearOrCreate(self.dealResetFunc2ResetPosInfo)
|
||||||
for posId, _ in pairs(useMap) do
|
for posId, _ in pairs(useMap) do
|
||||||
local snapInfo
|
local snapInfo
|
||||||
if emptySnapList[1] then
|
if emptySnapList[1] then
|
||||||
@ -2199,7 +2206,7 @@ function BattleController:_dealResetGridsDataFunc2(useMap, emptySnapList, mainEl
|
|||||||
else
|
else
|
||||||
snapInfo = backupSkill
|
snapInfo = backupSkill
|
||||||
end
|
end
|
||||||
resetPosInfo[posId] = snapInfo
|
self.dealResetFunc2ResetPosInfo[posId] = snapInfo
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, snap in ipairs(emptySnapList) do
|
for _, snap in ipairs(emptySnapList) do
|
||||||
@ -2225,12 +2232,12 @@ function BattleController:_dealResetGridsDataFunc2(useMap, emptySnapList, mainEl
|
|||||||
end
|
end
|
||||||
|
|
||||||
if snapInfo then
|
if snapInfo then
|
||||||
resetPosInfo[posId] = snapInfo
|
self.dealResetFunc2ResetPosInfo[posId] = snapInfo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return resetPosInfo
|
return self.dealResetFunc2ResetPosInfo
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:resetGrids(posList)
|
function BattleController:resetGrids(posList)
|
||||||
@ -2264,13 +2271,7 @@ function BattleController:resetGrids(posList)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.canRandomElmentList then
|
self.canRandomElmentList = table.clearOrCreate(self.canRandomElmentList)
|
||||||
self.canRandomElmentList = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = #self.canRandomElmentList, 1, -1 do
|
|
||||||
table.remove(self.canRandomElmentList)
|
|
||||||
end
|
|
||||||
|
|
||||||
local elementCount = 0
|
local elementCount = 0
|
||||||
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
|
for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do
|
||||||
@ -2297,12 +2298,12 @@ function BattleController:resetGrids(posList)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:findCanLinkPosList(posMap, needCount)
|
function BattleController:findCanLinkPosList(posMap, needCount)
|
||||||
local list = {}
|
self.findCanLinkList = table.clearOrCreate(self.findCanLinkList)
|
||||||
local useMap = {}
|
self.findCanUseMap = table.clearOrCreate(self.findCanUseMap)
|
||||||
local gotPos = false
|
local gotPos = false
|
||||||
for posId, _ in pairs(posMap) do
|
for posId, _ in pairs(posMap) do
|
||||||
list = {}
|
table.clear(self.findCanLinkList)
|
||||||
useMap = {}
|
table.clear(self.findCanUseMap)
|
||||||
local count = 0
|
local count = 0
|
||||||
local findPodId = posId
|
local findPodId = posId
|
||||||
gotPos = false
|
gotPos = false
|
||||||
@ -2313,10 +2314,10 @@ function BattleController:findCanLinkPosList(posMap, needCount)
|
|||||||
end
|
end
|
||||||
local got = false
|
local got = false
|
||||||
for id, status in pairs(aounrdList) do
|
for id, status in pairs(aounrdList) do
|
||||||
if posMap[id] and not useMap[id] then
|
if posMap[id] and not self.findCanUseMap[id] then
|
||||||
table.insert(list, id)
|
table.insert(self.findCanLinkList, id)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
useMap[id] = true
|
self.findCanUseMap[id] = true
|
||||||
findPodId = id
|
findPodId = id
|
||||||
got = true
|
got = true
|
||||||
break
|
break
|
||||||
@ -2336,7 +2337,7 @@ function BattleController:findCanLinkPosList(posMap, needCount)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return gotPos, useMap, list
|
return gotPos, self.findCanUseMap, self.findCanLinkList
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementType, lineList)
|
function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementType, lineList)
|
||||||
|
|||||||
@ -1762,7 +1762,7 @@ function BattleUI:playSkillLineSfx(posId, boradRangeList, randomPosList)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if randomPosList then
|
if randomPosList and randomPosList[1] then
|
||||||
local count = math.min(#randomPosList, 5) -- 特效最多5个
|
local count = math.min(#randomPosList, 5) -- 特效最多5个
|
||||||
self.skillLightSfxs.point:setAnchoredPosition(pos.x, pos.y)
|
self.skillLightSfxs.point:setAnchoredPosition(pos.x, pos.y)
|
||||||
self.skillLightSfxs.point:setActive(true)
|
self.skillLightSfxs.point:setActive(true)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user