refactor(skill): 优化特效生命周期管理并添加新动画
- 移除 timedCom 组件中未使用的 cd 和 ap 属性 - 重命名 dead 组件为 oneCom 并重构动画结束销毁逻辑,避免内存泄漏 - 为部分技能添加准备动画(readyAnm)配置 - 新增 uplv 升级动画特效预制体 - 统一特效生成接口,支持基于动画结束或定时销毁两种模式 - 清理 HeroViewComp 中未使用的导入和方法
This commit is contained in:
@@ -7,14 +7,12 @@ import { BoxSet, FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { EAnmConf, SkillSet,} from "../common/config/SkillSet";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { TooltipTypes } from "../common/config/GameSet";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { Tooltip } from "../skill/Tooltip";
|
||||
import { timedCom } from "../skill/timedCom";
|
||||
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
import { oneCom } from "../skill/oncend";
|
||||
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -245,19 +243,12 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
/** 升级特效 */
|
||||
private lv_up() {
|
||||
this.spawnEffect("game/skill/buff/buff_lvup", this.node, 1.0);
|
||||
this.spawnTimedFx("game/skill/buff/buff_lvup", this.node, 1.0);
|
||||
}
|
||||
|
||||
/** 攻击力提升特效 */
|
||||
private ap_up() {
|
||||
this.spawnEffect("game/skill/buff/buff_apup", this.node, 1.0);
|
||||
}
|
||||
|
||||
/** 显示 Buff 特效 */
|
||||
private show_do_buff(name: string) {
|
||||
var path = "game/skill/buff/" + name;
|
||||
let pos = v3(this.node.position.x, this.node.position.y + 20, this.node.position.z);
|
||||
this.spawnEffect(path, this.node.parent, 1.0, pos);
|
||||
this.spawnTimedFx("game/skill/buff/buff_apup", this.node, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,22 +265,16 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
/** 冰冻特效 */
|
||||
private in_iced(t: number = 1, ap: number = 0) {
|
||||
const node = this.spawnEffect("game/skill/buff/buff_iced", this.node, t);
|
||||
if (!node) return;
|
||||
const timer = node.getComponent(timedCom) || node.addComponent(timedCom);
|
||||
timer.time = t;
|
||||
timer.ap = ap;
|
||||
const node = this.spawnTimedFx("game/skill/buff/iced", this.node, t);
|
||||
|
||||
}
|
||||
|
||||
/** 眩晕特效 */
|
||||
private in_yun(t: number = 1, ap: number = 0) {
|
||||
const node = this.spawnEffect("game/skill/buff/buff_yun", this.node, t);
|
||||
const node = this.spawnTimedFx("game/skill/buff/buff_yun", this.node, t);
|
||||
if (!node) return;
|
||||
let height = this.node.getComponent(UITransform).height;
|
||||
node.setPosition(v3(0, height));
|
||||
const timer = node.getComponent(timedCom) || node.addComponent(timedCom);
|
||||
timer.time = t;
|
||||
timer.ap = ap;
|
||||
}
|
||||
|
||||
/** 技能提示 */
|
||||
@@ -322,29 +307,29 @@ export class HeroViewComp extends CCComp {
|
||||
public palayBuff(anm: string = ""){
|
||||
if(anm==="") return;
|
||||
var path = "game/skill/buff/" + anm;
|
||||
this.spawnEffect(path, this.node, this.effectLifeTime);
|
||||
this.spawnTimedFx(path, this.node, this.effectLifeTime);
|
||||
}
|
||||
|
||||
public playReady(anm: string = ""){
|
||||
if(anm==="") return;
|
||||
var path = "game/skill/ready/" + anm;
|
||||
this.spawnEffect(path, this.node, this.effectLifeTime);
|
||||
this.spawnAnimEndFx(path, this.node, undefined);
|
||||
}
|
||||
|
||||
public playEnd(anm: string = ""){
|
||||
if(anm==="") return;
|
||||
var path = "game/skill/end/" + anm;
|
||||
this.spawnEffect(path, this.node, this.effectLifeTime);
|
||||
this.spawnAnimEndFx(path, this.node, undefined);
|
||||
}
|
||||
|
||||
/** 治疗特效 */
|
||||
private heathed() {
|
||||
this.spawnEffect("game/skill/buff/heathed", this.node, 1.0);
|
||||
this.spawnAnimEndFx("game/skill/buff/heathed", this.node, undefined);
|
||||
}
|
||||
private deaded(){
|
||||
this.spawnEffect("game/skill/end/atked", this.node, this.effectLifeTime);
|
||||
this.spawnAnimEndFx("game/skill/end/atked", this.node, undefined);
|
||||
}
|
||||
private spawnEffect(path: string, parent: Node | null, life: number = 0.8, worldPos?: Vec3): Node | null {
|
||||
private createFxNode(path: string, parent: Node | null, worldPos?: Vec3): Node | null {
|
||||
if (!parent || !parent.isValid) return null;
|
||||
const prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
if (!prefab) return null;
|
||||
@@ -354,9 +339,23 @@ export class HeroViewComp extends CCComp {
|
||||
if (worldPos) {
|
||||
node.setWorldPosition(worldPos);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
private spawnTimedFx(path: string, parent: Node | null, life: number = 0.8, worldPos?: Vec3): Node | null {
|
||||
const node = this.createFxNode(path, parent, worldPos);
|
||||
if (!node) return null;
|
||||
const ender = node.getComponent(oneCom);
|
||||
if (ender) ender.destroy();
|
||||
const timer = node.getComponent(timedCom) || node.addComponent(timedCom);
|
||||
timer.time = Math.max(0.2, life);
|
||||
timer.ap = 0;
|
||||
return node;
|
||||
}
|
||||
private spawnAnimEndFx(path: string, parent: Node | null, worldPos?: Vec3): Node | null {
|
||||
const node = this.createFxNode(path, parent, worldPos);
|
||||
if (!node) return null;
|
||||
const timer = node.getComponent(timedCom);
|
||||
if (timer) timer.destroy();
|
||||
node.getComponent(oneCom) || node.addComponent(oneCom);
|
||||
return node;
|
||||
}
|
||||
// 注意:BaseUp 逻辑已移到 HeroAttrSystem.update()
|
||||
|
||||
Reference in New Issue
Block a user