feat(英雄合并): 添加合并时的爆炸特效
在英雄合并完成后播放视觉特效,提升合并操作的反馈和表现力。使用预制体资源并确保在正确的层级上显示。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, v3, Vec3 } from "cc";
|
||||
import { _decorator, instantiate, Prefab, v3, Vec3 } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
@@ -9,6 +9,7 @@ import { HeroPos } from "../common/config/heroSet";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { FacSet } from "../common/config/GameSet";
|
||||
import { oneCom } from "../skill/oncend";
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -77,6 +78,7 @@ export class MissionHeroCompComp extends CCComp {
|
||||
const landingPos:Vec3 = HeroPos[hero_pos].pos;
|
||||
const spawnPos:Vec3 = v3(landingPos.x, landingPos.y + MissionHeroCompComp.HERO_DROP_HEIGHT, 0);
|
||||
await this.mergeDestroyAtBirth(mergeHeroes, spawnPos);
|
||||
await this.playMergeBoomFx(spawnPos);
|
||||
this.addMergedHero(uuid, hero_lv + 1, sumAp, sumHpMax);
|
||||
} finally {
|
||||
this.is_merging = false;
|
||||
@@ -152,6 +154,31 @@ export class MissionHeroCompComp extends CCComp {
|
||||
});
|
||||
}
|
||||
|
||||
private playMergeBoomFx(worldPos: Vec3): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
const scene = smc.map?.MapView?.scene;
|
||||
const layer = scene?.entityLayer?.node;
|
||||
if (!layer || !layer.isValid) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
const prefab: Prefab = oops.res.get("game/skill/end/dead", Prefab)!;
|
||||
if (!prefab) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
const fx = instantiate(prefab);
|
||||
if (!fx || !fx.isValid) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
fx.parent = layer;
|
||||
fx.setPosition(worldPos);
|
||||
fx.getComponent(oneCom) || fx.addComponent(oneCom);
|
||||
this.scheduleOnce(() => resolve(), 0.4);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user