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),
LINE_RENDERER = typeof(CS.UnityEngine.LineRenderer),
UI_RECT_MASK_2D = typeof(CS.UnityEngine.UI.RectMask2D),
-- spine组件
SKELETON_GRAPHIC = typeof(CS.Spine.Unity.SkeletonGraphic),
SKELETON_ANIMATION = typeof(CS.Spine.Unity.SkeletonAnimation),

View File

@ -36,7 +36,9 @@ function BattleController:onLinkChange()
local sequence = DataManager.BattleData:getGridSequence()
local elementTypeMap = {}
local posIdMap = {}
for _, info in ipairs(sequence) do
posIdMap[info.posId] = true
local entity = DataManager.BattleData:getGridEntity(info.posId)
if not entity:getSkillId() then
@ -49,6 +51,21 @@ function BattleController:onLinkChange()
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)
Logger.logHighlight("---------onLinkChange--------------")
Logger.printTable(elementTypeMap)
@ -82,7 +99,9 @@ function BattleController:onTouchEvent(eventType, posId)
DataManager.BattleData:clearGridSequence()
end
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:onLinkChange()
elseif eventType == ELIMINATION_TOUCH_EVENT.ENTER then
@ -96,10 +115,6 @@ function BattleController:onTouchEvent(eventType, posId)
if not outLineMap or not outLineMap[posId] then
return
end
local lastEntity = DataManager.BattleData:getGridEntity(lastPosId)
if lastEntity:getElementType() ~= entity:getElementType() then
return
end
if DataManager.BattleData:alreadyInsertSequence(posId) then
local info = sequence[#sequence - 1]
@ -117,13 +132,52 @@ function BattleController:onTouchEvent(eventType, posId)
end
end
end
self:findSkillInfluenceGrids()
self:onLinkChange()
return
end
else
DataManager.BattleData:insertGridSequence(posId, self:snapshotBoard())
self:findSkillInfluenceGrids()
self:onLinkChange()
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
else -- 取消和抬起
@ -146,11 +200,9 @@ function BattleController:onTouchEvent(eventType, posId)
return
end
local cellList = {}
local elementTypeMap = {}
for _, info in ipairs(sequence) do
local entity = DataManager.BattleData:getGridEntity(info.posId)
table.insert(cellList, entity:getCell())
if not entity:getSkillId() then
local elementType = entity:getElementType()
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
@ -160,7 +212,7 @@ function BattleController:onTouchEvent(eventType, posId)
DataManager.BattleData:addSkillEnergy(elementTypeMap)
self.battleUI:disableUITouch()
self.battleUI:eliminationAni(cellList, function()
self.battleUI:eliminationAni(sequence, function()
self:onEliminationAniOver()
end)
end
@ -186,25 +238,37 @@ function BattleController:onEliminationAniOver()
eliminationPosIds[info.posId] = true
end
local newIdleList = {}
local cellList = {}
local sequence = {}
for posId, status in pairs(boomGridIds) do
if not eliminationPosIds[posId] then
local entity = DataManager.BattleData:getGridEntity(posId)
if entity then
entity:addAroundEliminationCount()
if entity:getIsIdle() then
table.insert(newIdleList, entity)
table.insert(cellList, entity:getCell())
eliminationPosIds[posId] = true
table.insert(sequence, {posId = posId})
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()
if cellList[1] then
self.battleUI:eliminationAni(cellList, function()
local sequence = {}
if sequence[1] then
self.battleUI:eliminationAni(sequence, function()
self:fillBoard()
end)
return
@ -268,6 +332,8 @@ function BattleController:onFillBoardOver()
end
end
end
self.battleUI:refreshSkill()
end
---- 从一个点直接遍历所有相关的路径
@ -366,15 +432,21 @@ function BattleController:getRandomGridInfo()
return {gridType = gridType, elementType = elementType}
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()
for _, info in ipairs(sequence) do
local entity = DataManager.BattleData:getGridEntity(info.posId)
local skillId = entity:getSkillId()
if skillId then
local skillEntity = DataManager.BattleData:getSkillEntityByElement(entity:getElementType())
local skillEntity = DataManager.BattleData:getSkillEntityBySkillId(skillId)
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

View File

@ -10,7 +10,9 @@ local function _takeElimination(posId, skillEntity, gridEntities)
if boardrange then
local cludePosIdsMap = {}
for posId, entity in pairs(gridEntities) do
cludePosIdsMap[posId] = true
if entity:canChangeInfo() then
cludePosIdsMap[posId] = true
end
end
local ids = ModuleManager.BattleManager:getAroundPosIdsByList(posId, boardrange, cludePosIdsMap)
cludePosIdsMap = {}
@ -45,24 +47,20 @@ BattleBoardSkillHandle._activeBoardSkill = {
[SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround,
}
function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, isFinal)
function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities)
if not skillEntity then
return
end
if isFinal then
if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_FINAL then
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
if func then
func(posId, skillEntity, gridEntities)
end
if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_FINAL then
local func = BattleBoardSkillHandle._activeBoardSkill[skillEntity:getSkillType()]
if func then
func(posId, skillEntity, gridEntities)
end
else
if skillEntity:getMethond() == SKILL_METHOD_TYPE.ON_ENTER 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
end
end

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 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()
return "assets/prefabs/ui/battle/battle_ui.prefab"
@ -15,6 +22,7 @@ end
function BattleUI:_display()
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:initSkill()
end
@ -131,6 +139,10 @@ function BattleUI:showBoardMask(elementType)
if not self.gridCells then
return
end
if self.curElementType == elementType then
return
end
self.curElementType = elementType
local entities = DataManager.BattleData:getGridEnties()
for posId, entity in pairs(entities) do
@ -140,27 +152,62 @@ function BattleUI:showBoardMask(elementType)
end
end
function BattleUI:eliminationAni(cellList, callback)
if not cellList then
function BattleUI:eliminationAni(sequence, callback)
Logger.printTable(sequence)
if not sequence then
if callback then
callback()
end
return
end
for _, cell in ipairs(cellList) do
if cell then
cell:getBaseObject():setAnchoredPositionX(DEFAULT_X)
if self.eliminationAniSeq then
self.eliminationAniSeq:Kill()
self.eliminationAniSeq = nil
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
if callback then
self:performWithDelayGlobal(function()
callback()
end, 1)
end
self.eliminationAniSeq:AppendCallback(function()
self.posIdMap = {}
if self.boardMask2D then
self.boardMask2D.enabled = true
end
self:refreshSkill()
if callback then
callback()
end
self:refreshSkill()
end)
end
function BattleUI:fallGrid(listInfo, callback)

View File

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

View File

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

View File

@ -7,6 +7,7 @@ function BattleGridEntity:ctor(data)
self.elementType = data.elementType or BattleConst.ELEMENT_TYPE.RED
self.aroundEliminationCount = data.aroundEliminationCount or 0 -- 周围消除次数
self.skillId = data.skillId
self.linkSkillCount = data.linkSkillCount or 0 -- 任意链接技能激活次数
self.isIdle = false
self.data.isDirty = false
end
@ -19,6 +20,7 @@ function BattleGridEntity:getSnapshoptInfo()
aroundEliminationCount = self.aroundEliminationCount,
isIdle = self.isIdle,
skillId = self.skillId,
linkSkillCount = self.linkSkillCount,
}
end
@ -29,6 +31,7 @@ function BattleGridEntity:setInfoBySnapshop(snapshot)
self.aroundEliminationCount = snapshot.aroundEliminationCount or 0 -- 周围消除次数
self.isIdle = snapshot.isIdle
self.skillId = snapshot.skillId
self.linkSkillCount = snapshot.linkSkillCount
self:setDirty()
end
@ -48,7 +51,11 @@ function BattleGridEntity:getGridType()
return self.gridType
end
function BattleGridEntity:getElementType()
function BattleGridEntity:getElementType(skillEntity)
if skillEntity and skillEntity:getIgnoreElementType() and self.linkSkillCount <= 0 then
return nil
end
return self.elementType
end
@ -144,6 +151,7 @@ end
function BattleGridEntity:setSkilId(skillId)
self.skillId = skillId
self.linkSkillCount = 0
self:setDirty()
end
@ -154,4 +162,38 @@ function BattleGridEntity:canChangeInfo()
return false
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

View File

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