一些棋盘上的技能调整
This commit is contained in:
parent
de7643a18f
commit
e68d5a1982
@ -125,20 +125,20 @@ function BattleManager:getFirstLineLastRowPosId(row, column)
|
||||
return self:getPosId(1 - row, column)
|
||||
end
|
||||
|
||||
function BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap)
|
||||
local ids = {}
|
||||
function BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap, randomExclusion)
|
||||
local posIdInfos = {}
|
||||
for _, info in ipairs(boardrange) do
|
||||
local list = self:getAroundPosIds(posId, info.type, info.range, cludePosIdsMap)
|
||||
for _, posId in ipairs(list) do
|
||||
table.insert(ids, posId)
|
||||
cludePosIdsMap[posId] = nil
|
||||
local list = self:getAroundPosIds(posId, info.type, info.range, cludePosIdsMap, randomExclusion)
|
||||
for _, info in ipairs(list) do
|
||||
table.insert(posIdInfos, info)
|
||||
cludePosIdsMap[info.posId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
return ids
|
||||
return posIdInfos
|
||||
end
|
||||
|
||||
function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap, randomExclusion)
|
||||
local rc = self:getPosRC(posId)
|
||||
local r = rc.r
|
||||
local c = rc.c
|
||||
@ -148,36 +148,38 @@ function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
if cludePosIdsMap then
|
||||
local cludePosIds = {}
|
||||
for posId, _ in pairs(cludePosIdsMap) do
|
||||
table.insert(cludePosIds, posId)
|
||||
if not randomExclusion or not randomExclusion[posId] then
|
||||
table.insert(cludePosIds, posId)
|
||||
end
|
||||
end
|
||||
|
||||
local count = math.min(#cludePosIds, range)
|
||||
for i = 1, count do
|
||||
table.insert(posIdList, cludePosIds[math.random(1, #cludePosIds)])
|
||||
table.insert(posIdList, {posId = cludePosIds[math.random(1, #cludePosIds)], direction = direction})
|
||||
end
|
||||
end
|
||||
elseif direction == BattleConst.BOARD_RANGE_TYPE.UP then
|
||||
for i = r - 1, r - range, -1 do
|
||||
if i >= 1 then
|
||||
table.insert(posIdList, self:getPosId(i, c))
|
||||
table.insert(posIdList, {posId = self:getPosId(i, c), direction = direction})
|
||||
end
|
||||
end
|
||||
elseif direction == BattleConst.BOARD_RANGE_TYPE.DOWN then
|
||||
for i = r + 1, r + range do
|
||||
if i <= BattleConst.ROW_COUNT then
|
||||
table.insert(posIdList, self:getPosId(i, c))
|
||||
table.insert(posIdList, {posId = self:getPosId(i, c), direction = direction})
|
||||
end
|
||||
end
|
||||
elseif direction == BattleConst.BOARD_RANGE_TYPE.LEFT then
|
||||
for i = c - 1, c - range, -1 do
|
||||
if i >= 1 then
|
||||
table.insert(posIdList, self:getPosId(r, i))
|
||||
table.insert(posIdList, {posId = self:getPosId(r, i), direction = direction})
|
||||
end
|
||||
end
|
||||
elseif direction == BattleConst.BOARD_RANGE_TYPE.RIGHT then
|
||||
for i = c + 1, c + range do
|
||||
if i <= BattleConst.COLUMN_COUNT then
|
||||
table.insert(posIdList, self:getPosId(r, i))
|
||||
table.insert(posIdList, {posId = self:getPosId(r, i), direction = direction})
|
||||
end
|
||||
end
|
||||
elseif direction == BattleConst.BOARD_RANGE_TYPE.LEFT_UP then
|
||||
@ -185,7 +187,7 @@ function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
if i >= 1 then
|
||||
for j = r - 1, r - range, -1 do
|
||||
if j >= 1 then
|
||||
table.insert(posIdList, self:getPosId(j, i))
|
||||
table.insert(posIdList, {posId = self:getPosId(j, i), direction = direction})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -195,7 +197,7 @@ function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
if i >= 1 then
|
||||
for j = r + 1, r + range do
|
||||
if j <= BattleConst.ROW_COUNT then
|
||||
table.insert(posIdList, self:getPosId(j, i))
|
||||
table.insert(posIdList, {posId = self:getPosId(j, i), direction = direction})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -205,7 +207,7 @@ function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
if i <= BattleConst.COLUMN_COUNT then
|
||||
for j = r - 1, r - range, -1 do
|
||||
if j >= 1 then
|
||||
table.insert(posIdList, self:getPosId(j, i))
|
||||
table.insert(posIdList, {posId = self:getPosId(j, i), direction = direction})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -215,7 +217,7 @@ function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
if i <= BattleConst.COLUMN_COUNT then
|
||||
for j = r + 1, r + range do
|
||||
if j <= BattleConst.ROW_COUNT then
|
||||
table.insert(posIdList, self:getPosId(j, i))
|
||||
table.insert(posIdList, {posId = self:getPosId(j, i), direction = direction})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -224,9 +226,9 @@ function BattleManager:getAroundPosIds(posId, direction, range, cludePosIdsMap)
|
||||
|
||||
if cludePosIdsMap then
|
||||
local newList = {}
|
||||
for _, posId in ipairs(posIdList) do
|
||||
if cludePosIdsMap[posId] then
|
||||
table.insert(newList, posId)
|
||||
for _, info in ipairs(posIdList) do
|
||||
if cludePosIdsMap[info.posId] then
|
||||
table.insert(newList, info)
|
||||
end
|
||||
end
|
||||
return newList
|
||||
|
||||
@ -69,18 +69,18 @@ function BattleController:onLinkChange()
|
||||
end
|
||||
end
|
||||
|
||||
for posId, _ in pairs(self.battleData:getSkillInfluenceGrids()) do
|
||||
for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do
|
||||
local entity = self.battleData:getGridEntity(posId)
|
||||
if not posIdMap[posId] then
|
||||
posIdMap[posId] = true
|
||||
local entity = self.battleData:getGridEntity(posId)
|
||||
if not entity:getSkillId() then
|
||||
local elementType = entity:getElementType()
|
||||
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
|
||||
end
|
||||
end
|
||||
|
||||
if entity:getCell() then
|
||||
entity:getCell():showCircle(true)
|
||||
end
|
||||
if entity:getCell() and info.direction ~= BattleConst.BOARD_RANGE_TYPE.RANDOM then
|
||||
entity:getCell():showCircle(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -737,17 +737,25 @@ function BattleController:findSkillInfluenceGrids()
|
||||
local girds = self.battleData:clearSkillInfluenceGrids()
|
||||
for posId, _ in pairs(girds) do
|
||||
local entity = self.battleData:getGridEntity(posId)
|
||||
entity:setNeedElimination(false)
|
||||
if entity:getCell() then
|
||||
entity:getCell():showCircle(false)
|
||||
end
|
||||
end
|
||||
|
||||
local sequence = self.battleData:getGridSequence()
|
||||
local sequenceEntities = {}
|
||||
for _, info in ipairs(sequence) do
|
||||
local entity = self.battleData:getGridEntity(info.posId)
|
||||
table.insert(sequenceEntities, entity)
|
||||
end
|
||||
|
||||
for _, info in ipairs(sequence) do
|
||||
local entity = self.battleData:getGridEntity(info.posId)
|
||||
local skillId = entity:getSkillId()
|
||||
if skillId then
|
||||
local skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
|
||||
if skillEntity then
|
||||
BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, self.battleData:getGridEnties())
|
||||
BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, self.battleData:getGridEnties(), sequenceEntities)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -5,7 +5,7 @@ local BattleBoardSkillHandle = {}
|
||||
local SKILL_TYPE = BattleConst.SKILL_TYPE
|
||||
local SKILL_METHOD_TYPE = BattleConst.SKILL_METHOD_TYPE
|
||||
|
||||
local function _takeElimination(posId, skillEntity, gridEntities)
|
||||
local function _takeElimination(posId, skillEntity, gridEntities, sequenceEntities)
|
||||
local boardrange = skillEntity:getBoardRange()
|
||||
if boardrange then
|
||||
local cludePosIdsMap = {}
|
||||
@ -14,16 +14,20 @@ local function _takeElimination(posId, skillEntity, gridEntities)
|
||||
cludePosIdsMap[posId] = true
|
||||
end
|
||||
end
|
||||
local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap)
|
||||
local randomExclusion = {}
|
||||
for _, entity in ipairs(sequenceEntities) do
|
||||
randomExclusion[entity:getPosId()] = true
|
||||
end
|
||||
local posIdInfos = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap, randomExclusion)
|
||||
cludePosIdsMap = {}
|
||||
for _, posId in ipairs(ids) do
|
||||
cludePosIdsMap[posId] = true
|
||||
for _, info in ipairs(posIdInfos) do
|
||||
cludePosIdsMap[info.posId] = info
|
||||
end
|
||||
DataManager.BattleData:cacheSkillInfluenceGrids(cludePosIdsMap)
|
||||
end
|
||||
end
|
||||
|
||||
local function _takeChangeAround(posId, skillEntity, gridEntities)
|
||||
local function _takeChangeAround(posId, skillEntity, gridEntities, sequenceEntities)
|
||||
local boardrange = skillEntity:getBoardRange()
|
||||
if boardrange then
|
||||
local cludePosIdsMap = {}
|
||||
@ -32,9 +36,9 @@ local function _takeChangeAround(posId, skillEntity, gridEntities)
|
||||
cludePosIdsMap[posId] = true
|
||||
end
|
||||
end
|
||||
local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap)
|
||||
for _, posId in ipairs(ids) do
|
||||
local entity = gridEntities[posId]
|
||||
local posIdInfos = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap)
|
||||
for _, info in ipairs(posIdInfos) do
|
||||
local entity = gridEntities[info.posId]
|
||||
if entity then
|
||||
entity:setElementType(skillEntity:getSkillTypeParameter())
|
||||
end
|
||||
@ -47,21 +51,14 @@ BattleBoardSkillHandle._activeBoardSkill = {
|
||||
[SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround,
|
||||
}
|
||||
|
||||
function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities)
|
||||
function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, sequenceEntities)
|
||||
if not skillEntity then
|
||||
return
|
||||
end
|
||||
|
||||
if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_FINAL then
|
||||
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
|
||||
if func then
|
||||
func(posId, skillEntity, gridEntities)
|
||||
end
|
||||
elseif skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_ENTER then
|
||||
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
|
||||
if func then
|
||||
func(posId, skillEntity, gridEntities)
|
||||
end
|
||||
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
|
||||
if func then
|
||||
func(posId, skillEntity, gridEntities, sequenceEntities)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -129,8 +129,8 @@ function BattleData:cacheSkillInfluenceGrids(grids)
|
||||
if not self.skillInfluenceGrids then
|
||||
self.skillInfluenceGrids = {}
|
||||
end
|
||||
for posId, status in pairs(grids) do
|
||||
self.skillInfluenceGrids[posId] = true
|
||||
for posId, info in pairs(grids) do
|
||||
self.skillInfluenceGrids[posId] = info
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -185,11 +185,6 @@ function BattleGridEntity:isEmptyIdle()
|
||||
return false
|
||||
end
|
||||
|
||||
function BattleGridEntity:setNeedElimination(need)
|
||||
self.needElimination = need
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function BattleGridEntity:getNeedElimination()
|
||||
return self.needElimination
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user