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

This commit is contained in:
chenxi 2023-04-10 21:54:54 +08:00
commit ed7bf4ace4
8 changed files with 240 additions and 50 deletions

View File

@ -103,6 +103,7 @@ GConst.TYPEOF_UNITY_CLASS = {
TEXT_ASSET = typeof(CS.UnityEngine.TextAsset), TEXT_ASSET = typeof(CS.UnityEngine.TextAsset),
LINE_RENDERER = typeof(CS.UnityEngine.LineRenderer), LINE_RENDERER = typeof(CS.UnityEngine.LineRenderer),
UI_RECT_MASK_2D = typeof(CS.UnityEngine.UI.RectMask2D),
-- spine组件 -- spine组件
SKELETON_GRAPHIC = typeof(CS.Spine.Unity.SkeletonGraphic), SKELETON_GRAPHIC = typeof(CS.Spine.Unity.SkeletonGraphic),
SKELETON_ANIMATION = typeof(CS.Spine.Unity.SkeletonAnimation), SKELETON_ANIMATION = typeof(CS.Spine.Unity.SkeletonAnimation),

View File

@ -36,7 +36,9 @@ function BattleController:onLinkChange()
local sequence = DataManager.BattleData:getGridSequence() local sequence = DataManager.BattleData:getGridSequence()
local elementTypeMap = {} local elementTypeMap = {}
local posIdMap = {}
for _, info in ipairs(sequence) do for _, info in ipairs(sequence) do
posIdMap[info.posId] = true
local entity = DataManager.BattleData:getGridEntity(info.posId) local entity = DataManager.BattleData:getGridEntity(info.posId)
if not entity:getSkillId() then if not entity:getSkillId() then
@ -49,6 +51,21 @@ function BattleController:onLinkChange()
end end
end end
for posId, _ in pairs(DataManager.BattleData:getSkillInfluenceGrids()) do
if not posIdMap[posId] then
posIdMap[posId] = true
local entity = DataManager.BattleData:getGridEntity(posId)
if not entity:getSkillId() then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
end
if entity:getCell() then
entity:getCell():showCircle(true)
end
end
end
self.battleUI:refreshSkill(elementTypeMap) self.battleUI:refreshSkill(elementTypeMap)
Logger.logHighlight("---------onLinkChange--------------") Logger.logHighlight("---------onLinkChange--------------")
Logger.printTable(elementTypeMap) Logger.printTable(elementTypeMap)
@ -82,7 +99,9 @@ function BattleController:onTouchEvent(eventType, posId)
DataManager.BattleData:clearGridSequence() DataManager.BattleData:clearGridSequence()
end end
DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard()) DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard())
self.battleUI:showBoardMask(entity:getElementType()) local skillEntity = DataManager.BattleData:getSkillEntityBySkillId(entity:getSkillId())
local maskElementType = entity:getElementType(skillEntity)
self.battleUI:showBoardMask(maskElementType)
self:findSkillInfluenceGrids() self:findSkillInfluenceGrids()
self:onLinkChange() self:onLinkChange()
elseif eventType == ELIMINATION_TOUCH_EVENT.ENTER then elseif eventType == ELIMINATION_TOUCH_EVENT.ENTER then
@ -96,10 +115,6 @@ function BattleController:onTouchEvent(eventType, posId)
if not outLineMap or not outLineMap[posId] then if not outLineMap or not outLineMap[posId] then
return return
end end
local lastEntity = DataManager.BattleData:getGridEntity(lastPosId)
if lastEntity:getElementType() ~= entity:getElementType() then
return
end
if DataManager.BattleData:alreadyInsertSequence(posId) then if DataManager.BattleData:alreadyInsertSequence(posId) then
local info = sequence[#sequence - 1] local info = sequence[#sequence - 1]
@ -117,13 +132,52 @@ function BattleController:onTouchEvent(eventType, posId)
end end
end end
end end
self:onLinkChange()
end
else
DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard())
self:findSkillInfluenceGrids() self:findSkillInfluenceGrids()
self:onLinkChange() self:onLinkChange()
return
end end
end
local skillId = entity:getSkillId()
local skillEntity = DataManager.BattleData:getSkillEntityBySkillId(skillId)
local elementType = entity:getElementType(skillEntity)
local lastEntity = DataManager.BattleData:getGridEntity(lastPosId)
local lastSkillId = lastEntity:getSkillId()
local lastSkillEntity = DataManager.BattleData:getSkillEntityBySkillId(lastSkillId)
local lastElementType = lastEntity:getElementType(lastSkillEntity)
if not elementType or not lastElementType then
else
if lastElementType ~= elementType then
return
end
end
local maskElementType = elementType or lastElementType
self.battleUI:showBoardMask(maskElementType)
DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard())
if lastEntity:getNeedChangePos() and not entity:getNeedChangePos() then -- 需要移动到队列末尾
local lastSkillId = lastEntity:getSkillId()
local skillId = entity:getSkillId()
lastEntity:setSkilId(skillId)
entity:setSkilId(lastSkillId)
end
if not lastElementType and elementType then
lastEntity:addLinkSkillCount()
entity:addLinkSkillCount()
elseif not lastElementType and not elementType then
lastEntity:addLinkSkillCount()
elseif lastElementType and not elementType then
entity:addLinkSkillCount()
else
entity:setLinkSkillCount(lastEntity:getLinkSkillCount())
end
self:findSkillInfluenceGrids()
self:onLinkChange()
elseif eventType == ELIMINATION_TOUCH_EVENT.EXIT then elseif eventType == ELIMINATION_TOUCH_EVENT.EXIT then
else -- 取消和抬起 else -- 取消和抬起
@ -146,11 +200,9 @@ function BattleController:onTouchEvent(eventType, posId)
return return
end end
local cellList = {}
local elementTypeMap = {} local elementTypeMap = {}
for _, info in ipairs(sequence) do for _, info in ipairs(sequence) do
local entity = DataManager.BattleData:getGridEntity(info.posId) local entity = DataManager.BattleData:getGridEntity(info.posId)
table.insert(cellList, entity:getCell())
if not entity:getSkillId() then if not entity:getSkillId() then
local elementType = entity:getElementType() local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1 elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
@ -160,7 +212,7 @@ function BattleController:onTouchEvent(eventType, posId)
DataManager.BattleData:addSkillEnergy(elementTypeMap) DataManager.BattleData:addSkillEnergy(elementTypeMap)
self.battleUI:disableUITouch() self.battleUI:disableUITouch()
self.battleUI:eliminationAni(cellList, function() self.battleUI:eliminationAni(sequence, function()
self:onEliminationAniOver() self:onEliminationAniOver()
end) end)
end end
@ -186,25 +238,37 @@ function BattleController:onEliminationAniOver()
eliminationPosIds[info.posId] = true eliminationPosIds[info.posId] = true
end end
local newIdleList = {} local sequence = {}
local cellList = {}
for posId, status in pairs(boomGridIds) do for posId, status in pairs(boomGridIds) do
if not eliminationPosIds[posId] then if not eliminationPosIds[posId] then
local entity = DataManager.BattleData:getGridEntity(posId) local entity = DataManager.BattleData:getGridEntity(posId)
if entity then if entity then
entity:addAroundEliminationCount() entity:addAroundEliminationCount()
if entity:getIsIdle() then if entity:getIsIdle() then
table.insert(newIdleList, entity) eliminationPosIds[posId] = true
table.insert(cellList, entity:getCell()) table.insert(sequence, {posId = posId})
end end
end end
end end
end end
for posId, _ in pairs(DataManager.BattleData:getSkillInfluenceGrids()) do
local entity = DataManager.BattleData:getGridEntity(posId)
if not entity:getIsIdle() then
entity:setIsIdle(true)
if not eliminationPosIds[posId] then
eliminationPosIds[posId] = true
table.insert(sequence, {posId = posId})
end
end
end
DataManager.BattleData:clearGridSequence() DataManager.BattleData:clearGridSequence()
if cellList[1] then local sequence = {}
self.battleUI:eliminationAni(cellList, function()
if sequence[1] then
self.battleUI:eliminationAni(sequence, function()
self:fillBoard() self:fillBoard()
end) end)
return return
@ -268,6 +332,8 @@ function BattleController:onFillBoardOver()
end end
end end
end end
self.battleUI:refreshSkill()
end end
---- 从一个点直接遍历所有相关的路径 ---- 从一个点直接遍历所有相关的路径
@ -366,15 +432,21 @@ function BattleController:getRandomGridInfo()
return {gridType = gridType, elementType = elementType} return {gridType = gridType, elementType = elementType}
end end
function BattleController:findSkillInfluenceGrids(isFinal) function BattleController:findSkillInfluenceGrids()
local girds = DataManager.BattleData:clearSkillInfluenceGrids()
for posId, _ in pairs(girds) do
local entity = DataManager.BattleData:getGridEntity(posId)
entity:setNeedElimination(false)
end
local sequence = DataManager.BattleData:getGridSequence() local sequence = DataManager.BattleData:getGridSequence()
for _, info in ipairs(sequence) do for _, info in ipairs(sequence) do
local entity = DataManager.BattleData:getGridEntity(info.posId) local entity = DataManager.BattleData:getGridEntity(info.posId)
local skillId = entity:getSkillId() local skillId = entity:getSkillId()
if skillId then if skillId then
local skillEntity = DataManager.BattleData:getSkillEntityByElement(entity:getElementType()) local skillEntity = DataManager.BattleData:getSkillEntityBySkillId(skillId)
if skillEntity then if skillEntity then
BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, DataManager.BattleData:getGridEnties(), isFinal) BATTLE_BOARD_SKILL_HANDLE.activeBoardSkill(info.posId, skillEntity, DataManager.BattleData:getGridEnties())
end end
end end
end end

View File

@ -10,8 +10,10 @@ local function _takeElimination(posId, skillEntity, gridEntities)
if boardrange then if boardrange then
local cludePosIdsMap = {} local cludePosIdsMap = {}
for posId, entity in pairs(gridEntities) do for posId, entity in pairs(gridEntities) do
if entity:canChangeInfo() then
cludePosIdsMap[posId] = true cludePosIdsMap[posId] = true
end end
end
local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap) local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap)
cludePosIdsMap = {} cludePosIdsMap = {}
for _, posId in ipairs(ids) do for _, posId in ipairs(ids) do
@ -45,26 +47,22 @@ BattleBoardSkillHandle._activeBoardSkill = {
[SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround, [SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround,
} }
function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, isFinal) function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities)
if not skillEntity then if not skillEntity then
return return
end end
if isFinal then
if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_FINAL then if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_FINAL then
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()] local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
if func then if func then
func(posId, skillEntity, gridEntities) func(posId, skillEntity, gridEntities)
end end
end elseif skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_ENTER then
else
if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_ENTER then
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()] local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
if func then if func then
func(posId, skillEntity, gridEntities) func(posId, skillEntity, gridEntities)
end end
end end
end
end end
return BattleBoardSkillHandle return BattleBoardSkillHandle

View File

@ -3,6 +3,13 @@ local GRID_CELL = "app/ui/battle/cell/grid_cell"
local GRID_CELL_PATH = "assets/prefabs/ui/battle/cell/grid_cell.prefab" local GRID_CELL_PATH = "assets/prefabs/ui/battle/cell/grid_cell.prefab"
local DEFAULT_X = 10000 local DEFAULT_X = 10000
local SKILL_POS = {
[GConst.BattleConst.ELEMENT_TYPE.RED] = BF.Vector2(-183, 454),
[GConst.BattleConst.ELEMENT_TYPE.YELLOW] = BF.Vector2(-81.61, 454),
[GConst.BattleConst.ELEMENT_TYPE.GREEN] = BF.Vector2(17.1, 454),
[GConst.BattleConst.ELEMENT_TYPE.BLUE] = BF.Vector2(124.7, 454),
[GConst.BattleConst.ELEMENT_TYPE.PURPLE] = BF.Vector2(229.4, 454),
}
function BattleUI:getPrefabPath() function BattleUI:getPrefabPath()
return "assets/prefabs/ui/battle/battle_ui.prefab" return "assets/prefabs/ui/battle/battle_ui.prefab"
@ -15,6 +22,7 @@ end
function BattleUI:_display() function BattleUI:_display()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
self:initGridCell() self:initGridCell()
self:initSkill() self:initSkill()
end end
@ -131,6 +139,10 @@ function BattleUI:showBoardMask(elementType)
if not self.gridCells then if not self.gridCells then
return return
end end
if self.curElementType == elementType then
return
end
self.curElementType = elementType self.curElementType = elementType
local entities = DataManager.BattleData:getGridEnties() local entities = DataManager.BattleData:getGridEnties()
for posId, entity in pairs(entities) do for posId, entity in pairs(entities) do
@ -140,27 +152,62 @@ function BattleUI:showBoardMask(elementType)
end end
end end
function BattleUI:eliminationAni(cellList, callback) function BattleUI:eliminationAni(sequence, callback)
if not cellList then Logger.printTable(sequence)
if not sequence then
if callback then if callback then
callback() callback()
end end
return return
end end
for _, cell in ipairs(cellList) do if self.eliminationAniSeq then
if cell then self.eliminationAniSeq:Kill()
cell:getBaseObject():setAnchoredPositionX(DEFAULT_X) self.eliminationAniSeq = nil
end end
self.eliminationAniSeq = self.root:createBindTweenSequence()
self.eliminationAniSeq:AppendCallback(function()
if self.boardMask2D then
self.boardMask2D.enabled = false
end
end)
if not self.posIdMap then
self.posIdMap = {}
end
for index, info in ipairs(sequence) do
if not self.posIdMap[info.posId] then
self.posIdMap[info.posId] = true
local entity = DataManager.BattleData:getGridEntity(info.posId)
if entity and entity:getCell() then
local baseObject = entity:getCell():getBaseObject()
baseObject:getTransform():SetAsLastSibling()
if entity:getSkillId() then
baseObject:setAnchoredPositionX(DEFAULT_X)
else
self.eliminationAniSeq:Insert(index * 0.01, baseObject:getTransform():DOScale(1.3, 0.1))
self.eliminationAniSeq:Insert(index * 0.01 + 0.2, baseObject:getTransform():DOAnchorPos(SKILL_POS[entity:getElementType()], 0.3))
self.eliminationAniSeq:Insert(index * 0.01 + 0.2, baseObject:getTransform():DOScale(1, 0.3))
end
end
end
end
self.eliminationAniSeq:AppendCallback(function()
self.posIdMap = {}
if self.boardMask2D then
self.boardMask2D.enabled = true
end end
if callback then if callback then
self:performWithDelayGlobal(function()
callback() callback()
end, 1)
end end
self:refreshSkill() self:refreshSkill()
end)
end end
function BattleUI:fallGrid(listInfo, callback) function BattleUI:fallGrid(listInfo, callback)

View File

@ -47,7 +47,7 @@ function GridCell:refresh(gridEntity, curElement)
skillIcon:setVisible(false) skillIcon:setVisible(false)
end end
self:showCircle(false) self:showCircle(gridEntity:getNeedElimination())
self:showHighLight(false) self:showHighLight(false)
--- 测试代码 --- 测试代码
uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount()) uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount())
@ -60,7 +60,7 @@ end
function GridCell:showCircle(show) function GridCell:showCircle(show)
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
uiMap["grid_cell.touch_node.ani_node.circle"]:setVisible(show) uiMap["grid_cell.touch_node.ani_node.circle"]:setVisible(show == true)
end end
function GridCell:showHighLight(show) function GridCell:showHighLight(show)
@ -71,4 +71,8 @@ function GridCell:showHighLight(show)
skillHighLightIcon:setVisible(show) skillHighLightIcon:setVisible(show)
end end
function GridCell:resetTranform()
end
return GridCell return GridCell

View File

@ -107,10 +107,16 @@ function BattleData:getSkillInfluenceGrids()
return self.skillInfluenceGrids or {} return self.skillInfluenceGrids or {}
end end
function BattleData:clearSkillInfluenceGrids()
local grids = self:getSkillInfluenceGrids()
self.skillInfluenceGrids = {} -- 技能影响的格子
return grids
end
function BattleData:clearGridSequence() function BattleData:clearGridSequence()
self.gridSequence = {} -- 格子队列 self.gridSequence = {} -- 格子队列
self.gridSequenceMap = {} -- 格子队列对应的map方面查找 self.gridSequenceMap = {} -- 格子队列对应的map方面查找
self.skillInfluenceGrids = {} -- 技能影响的格子 self:clearSkillInfluenceGrids()
end end
function BattleData:getGridEnties() function BattleData:getGridEnties()
@ -209,6 +215,18 @@ function BattleData:getSkillEntityByElement(elementType)
return self.skillMap[elementType] return self.skillMap[elementType]
end end
function BattleData:getSkillEntityBySkillId(skillId)
if not self.skillMap or not skillId then
return
end
local cfg = SKILL_HERO_CFG[skillId]
if not cfg then
return
end
return self.skillMap[cfg.position]
end
function BattleData:addSkillEnergy(elementMap) function BattleData:addSkillEnergy(elementMap)
if not self.skillMap then if not self.skillMap then
return return

View File

@ -7,6 +7,7 @@ function BattleGridEntity:ctor(data)
self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED
self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数 self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数
self.skillId = data.skillId self.skillId = data.skillId
self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数
self.isIdle = false self.isIdle = false
self.data.isDirty = false self.data.isDirty = false
end end
@ -19,6 +20,7 @@ function BattleGridEntity:getSnapshoptInfo()
aroundEliminationCount = self.aroundEliminationCount, aroundEliminationCount = self.aroundEliminationCount,
isIdle = self.isIdle, isIdle = self.isIdle,
skillId = self.skillId, skillId = self.skillId,
linkSkillCount = self.linkSkillCount,
} }
end end
@ -29,6 +31,7 @@ function BattleGridEntity:setInfoBySnapshop(snapshot)
self.aroundEliminationCount = snapshot.aroundEliminationCount or 0 -- 周围消除次数 self.aroundEliminationCount = snapshot.aroundEliminationCount or 0 -- 周围消除次数
self.isIdle = snapshot.isIdle self.isIdle = snapshot.isIdle
self.skillId = snapshot.skillId self.skillId = snapshot.skillId
self.linkSkillCount = snapshot.linkSkillCount
self:setDirty() self:setDirty()
end end
@ -48,7 +51,11 @@ function BattleGridEntity:getGridType()
return self.gridType return self.gridType
end end
function BattleGridEntity:getElementType() function BattleGridEntity:getElementType(skillEntity)
if skillEntity and skillEntity:getIgnoreElementType() and self.linkSkillCount <= 0 then
return nil
end
return self.elementType return self.elementType
end end
@ -144,6 +151,7 @@ end
function BattleGridEntity:setSkilId(skillId) function BattleGridEntity:setSkilId(skillId)
self.skillId = skillId self.skillId = skillId
self.linkSkillCount = 0
self:setDirty() self:setDirty()
end end
@ -154,4 +162,38 @@ function BattleGridEntity:canChangeInfo()
return false return false
end end
function BattleGridEntity:setNeedElimination(need)
self.needElimination = need
self:setDirty()
end
function BattleGridEntity:getNeedElimination()
return self.needElimination
end
function BattleGridEntity:getNeedChangePos()
if not self:getSkillId() then
return false
end
local cfg = ModuleManager.BattleManager.SKILL_HERO_CFG[self:getSkillId()]
if cfg and cfg.method == BattleConst.SKILL_METHOD_TYPE.ON_FINAL then
return true
end
return false
end
function BattleGridEntity:addLinkSkillCount(count)
self.linkSkillCount = self.linkSkillCount + (count or 1)
end
function BattleGridEntity:setLinkSkillCount(count)
self.linkSkillCount = count or 0
end
function BattleGridEntity:getLinkSkillCount()
return self.linkSkillCount
end
return BattleGridEntity return BattleGridEntity

View File

@ -111,4 +111,12 @@ function BattleBoardSkillEnity:clearEnergy()
self.curEnergy = 0 self.curEnergy = 0
end end
function BattleBoardSkillEnity:getIgnoreElementType()
return self.ignoreElementType
end
function BattleBoardSkillEnity:setIgnoreElementType(ignore)
self.ignoreElementType = ignore
end
return BattleBoardSkillEnity return BattleBoardSkillEnity