Files
heros/assets/script/game/skill/SkillAnimation.ts
2025-02-02 14:48:06 +08:00

55 lines
1.5 KiB
TypeScript

import { ecs ,} from "db://oops-framework/libs/ecs/ECS";
import { HeroViewComp } from "../hero/HeroViewComp";
import { SkillsComp } from "./SkillSystem";
import { SkillSet } from "../common/config/SkillSet";
import { Node } from "cc";
// 动画组件
@ecs.register('SkillAnimation')
export class SkillAnimationComp extends ecs.Comp {
prefab: Node | null = null; // 预制体实例
damageTriggerTime = 0.3; // 伤害触发时间(秒)
elapsed = 0; // 已播放时间
reset() {
this.prefab?.destroy();
this.prefab = null;
this.damageTriggerTime = 0.3;
this.elapsed = 0;
}
}
// 动画系统
@ecs.register('SkillAnimationSystem')
export class SkillAnimationSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
filter(): ecs.IMatcher {
return ecs.allOf(SkillAnimationComp, HeroViewComp);
}
update(e: ecs.Entity): void {
const anim = e.get(SkillAnimationComp);
anim.elapsed += this.dt;
// 伤害触发检测
// if (!anim.hitted && anim.elapsed >= anim.hitTime) {
// this.applyDamage(e);
// anim.hitted = true;
// }
// 更新动画状态
// if (anim.elapsed >= anim.duration) {
// e.remove(SkillAnimationComp);
// }
}
private applyDamage(e: ecs.Entity) {
const skill = e.get(SkillsComp);
const view = e.get(HeroViewComp);
// 添加伤害标记组件
}
// 在角色组件中实现目标查找
}