diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 30a2d54a..11ae2725 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -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 diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index aac66dab..5e8a3b55 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -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 diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index b24055b4..61dd26cf 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -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 \ No newline at end of file