随机消灭x行列空闲元素技能机制

This commit is contained in:
xiekaidong 2023-05-11 16:57:39 +08:00
parent 5f7cca6351
commit bea9daf0bc
3 changed files with 74 additions and 0 deletions

View File

@ -687,6 +687,7 @@ BattleConst.SKILL_TYPE = {
CHANGE_ALL_ELEMENT_TYPE = 5,
RANDOM_KILL_SKILL_GRID = 6,
SHUFFLE_BOARD = 7,
RANDOM_KILL_ROW_OR_COLUMN = 8,
}
BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = {
@ -694,6 +695,7 @@ BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = {
[BattleConst.SKILL_TYPE.CHANGE_ALL_ELEMENT_TYPE] = true,
[BattleConst.SKILL_TYPE.RANDOM_KILL_SKILL_GRID] = true,
[BattleConst.SKILL_TYPE.SHUFFLE_BOARD] = true,
[BattleConst.SKILL_TYPE.RANDOM_KILL_ROW_OR_COLUMN] = true,
}
BattleConst.SKILL_METHOD_TYPE = {

View File

@ -1711,6 +1711,22 @@ function BattleController:killGrids(posIdList)
self.battleUI:removeGridOutOfScreen(posIdList)
end
function BattleController:killRowOrColumn(infoList)
local map = {}
for _, info in ipairs(infoList) do
if info.posList then
for i, posId in ipairs(info.posList) do
if not map[posId] then
map[posId] = true
local entity = DataManager.BattleData:getGridEntity(posId)
entity:setIsIdle(true)
end
end
self.battleUI:removeGridOutOfScreen(info.posList)
end
end
end
function BattleController:addHeroAttr(attrName, value)
if not self.battleData or not self.battleData.atkTeam then
return

View File

@ -146,6 +146,61 @@ local function _takeShuffleBoard(atkUnitComp, skillEntity, battleController)
battleController:shuffleBoard()
end
local function _takeRandomKillRowOrColumn(atkUnitComp, skillEntity, battleController)
local battleData = battleController.battleData
if not battleData or not battleData:getGridEnties() or not skillEntity:getEliminateSkillParameter() then
return
end
local count = skillEntity:getEliminateSkillParameter()[1]
if count <= 0 then
return
end
local listCount = 0
local list = {}
local rowMap = {}
local columnMap = {}
for posId, entity in pairs(battleData:getGridEnties()) do
if entity:isEmptyIdle() then
local rc = ModuleManager.BattleManager:getPosRC(posId)
local r = rc.r
local c = rc.c
if not rowMap[r] then
table.insert(list, {r = r})
listCount = listCount + 1
rowMap[r] = {}
end
if not columnMap[c] then
table.insert(list, {c = c})
listCount = listCount + 1
columnMap[c] = {}
end
table.insert(rowMap[r], posId)
table.insert(columnMap[c], posId)
end
end
local infoList = {}
for i = 1, count do
if not list[1] then
break
end
local info = table.remove(list, math.random(1, listCount))
listCount = listCount - 1
if info.r then
info.posList = rowMap[info.r]
elseif info.c then
info.posList = columnMap[info.c]
end
if info.posList then
table.insert(infoList, info)
end
end
battleController:killRowOrColumn(infoList)
end
BattleBoardSkillHandle._activeBoardSkill = {
[SKILL_TYPE.ELIMINATION] = _takeElimination,
[SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround,
@ -157,6 +212,7 @@ BattleBoardSkillHandle._activeAttackOverSkill = {
[SKILL_TYPE.CHANGE_ALL_ELEMENT_TYPE] = _takeChangeAllElementType,
[SKILL_TYPE.RANDOM_KILL_SKILL_GRID] = _takeRandomKillSkillGrid,
[SKILL_TYPE.SHUFFLE_BOARD] = _takeShuffleBoard,
[SKILL_TYPE.RANDOM_KILL_ROW_OR_COLUMN] = _takeRandomKillRowOrColumn,
}
function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, sequenceEntities, battleController)