refactor(skill): 移除旧技能组件和文档,优化技能配置结构 fix(skill): 修正技能预制体配置错误,统一技能运行类型字段 docs(skill): 删除过时的技能系统说明文档 perf(skill): 优化技能加载逻辑,减少资源消耗 style(skill): 调整代码格式,提高可读性
107 lines
2.3 KiB
TypeScript
107 lines
2.3 KiB
TypeScript
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { Vec3 } from "cc";
|
|
|
|
/**
|
|
* ==================== 技能数据组件 ====================
|
|
*
|
|
* 用途:
|
|
* - 存储单个技能的完整数据
|
|
* - 包含技能配置、状态、目标等信息
|
|
* - 可被技能系统读取和修改
|
|
*/
|
|
@ecs.register('SkillData')
|
|
export class SkillDataComp extends ecs.Comp {
|
|
/** 技能唯一ID */
|
|
skillId: number = 0;
|
|
|
|
/** 技能名称 */
|
|
name: string = "";
|
|
|
|
/** 技能等级 */
|
|
level: number = 1;
|
|
|
|
/** 技能类型 */
|
|
type: number = 0;
|
|
|
|
/** 消耗MP */
|
|
cost: number = 0;
|
|
|
|
/** 冷却时间 */
|
|
cooldown: number = 0;
|
|
|
|
/** 当前冷却剩余时间 */
|
|
currentCooldown: number = 0;
|
|
|
|
/** 伤害值 */
|
|
damage: number = 0;
|
|
|
|
/** 技能范围 */
|
|
range: number = 0;
|
|
|
|
/** 施法时间 */
|
|
castTime: number = 0;
|
|
|
|
/** 技能描述 */
|
|
description: string = "";
|
|
|
|
/** 是否已解锁 */
|
|
unlocked: boolean = false;
|
|
|
|
/** 技能图标路径 */
|
|
iconPath: string = "";
|
|
|
|
/** 额外属性数据 */
|
|
extraData: any = null;
|
|
|
|
reset() {
|
|
this.skillId = 0;
|
|
this.name = "";
|
|
this.level = 1;
|
|
this.type = 0;
|
|
this.cost = 0;
|
|
this.cooldown = 0;
|
|
this.currentCooldown = 0;
|
|
this.damage = 0;
|
|
this.range = 0;
|
|
this.castTime = 0;
|
|
this.description = "";
|
|
this.unlocked = false;
|
|
this.iconPath = "";
|
|
this.extraData = null;
|
|
}
|
|
|
|
/**
|
|
* 检查技能是否可以施放
|
|
*/
|
|
canCast(currentMP: number): boolean {
|
|
return this.unlocked &&
|
|
this.currentCooldown <= 0 &&
|
|
currentMP >= this.cost;
|
|
}
|
|
|
|
/**
|
|
* 更新冷却时间
|
|
*/
|
|
updateCooldown(deltaTime: number): void {
|
|
if (this.currentCooldown > 0) {
|
|
this.currentCooldown = Math.max(0, this.currentCooldown - deltaTime);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 重置冷却时间
|
|
*/
|
|
resetCooldown(): void {
|
|
this.currentCooldown = this.cooldown;
|
|
}
|
|
|
|
/**
|
|
* 获取冷却进度 (0-1)
|
|
*/
|
|
getCooldownProgress(): number {
|
|
if (this.cooldown <= 0) return 1;
|
|
return Math.max(0, 1 - (this.currentCooldown / this.cooldown));
|
|
}
|
|
}
|
|
|