怪物丢棋盘技能的动画
This commit is contained in:
parent
1ced149768
commit
5a97438c08
@ -1038,7 +1038,7 @@ end
|
||||
function BattleUnitComp:onSkillTakeEffect(skill)
|
||||
skill:endUse()
|
||||
if skill:getIsEliminateType() then
|
||||
self.battleController:generateGridType(skill:getEliminateSkillParameter())
|
||||
self.battleController:generateGridType(skill:getEliminateSkillParameter(), self.baseObject:getTransform().position)
|
||||
end
|
||||
local effectList = skill:getEffectList()
|
||||
if effectList == nil then
|
||||
|
||||
@ -1249,7 +1249,7 @@ function BattleController:setGridSkillId(posId, skillId)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleController:generateGridType(skillTypeParameter)
|
||||
function BattleController:generateGridType(skillTypeParameter, monsterPos)
|
||||
if not skillTypeParameter then
|
||||
return
|
||||
end
|
||||
@ -1264,11 +1264,21 @@ function BattleController:generateGridType(skillTypeParameter)
|
||||
end
|
||||
list = table.shuffle(list)
|
||||
if count > 0 then
|
||||
local map = {}
|
||||
local minCount = math.min(skillTypeParameter[2], count)
|
||||
for i = minCount, 1, -1 do
|
||||
local entity = table.remove(list, math.random(1, i))
|
||||
self.battleData:setGridInfo(entity:getPosId(), {gridType = skillTypeParameter[1], elementType = entity:getElementType()})
|
||||
map[entity:getPosId()] = {
|
||||
gridType = skillTypeParameter[1],
|
||||
elementType = entity:getElementType()
|
||||
}
|
||||
end
|
||||
|
||||
self.battleUI:showMonsterSkillAni(map, monsterPos, function()
|
||||
for posId, info in pairs(map) do
|
||||
self.battleData:setGridInfo(posId, info)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -856,6 +856,74 @@ function BattleUI:hideGenerateSkillGridCells()
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:showMonsterSkillAni(map, monsterPos, callback)
|
||||
if table.nums(map) <= 0 then
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
self:hideMonsterSkillGridCells()
|
||||
if self.monsterSkillAniSeq then
|
||||
self.monsterSkillAniSeq:Kill()
|
||||
self.monsterSkillAniSeq = nil
|
||||
end
|
||||
|
||||
local sPoint = UIManager:getUICameraComponent():WorldToScreenPoint(monsterPos)
|
||||
monsterPos = CS.BF.Utils.RectTransformScreenPointToLocalPointInRectangle(self.boardNode:getTransform(), sPoint.x, sPoint.y, UIManager:getUICameraComponent())
|
||||
|
||||
self.monsterSkillAniSeq = self.root:createBindTweenSequence()
|
||||
local count = 1
|
||||
for posId, info in pairs(map) do
|
||||
local entity = self.monsterSkillGridEntities[count]
|
||||
if entity and entity:getCell() then
|
||||
entity:setGridType(info.gridType)
|
||||
entity:setElementType(GConst.BattleConst.ELEMENT_TYPE.EMPTY)
|
||||
count = count + 1
|
||||
local cell = entity:getCell()
|
||||
cell:refresh(entity)
|
||||
cell:getBaseObject():setAnchoredPosition(monsterPos.x, monsterPos.y)
|
||||
cell:getBaseObject():setLocalScale(0.3, 0.3, 0.3)
|
||||
local pos = ModuleManager.BattleManager:getPosInfo(posId)
|
||||
if count == 1 then
|
||||
self.monsterSkillAniSeq:Append(cell:getBaseObject():getTransform():DOAnchorPos(pos, 0.3))
|
||||
else
|
||||
self.monsterSkillAniSeq:Join(cell:getBaseObject():getTransform():DOAnchorPos(pos, 0.3))
|
||||
end
|
||||
self.monsterSkillAniSeq:Join(cell:getBaseObject():getTransform():DOScale(1, 0.3))
|
||||
end
|
||||
end
|
||||
self.monsterSkillAniSeq:AppendCallback(function()
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
self:hideMonsterSkillGridCells()
|
||||
end)
|
||||
end
|
||||
|
||||
function BattleUI:hideMonsterSkillGridCells()
|
||||
if not self.monsterSkillGridEntities then
|
||||
local uiMap = self.root:genAllChildren()
|
||||
self.monsterSkillGridEntities = {}
|
||||
for name, elementType in pairs(GConst.BattleConst.ELEMENT_TYPE) do
|
||||
local obj = uiMap["battle_ui.bg_2.ani_node.grid_cell_m" .. elementType]
|
||||
if obj then
|
||||
local cell = CellManager:addCellComp(obj, GRID_CELL)
|
||||
local entity = DataManager.BattleData:getNewGridEntity()
|
||||
entity:setCell(cell)
|
||||
self.monsterSkillGridEntities[elementType] = entity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, entity in pairs(self.monsterSkillGridEntities) do
|
||||
if entity:getCell() then
|
||||
entity:getCell():getBaseObject():setAnchoredPositionX(DEFAULT_X)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:initGenerateSkillEffect()
|
||||
if not self.generateSkillSfxs then
|
||||
local uiMap = self.root:genAllChildren()
|
||||
@ -1691,6 +1759,11 @@ function BattleUI:clear()
|
||||
self.cacheSkillAniSeq:Kill()
|
||||
self.cacheSkillAniSeq = nil
|
||||
end
|
||||
|
||||
if self.monsterSkillAniSeq then
|
||||
self.monsterSkillAniSeq:Kill()
|
||||
self.monsterSkillAniSeq = nil
|
||||
end
|
||||
end
|
||||
|
||||
return BattleUI
|
||||
Loading…
x
Reference in New Issue
Block a user