refactor(skill): 重构技能配置加载逻辑,将参数下沉至prefab配置

1. 新增SkillView组件属性runType/endType/speed/time,替换原配置表字段
2. 批量同步所有技能prefab的配置参数
3. 优化技能运行逻辑,优先使用prefab配置,配置表仅作兜底
4. 新增同步脚本用于批量迁移技能配置
This commit is contained in:
pan
2026-08-13 16:26:19 +08:00
parent c6b5e1431f
commit 695a9e2b66
22 changed files with 268 additions and 95 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator, Animation, CCInteger, Collider2D, Contact2DType, UITransform, v3, Vec3 } from "cc";
import { _decorator, Animation, CCFloat, CCInteger, Collider2D, Contact2DType, Enum, UITransform, 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 { HeroViewComp } from "../hero/HeroViewComp";
@@ -22,6 +22,22 @@ export class SkillView extends CCComp {
@property({ type: CCInteger })
atk_y: number = 0
/** 运动类型:直线/贝塞尔/固定起点/固定终点(由 prefab 配置,优先级高于 SkillSet */
@property({ type: Enum(RType), tooltip: "技能特效运动类型" })
runType: RType = RType.linear;
/** 消亡条件:动画结束/计时结束/碰撞次数结束(由 prefab 配置,优先级高于 SkillSet */
@property({ type: Enum(EType), tooltip: "技能特效消亡条件" })
endType: EType = EType.collision;
/** 移动速度(由 prefab 配置,<=0 时回退 SkillSet.speed */
@property({ type: CCFloat, slide: true, range: [0, 2000, 10], tooltip: "技能特效移动速度" })
speed: number = 0;
/** timeEnd 持续时间(秒),仅 endType=timeEnd 时生效(由 prefab 配置,<=0 时回退 SkillSet.time */
@property({ type: CCFloat, slide: true, range: [0, 30, 0.1], tooltip: "timeEnd 持续时间(秒)" })
time: number = 0;
private debugMode: boolean = false;
anim: Animation = null;
@@ -45,7 +61,7 @@ export class SkillView extends CCComp {
this.collider.group = this.group;
this.collider.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
this.collider.enabled = this.SConf?.EType === EType.collision;
this.collider.enabled = this.endType === EType.collision;
}
if (this.node.getComponent(Animation)) {
let anim = this.node.getComponent(Animation);
@@ -128,13 +144,13 @@ export class SkillView extends CCComp {
onAnimationFinished() {
// animationEnd 类型:动画结束后再关闭碰撞并销毁
if (this.SConf.EType == EType.animationEnd) {
if (this.endType == EType.animationEnd) {
this.disable_collider_now();
this.ent.destroy()
return;
}
// fixed 类型不移动,无法通过移动完成销毁;动画播完作为兜底销毁时机
if (this.SConf.RType == RType.fixed) {
if (this.runType == RType.fixed) {
this.disable_collider_now();
this.ent.destroy()
}
@@ -142,7 +158,7 @@ export class SkillView extends CCComp {
// 动画帧事件 atk仅负责开启一帧碰撞窗口不负责伤害与计数
public atk(args: any) {
if (!this.SConf) return;
if (this.SConf.EType == EType.collision) return
if (this.endType == EType.collision) return
if (this.enable_collider_safely()) {
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 开启碰撞检测`);
this.scheduleOnce(() => {