技能回收和吐出来
This commit is contained in:
parent
9722405d9e
commit
cbad76a7d9
@ -825,7 +825,6 @@ local chapter_board = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
["control_element"]={
|
["control_element"]={
|
||||||
0
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[5]={
|
[5]={
|
||||||
|
|||||||
@ -5,7 +5,7 @@ BattleConst.COLUMN_COUNT = 7
|
|||||||
BattleConst.HALF_ROW_COUNT = 4 -- 计算偏移 math.ceil(ROW_COUNT / 2)
|
BattleConst.HALF_ROW_COUNT = 4 -- 计算偏移 math.ceil(ROW_COUNT / 2)
|
||||||
BattleConst.HALF_COLUMN_COUNT = 4 -- 计算偏移 math.ceil(COLUMN_COUNT / 2)
|
BattleConst.HALF_COLUMN_COUNT = 4 -- 计算偏移 math.ceil(COLUMN_COUNT / 2)
|
||||||
BattleConst.ELIMINATION_MIN_COUNT = 2
|
BattleConst.ELIMINATION_MIN_COUNT = 2
|
||||||
BattleConst.GRID_STEP_H = 97
|
BattleConst.GRID_STEP_H = 94
|
||||||
BattleConst.ROW_STEP = 10
|
BattleConst.ROW_STEP = 10
|
||||||
BattleConst.ONE_STEP_TIME = 0.2
|
BattleConst.ONE_STEP_TIME = 0.2
|
||||||
BattleConst.ELEMENT_TYPE_COUNT = 5
|
BattleConst.ELEMENT_TYPE_COUNT = 5
|
||||||
@ -102,55 +102,55 @@ BattleConst.RC_2_POS_ID = {}
|
|||||||
|
|
||||||
---- 格子位置
|
---- 格子位置
|
||||||
BattleConst.GRID_POS = {
|
BattleConst.GRID_POS = {
|
||||||
[11] = {x = -291, y = 291},
|
[11] = {x = -282, y = 282},
|
||||||
[12] = {x = -194, y = 291},
|
[12] = {x = -188, y = 282},
|
||||||
[13] = {x = -97, y = 291},
|
[13] = {x = -94, y = 282},
|
||||||
[14] = {x = 0, y = 291},
|
[14] = {x = 0, y = 282},
|
||||||
[15] = {x = 97, y = 291},
|
[15] = {x = 94, y = 282},
|
||||||
[16] = {x = 194, y = 291},
|
[16] = {x = 188, y = 282},
|
||||||
[17] = {x = 291, y = 291},
|
[17] = {x = 282, y = 282},
|
||||||
[21] = {x = -291, y = 194},
|
[21] = {x = -282, y = 188},
|
||||||
[22] = {x = -194, y = 194},
|
[22] = {x = -188, y = 188},
|
||||||
[23] = {x = -97, y = 194},
|
[23] = {x = -94, y = 188},
|
||||||
[24] = {x = 0, y = 194},
|
[24] = {x = 0, y = 188},
|
||||||
[25] = {x = 97, y = 194},
|
[25] = {x = 94, y = 188},
|
||||||
[26] = {x = 194, y = 194},
|
[26] = {x = 188, y = 188},
|
||||||
[27] = {x = 291, y = 194},
|
[27] = {x = 282, y = 188},
|
||||||
[31] = {x = -291, y = 97},
|
[31] = {x = -282, y = 94},
|
||||||
[32] = {x = -194, y = 97},
|
[32] = {x = -188, y = 94},
|
||||||
[33] = {x = -97, y = 97},
|
[33] = {x = -94, y = 94},
|
||||||
[34] = {x = 0, y = 97},
|
[34] = {x = 0, y = 94},
|
||||||
[35] = {x = 97, y = 97},
|
[35] = {x = 94, y = 94},
|
||||||
[36] = {x = 194, y = 97},
|
[36] = {x = 188, y = 94},
|
||||||
[37] = {x = 291, y = 97},
|
[37] = {x = 282, y = 94},
|
||||||
[41] = {x = -291, y = 0},
|
[41] = {x = -282, y = 0},
|
||||||
[42] = {x = -194, y = 0},
|
[42] = {x = -188, y = 0},
|
||||||
[43] = {x = -97, y = 0},
|
[43] = {x = -94, y = 0},
|
||||||
[44] = {x = 0, y = 0},
|
[44] = {x = 0, y = 0},
|
||||||
[45] = {x = 97, y = 0},
|
[45] = {x = 94, y = 0},
|
||||||
[46] = {x = 194, y = 0},
|
[46] = {x = 188, y = 0},
|
||||||
[47] = {x = 291, y = 0},
|
[47] = {x = 282, y = 0},
|
||||||
[51] = {x = -291, y = -97},
|
[51] = {x = -282, y = -94},
|
||||||
[52] = {x = -194, y = -97},
|
[52] = {x = -188, y = -94},
|
||||||
[53] = {x = -97, y = -97},
|
[53] = {x = -94, y = -94},
|
||||||
[54] = {x = 0, y = -97},
|
[54] = {x = 0, y = -94},
|
||||||
[55] = {x = 97, y = -97},
|
[55] = {x = 94, y = -94},
|
||||||
[56] = {x = 194, y = -97},
|
[56] = {x = 188, y = -94},
|
||||||
[57] = {x = 291, y = -97},
|
[57] = {x = 282, y = -94},
|
||||||
[61] = {x = -291, y = -194},
|
[61] = {x = -282, y = -188},
|
||||||
[62] = {x = -194, y = -194},
|
[62] = {x = -188, y = -188},
|
||||||
[63] = {x = -97, y = -194},
|
[63] = {x = -94, y = -188},
|
||||||
[64] = {x = 0, y = -194},
|
[64] = {x = 0, y = -188},
|
||||||
[65] = {x = 97, y = -194},
|
[65] = {x = 94, y = -188},
|
||||||
[66] = {x = 194, y = -194},
|
[66] = {x = 188, y = -188},
|
||||||
[67] = {x = 291, y = -194},
|
[67] = {x = 282, y = -188},
|
||||||
[71] = {x = -291, y = -291},
|
[71] = {x = -282, y = -282},
|
||||||
[72] = {x = -194, y = -291},
|
[72] = {x = -188, y = -282},
|
||||||
[73] = {x = -97, y = -291},
|
[73] = {x = -94, y = -282},
|
||||||
[74] = {x = 0, y = -291},
|
[74] = {x = 0, y = -282},
|
||||||
[75] = {x = 97, y = -291},
|
[75] = {x = 94, y = -282},
|
||||||
[76] = {x = 194, y = -291},
|
[76] = {x = 188, y = -282},
|
||||||
[77] = {x = 291, y = -291},
|
[77] = {x = 282, y = -282},
|
||||||
}
|
}
|
||||||
|
|
||||||
---- 每个格子外围一格距离的格子
|
---- 每个格子外围一格距离的格子
|
||||||
|
|||||||
@ -241,8 +241,8 @@ function BattleController:onTouchEvent(eventType, posId)
|
|||||||
if lastEntity:getNeedChangePos() and not entity:getNeedChangePos() then -- 需要移动到队列末尾
|
if lastEntity:getNeedChangePos() and not entity:getNeedChangePos() then -- 需要移动到队列末尾
|
||||||
local lastSkillId = lastEntity:getSkillId()
|
local lastSkillId = lastEntity:getSkillId()
|
||||||
local skillId = entity:getSkillId()
|
local skillId = entity:getSkillId()
|
||||||
lastEntity:setSkilId(skillId)
|
self:setGridSkillId(lastPosId, skillId)
|
||||||
entity:setSkilId(lastSkillId)
|
self:setGridSkillId(posId, lastSkillId)
|
||||||
end
|
end
|
||||||
|
|
||||||
local newElementType = elementType or lastElementType
|
local newElementType = elementType or lastElementType
|
||||||
@ -433,6 +433,7 @@ function BattleController:fillBoard()
|
|||||||
-- local gridType = list[math.random(1, 4)]
|
-- local gridType = list[math.random(1, 4)]
|
||||||
-- self:generateGridType(gridType)
|
-- self:generateGridType(gridType)
|
||||||
-- ModuleManager.BattleManager:showSelectSkillUI(self:getRandomSkillList())
|
-- ModuleManager.BattleManager:showSelectSkillUI(self:getRandomSkillList())
|
||||||
|
-- self:generateBoard()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -493,7 +494,8 @@ function BattleController:generateInstructions(skillEntity, elementType, influen
|
|||||||
if elementTypeCount > 0 then
|
if elementTypeCount > 0 then
|
||||||
table.insert(instructions, {
|
table.insert(instructions, {
|
||||||
name = BattleConst.INSTRUCTION_NAME.GENERAL_ATTACK,
|
name = BattleConst.INSTRUCTION_NAME.GENERAL_ATTACK,
|
||||||
count = elementTypeCount
|
count = elementTypeCount,
|
||||||
|
skillMatch = elementType
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -527,10 +529,42 @@ function BattleController:generateBoard()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local skillCount = 0
|
||||||
|
local skillList = {}
|
||||||
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
|
if entity:getSkillId() then
|
||||||
|
table.insert(skillList, {skillId = entity:getSkillId(), posId = posId})
|
||||||
|
skillCount = skillCount + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.battleUI:cacheSkillAni(skillList, false, function()
|
||||||
self.curBoardIndex = (self.curBoardIndex or 0) + 1
|
self.curBoardIndex = (self.curBoardIndex or 0) + 1
|
||||||
local board = boardList[self.curBoardIndex]
|
local board = boardList[self.curBoardIndex]
|
||||||
self.battleData:refreshBoard(board)
|
self.battleData:refreshBoard(board)
|
||||||
self.battleUI:initGridCell()
|
self.battleUI:initGridCell()
|
||||||
|
|
||||||
|
if skillCount > 0 then
|
||||||
|
local posidList = {}
|
||||||
|
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||||
|
if entity:isEmptyIdle() then
|
||||||
|
table.insert(posidList, posId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
posidList = table.shuffle(posidList)
|
||||||
|
local newSkillId = {}
|
||||||
|
for index, info in ipairs(skillList) do
|
||||||
|
if posidList[1] then
|
||||||
|
newSkillId[index] = info
|
||||||
|
newSkillId[index].posId = table.remove(posidList)
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.battleUI:cacheSkillAni(newSkillId, true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:generateSkill()
|
function BattleController:generateSkill()
|
||||||
@ -544,13 +578,18 @@ function BattleController:generateSkill()
|
|||||||
for elementType, skillId in pairs(map) do
|
for elementType, skillId in pairs(map) do
|
||||||
local list = self:getSkillElementList(elementType, 1, true)
|
local list = self:getSkillElementList(elementType, 1, true)
|
||||||
for _, posId in ipairs(list) do
|
for _, posId in ipairs(list) do
|
||||||
|
self:setGridSkillId(posId, skillId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleController:setGridSkillId(posId, skillId)
|
||||||
local entity = self.battleData:getGridEntity(posId)
|
local entity = self.battleData:getGridEntity(posId)
|
||||||
if entity then
|
if entity then
|
||||||
entity:setSkilId(skillId)
|
entity:setSkilId(skillId)
|
||||||
if entity:getElementType() ~= elementType then
|
local skillEntity = self.battleData:getSkillEntityBySkillId(skillId)
|
||||||
entity:setElementType(elementType)
|
if skillEntity and entity:getElementType() ~= skillEntity:getPosition() then
|
||||||
end
|
entity:setElementType(skillEntity:getPosition())
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,6 +25,9 @@ function BattleUI:_display()
|
|||||||
self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
||||||
self.boardMask = uiMap["battle_ui.bg_2.board_mask"]
|
self.boardMask = uiMap["battle_ui.bg_2.board_mask"]
|
||||||
self.boardMask:setVisible(false)
|
self.boardMask:setVisible(false)
|
||||||
|
self.boardCacheNode = uiMap["battle_ui.bg_2.board_cache_node"]
|
||||||
|
self.boardCacheNode:setVisible(false)
|
||||||
|
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
|
||||||
self:initSkill()
|
self:initSkill()
|
||||||
self:initBattlefield()
|
self:initBattlefield()
|
||||||
end
|
end
|
||||||
@ -264,4 +267,144 @@ function BattleUI:fallGrid(listInfo, callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUI:cacheSkillAni(skillInfo, isPop, callback)
|
||||||
|
local skillInfoCount = #skillInfo
|
||||||
|
if skillInfoCount <= 0 then
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self:disableUITouch()
|
||||||
|
|
||||||
|
if not self.root.skillAniGridEntities then
|
||||||
|
self.root.skillAniGridEntities = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, entity in ipairs(self.root.skillAniGridEntities) do
|
||||||
|
local cell = entity:getCell()
|
||||||
|
if cell then
|
||||||
|
cell:getBaseObject():setAnchoredPositionX(DEFAULT_X) -- 放到屏幕外
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local gridEntityCount = #self.root.skillAniGridEntities
|
||||||
|
if gridEntityCount < skillInfoCount then
|
||||||
|
for i = gridEntityCount, skillInfoCount do
|
||||||
|
CellManager:loadCellAsync(GRID_CELL_PATH, GRID_CELL, self.boardCacheNode, function(cell)
|
||||||
|
cell:getBaseObject():setAnchoredPositionX(DEFAULT_X) -- 初始化时放到屏幕外
|
||||||
|
local entity = DataManager.BattleData:getNewGridEntity()
|
||||||
|
entity:setCell(cell)
|
||||||
|
table.insert(self.root.skillAniGridEntities, entity)
|
||||||
|
if i == skillInfoCount then
|
||||||
|
if isPop then
|
||||||
|
self:doCachePopAni(skillInfo, callback)
|
||||||
|
else
|
||||||
|
self:doCacheAni(skillInfo, callback)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if isPop then
|
||||||
|
self:doCachePopAni(skillInfo, callback)
|
||||||
|
else
|
||||||
|
self:doCacheAni(skillInfo, callback)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:doCacheAni(skillInfo, callback)
|
||||||
|
if self.cacheSkillAniSeq then
|
||||||
|
self.cacheSkillAniSeq:Kill()
|
||||||
|
self.cacheSkillAniSeq = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.root.skillAniGridEntities then
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.boardCacheNode:setVisible(true)
|
||||||
|
|
||||||
|
self.cacheSkillAniSeq = self.root:createBindTweenSequence()
|
||||||
|
for index, info in ipairs(skillInfo) do
|
||||||
|
local entity = self.root.skillAniGridEntities[index]
|
||||||
|
if entity then
|
||||||
|
entity:setSkilId(info.skillId)
|
||||||
|
local pos = ModuleManager.BattleManager:getPosInfo(info.posId)
|
||||||
|
local cell = entity:getCell()
|
||||||
|
if cell then
|
||||||
|
cell:refresh(entity)
|
||||||
|
local obj = cell:getBaseObject()
|
||||||
|
self.cacheSkillAniSeq:InsertCallback(0.5 * (index - 1), function()
|
||||||
|
obj:setAnchoredPosition(pos.x, pos.y)
|
||||||
|
local gridEntity = DataManager.BattleData:getGridEntity(info.posId)
|
||||||
|
if gridEntity and gridEntity:getCell() then
|
||||||
|
gridEntity:getCell():getBaseObject():setAnchoredPositionX(DEFAULT_X) -- 放到屏幕外
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.cacheSkillAniSeq:Insert(0.5 * (index - 1) + 0.02, obj:getTransform():DOAnchorPos(BF.Vector2(0, 656), 0.5))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.cacheSkillAniSeq:AppendCallback(function()
|
||||||
|
self.boardCacheNode:setVisible(false)
|
||||||
|
self:enableUITouch()
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUI:doCachePopAni(skillInfo, callback)
|
||||||
|
if self.cacheSkillAniSeq then
|
||||||
|
self.cacheSkillAniSeq:Kill()
|
||||||
|
self.cacheSkillAniSeq = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self.root.skillAniGridEntities then
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.boardCacheNode:setVisible(true)
|
||||||
|
self.cacheSkillAniSeq = self.root:createBindTweenSequence()
|
||||||
|
for index, info in ipairs(skillInfo) do
|
||||||
|
local entity = self.root.skillAniGridEntities[index]
|
||||||
|
if entity then
|
||||||
|
entity:setSkilId(info.skillId)
|
||||||
|
local pos = ModuleManager.BattleManager:getPosInfo(info.posId)
|
||||||
|
local cell = entity:getCell()
|
||||||
|
if cell then
|
||||||
|
cell:refresh(entity)
|
||||||
|
local obj = cell:getBaseObject()
|
||||||
|
self.cacheSkillAniSeq:InsertCallback(0.5 * (index - 1), function()
|
||||||
|
obj:setAnchoredPosition(0, 656)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.cacheSkillAniSeq:Insert(0.5 * (index - 1) + 0.02, obj:getTransform():DOAnchorPos(pos, 0.5))
|
||||||
|
self.cacheSkillAniSeq:InsertCallback(0.5 * (index - 1) + 0.52, function()
|
||||||
|
if self.battleController then
|
||||||
|
self.battleController:setGridSkillId(info.posId, info.skillId)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.cacheSkillAniSeq:AppendCallback(function()
|
||||||
|
self.boardCacheNode:setVisible(false)
|
||||||
|
self:enableUITouch()
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
return BattleUI
|
return BattleUI
|
||||||
@ -56,6 +56,7 @@ function BattleData:refreshBoard(board)
|
|||||||
elementType = info[2]
|
elementType = info[2]
|
||||||
}
|
}
|
||||||
if self.gridEntities[data.posId] then
|
if self.gridEntities[data.posId] then
|
||||||
|
self.gridEntities[data.posId]:clear()
|
||||||
self.gridEntities[data.posId]:setGridType(data.gridType)
|
self.gridEntities[data.posId]:setGridType(data.gridType)
|
||||||
self.gridEntities[data.posId]:setElementType(data.elementType)
|
self.gridEntities[data.posId]:setElementType(data.elementType)
|
||||||
else
|
else
|
||||||
@ -67,6 +68,15 @@ function BattleData:refreshBoard(board)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleData:getNewGridEntity(posId, gridType, elementType)
|
||||||
|
local data = {
|
||||||
|
posId = posId or 0,
|
||||||
|
gridType = gridType or BattleConst.GRID_TYPE.EMPTY,
|
||||||
|
elementType = elementType or BattleConst.ELEMENT_TYPE.RED
|
||||||
|
}
|
||||||
|
return BATTLE_GRID_ENTITY:create(data)
|
||||||
|
end
|
||||||
|
|
||||||
function BattleData:clear()
|
function BattleData:clear()
|
||||||
self:clearGridSequence()
|
self:clearGridSequence()
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ local BattleGridEntity = class("BattleGridEntity", BaseData)
|
|||||||
local BattleConst = GConst.BattleConst
|
local BattleConst = GConst.BattleConst
|
||||||
|
|
||||||
function BattleGridEntity:ctor(data)
|
function BattleGridEntity:ctor(data)
|
||||||
|
self:clear()
|
||||||
self.posId = data.posId or 0
|
self.posId = data.posId or 0
|
||||||
self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY
|
self.gridType = data.gridType or BattleConst.GRID_TYPE.EMPTY
|
||||||
self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED
|
self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED
|
||||||
@ -12,6 +13,16 @@ function BattleGridEntity:ctor(data)
|
|||||||
self.data.isDirty = false
|
self.data.isDirty = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleGridEntity:clear()
|
||||||
|
self.gridType = BattleConst.GRID_TYPE.EMPTY
|
||||||
|
self.elementType = BattleConst.ELEMENT_TYPE.RED
|
||||||
|
self.aroundEliminationCount = 0 -- 周围消除次数
|
||||||
|
self.skillId = nil
|
||||||
|
self.linkSkillCount = 0 -- 任意链接技能激活次数
|
||||||
|
self.isIdle = false
|
||||||
|
self.data.isDirty = false
|
||||||
|
end
|
||||||
|
|
||||||
function BattleGridEntity:getSnapshoptInfo()
|
function BattleGridEntity:getSnapshoptInfo()
|
||||||
return {
|
return {
|
||||||
posId = self.posId,
|
posId = self.posId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user