特效
This commit is contained in:
parent
3c896cf339
commit
c874c9026b
@ -514,4 +514,20 @@ BattleConst.INSTRUCTION_NAME = {
|
||||
PLAY_SKILL = "play_skill",
|
||||
}
|
||||
|
||||
BattleConst.OUTLINE_SFX = {
|
||||
[BattleConst.ELEMENT_TYPE.RED] = "sfx_piece_qizi_b03",
|
||||
[BattleConst.ELEMENT_TYPE.YELLOW] = "sfx_piece_qizi_b02",
|
||||
[BattleConst.ELEMENT_TYPE.GREEN] = "sfx_piece_qizi_b04",
|
||||
[BattleConst.ELEMENT_TYPE.BLUE] = "sfx_piece_qizi_b05",
|
||||
[BattleConst.ELEMENT_TYPE.PURPLE] = "sfx_piece_qizi_b01"
|
||||
}
|
||||
|
||||
BattleConst.LINE_SFX = "assets/prefabs/effects/battle/sfx_piece_line_b01.prefab"
|
||||
BattleConst.GRID_TYPE_BREAK_SFX = {
|
||||
[BattleConst.GRID_TYPE.SNOW_BOX] = "assets/prefabs/effects/battle/sfx_piece_za_b01.prefab",
|
||||
[BattleConst.GRID_TYPE.SOLID_SNOW] = "assets/prefabs/effects/battle/sfx_piece_za_b01.prefab",
|
||||
[BattleConst.GRID_TYPE.VINES] = "assets/prefabs/effects/battle/sfx_piece_za_b03.prefab",
|
||||
[BattleConst.GRID_TYPE.ICE] = "assets/prefabs/effects/battle/sfx_piece_za_b02.prefab",
|
||||
}
|
||||
|
||||
return BattleConst
|
||||
@ -266,6 +266,15 @@ function BattleManager:getBuffElementType(buffName)
|
||||
return cfg and cfg.position
|
||||
end
|
||||
|
||||
function BattleManager:getPosCenterAndDir(pos1, pos2)
|
||||
local centerPos = {x = 0, y = 0}
|
||||
centerPos.x = (pos1.x + pos2.x) / 2
|
||||
centerPos.y = (pos1.y + pos2.y) / 2
|
||||
|
||||
local zEuler = - math.deg(math.atan(pos2.x - pos1.x, pos2.y - pos1.y)) + 90
|
||||
return centerPos, zEuler
|
||||
end
|
||||
|
||||
----------------------- end 一些公共相关的方法 -----------------------------
|
||||
|
||||
function BattleManager:bindBattleUnitAttribute(hashCode, side)
|
||||
|
||||
@ -75,9 +75,11 @@ function BattleController:tick(dt)
|
||||
end
|
||||
|
||||
function BattleController:onLinkChange()
|
||||
self.battleUI:hideAllSfxLine()
|
||||
local needFalsePosMap = {}
|
||||
for posId, entity in pairs(self.battleData:getGridEnties()) do
|
||||
if entity:getCell() then
|
||||
entity:getCell():showHighLight(false)
|
||||
needFalsePosMap[posId] = entity:getCell()
|
||||
end
|
||||
end
|
||||
|
||||
@ -85,6 +87,7 @@ function BattleController:onLinkChange()
|
||||
local elementTypeMap = {}
|
||||
local posIdMap = {}
|
||||
local mainElementType
|
||||
local count = 0
|
||||
for _, info in ipairs(sequence) do
|
||||
posIdMap[info.posId] = true
|
||||
local entity = self.battleData:getGridEntity(info.posId)
|
||||
@ -94,13 +97,32 @@ function BattleController:onLinkChange()
|
||||
elementTypeMap[elementType] = (elementTypeMap[elementType] or 0) + 1
|
||||
mainElementType = elementType
|
||||
end
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
for _, info in ipairs(sequence) do
|
||||
for index, info in ipairs(sequence) do
|
||||
local entity = self.battleData:getGridEntity(info.posId)
|
||||
if entity:getCell() then
|
||||
entity:getCell():showHighLight(true, mainElementType)
|
||||
entity:getCell():showHighLight(true, mainElementType, self.battleUI)
|
||||
end
|
||||
if needFalsePosMap[info.posId] then
|
||||
needFalsePosMap[info.posId] = nil
|
||||
end
|
||||
if index < count then
|
||||
local nextPosId = sequence[index + 1].posId
|
||||
self.battleUI:getSfxLine(index, function(obj)
|
||||
local curPos = ModuleManager.BattleManager:getPosInfo(info.posId)
|
||||
local nextPos = ModuleManager.BattleManager:getPosInfo(nextPosId)
|
||||
local pos, z = ModuleManager.BattleManager:getPosCenterAndDir(curPos, nextPos)
|
||||
obj:setLocalScale(25, 25, 25)
|
||||
obj:setLocalPosition(pos.x, pos.y, 0)
|
||||
obj:setEulerAngles(0, 0, z)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
for posId, cell in pairs(needFalsePosMap) do
|
||||
cell:showHighLight(false)
|
||||
end
|
||||
|
||||
for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do
|
||||
@ -604,6 +626,7 @@ function BattleController:onTouchEvent(eventType, posId)
|
||||
end
|
||||
|
||||
function BattleController:onLinkOver()
|
||||
self.battleUI:hideAllSfxLine()
|
||||
local sequence = self.battleData:getGridSequence()
|
||||
local count = #sequence
|
||||
if count < self:getMinEliminationCount() then
|
||||
|
||||
@ -27,8 +27,9 @@ end
|
||||
function BattleUI:_display()
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.uiMap = uiMap
|
||||
self.gridNode = uiMap["battle_ui.bg_2.board_node.grid_node"]
|
||||
self.boardNode = uiMap["battle_ui.bg_2.board_node"]
|
||||
self.boardMask2D = self.boardNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
||||
self.boardMask2D = self.gridNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
|
||||
self.boardMask = uiMap["battle_ui.bg_2.board_mask"]
|
||||
self.boardMask:setVisible(false)
|
||||
self.boardCacheNode = uiMap["battle_ui.bg_2.board_cache_node"]
|
||||
@ -511,14 +512,11 @@ function BattleUI:initGridCell()
|
||||
return
|
||||
end
|
||||
|
||||
local uiMap = self.root:genAllChildren()
|
||||
local parent = uiMap["battle_ui.bg_2.board_node"]
|
||||
|
||||
self.gridCells = {}
|
||||
self.cellLoadRemianCount = GConst.BattleConst.ROW_COUNT * GConst.BattleConst.COLUMN_COUNT
|
||||
for r = 1, GConst.BattleConst.ROW_COUNT do
|
||||
for c = 1, GConst.BattleConst.COLUMN_COUNT do
|
||||
CellManager:loadCellAsync(GRID_CELL_PATH, GRID_CELL, parent, function(cell)
|
||||
CellManager:loadCellAsync(GRID_CELL_PATH, GRID_CELL, self.gridNode, function(cell)
|
||||
local posId = ModuleManager.BattleManager:getPosId(r, c)
|
||||
self.gridCells[posId] = cell
|
||||
local gameObject = cell:getGameObject()
|
||||
@ -540,6 +538,7 @@ function BattleUI:onInitGridCellOver()
|
||||
for posId, cell in pairs(self.gridCells) do
|
||||
local entity = DataManager.BattleData:getGridEntity(posId)
|
||||
if entity then
|
||||
cell:setOrder(self:getUIOrder())
|
||||
cell:refresh(entity)
|
||||
cell:addTouchListener(function(eventType)
|
||||
if self.battleController then
|
||||
@ -954,6 +953,47 @@ function BattleUI:refreshWave(wave)
|
||||
GFunc.centerImgAndTx(icon, desc, 10)
|
||||
end
|
||||
|
||||
function BattleUI:getSfxLine(index, func)
|
||||
self.hidingAllSfxLine = true
|
||||
|
||||
if not self.root.lineSfxObjs then
|
||||
self.root.lineSfxObjs = {}
|
||||
end
|
||||
if self.root.lineSfxObjs[index] then
|
||||
if self.root.lineSfxObjs[index].obj and func then
|
||||
local obj = self.root.lineSfxObjs[index].obj
|
||||
obj:setActive(true)
|
||||
func(obj)
|
||||
end
|
||||
else
|
||||
self.root.lineSfxObjs[index] = {
|
||||
isLoaded = true
|
||||
}
|
||||
EffectManager:loadUIEffectAsync(GConst.BattleConst.LINE_SFX, self, self.gridNode, 11, function(obj)
|
||||
self.root.lineSfxObjs[index].obj = obj
|
||||
if not self.hidingAllSfxLine then
|
||||
obj:setActive(false)
|
||||
else
|
||||
if func then
|
||||
func(obj)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:hideAllSfxLine()
|
||||
self.hidingAllSfxLine = false
|
||||
if not self.root.lineSfxObjs then
|
||||
return
|
||||
end
|
||||
for inde, info in pairs(self.root.lineSfxObjs) do
|
||||
if info.obj then
|
||||
info.obj:setActive(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:clear()
|
||||
if self.alreadyClear then
|
||||
return
|
||||
|
||||
@ -60,7 +60,10 @@ function GridCell:refresh(gridEntity, curElement)
|
||||
|
||||
uiMap["grid_cell.touch_node.ani_node.mask"]:setVisible(showMask)
|
||||
self:showCircle(gridEntity:getNeedElimination())
|
||||
self:showHighLight(false)
|
||||
if self.gridEntity:getIsIdle() then
|
||||
self.lastShowHlElementType = nil
|
||||
end
|
||||
self:showHighLight(self.lastShowHlElementType ~= nil, self.lastShowHlElementType)
|
||||
--- 测试代码
|
||||
-- uiMap["grid_cell.touch_node.ani_node.count"]:setText(gridEntity:getAroundEliminationCount())
|
||||
end
|
||||
@ -75,7 +78,7 @@ function GridCell:showCircle(show)
|
||||
uiMap["grid_cell.touch_node.ani_node.circle"]:setVisible(show == true)
|
||||
end
|
||||
|
||||
function GridCell:showHighLight(show, mainElementType)
|
||||
function GridCell:showHighLight(show, mainElementType, parentUI)
|
||||
if not self.gridEntity then
|
||||
return
|
||||
end
|
||||
@ -102,12 +105,36 @@ function GridCell:showHighLight(show, mainElementType)
|
||||
end
|
||||
|
||||
|
||||
local elementType = mainElementType or self.gridEntity:getElementType()
|
||||
--- 测试代码
|
||||
local str = GConst.EMPTY_STRING
|
||||
if show then
|
||||
str = self.gridEntity:getAroundEliminationCount()
|
||||
end
|
||||
uiMap["grid_cell.touch_node.ani_node.count"]:setText(str)
|
||||
|
||||
if not self.outLineSfxObjs then
|
||||
self.outLineSfxObjs = {}
|
||||
for elementType, name in pairs(GConst.BattleConst.OUTLINE_SFX) do
|
||||
self.outLineSfxObjs[elementType] = uiMap["grid_cell.touch_node.ani_node.effect_node." .. name]
|
||||
end
|
||||
end
|
||||
|
||||
local find = false
|
||||
for type, obj in pairs(self.outLineSfxObjs) do
|
||||
if show and type == elementType then
|
||||
find = true
|
||||
if self.lastShowHlElementType ~= elementType then
|
||||
self.lastShowHlElementType = elementType
|
||||
obj:setActive(true)
|
||||
end
|
||||
else
|
||||
obj:setActive(false)
|
||||
end
|
||||
end
|
||||
if not find then
|
||||
self.lastShowHlElementType = nil
|
||||
end
|
||||
end
|
||||
|
||||
function GridCell:resetTranform()
|
||||
@ -124,4 +151,13 @@ function GridCell:hideAni()
|
||||
GFunc.getShakeSeq(uiMap["grid_cell.touch_node.ani_node"], true)
|
||||
end
|
||||
|
||||
function GridCell:setOrder(uiOder)
|
||||
local uiMap = self:getUIMap()
|
||||
for i = 1, 5 do
|
||||
local obj = uiMap["grid_cell.touch_node.ani_node.effect_node.sfx_piece_qizi_b0" .. i]
|
||||
obj:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(uiOder, GConst.UI_EFFECT_ORDER.LEVEL1)
|
||||
end
|
||||
-- uiMap["grid_cell.touch_node.ani_node.effect_node.sfx_piece_line_b01"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_EFFECT_HELPER):SetSortingOrder(uiOder, GConst.UI_EFFECT_ORDER.LEVEL1)
|
||||
end
|
||||
|
||||
return GridCell
|
||||
Loading…
x
Reference in New Issue
Block a user