refactor(hero): 重构天赋系统使用统一管理方式

- 将分散的天赋属性管理改为统一的Talents记录
- 添加addTalent和consumeTalent方法来管理天赋状态
- 修改技能系统使用新的天赋管理接口
This commit is contained in:
2025-11-20 14:51:26 +08:00
parent f2ec48bd2b
commit 5a81704379
3 changed files with 25 additions and 17 deletions

View File

@@ -134,8 +134,6 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
*/
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet): boolean {
const heroAttrs=casterEntity.get(HeroAttrsComp)
let isDSill=heroAttrs.tal_DSill.count > 0
let isWFuny=heroAttrs.tal_WFuny.count > 0
const config = SkillSet[s_uuid];
if (!config) {
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
@@ -165,14 +163,13 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
}, delay);
//风怒wfuny 只针对 普通攻击起效
if (hset === HSSet.atk&&isWFuny){
if (hset === HSSet.atk && heroAttrs.consumeTalent(TalEffet.WFUNY)){
heroView.playSkillEffect(s_uuid);
//需要再添加 风怒动画
this.createSkill(s_uuid, heroView,targets);
heroAttrs.tal_WFuny.count --
}
// 双技能 只针对 技能起效
if(hset === HSSet.skill&&isDSill){
if(hset === HSSet.skill && heroAttrs.consumeTalent(TalEffet.D_SKILL)){
targets = this.sTargets(heroView, s_uuid);
if (targets.length === 0) {
console.warn("[SACastSystem] 没有找到有效目标");
@@ -183,7 +180,6 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
heroView.scheduleOnce(() => {
this.createSkill(s_uuid, heroView,targets);
}, delay);
heroAttrs.tal_DSill.count --
}
@@ -194,7 +190,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
/**
* 创建技能实体
*/
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],damage:number=0) {
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],exr_dmg:number=0) {
// 检查节点有效性
if (!caster.node || !caster.node.isValid) {
console.warn("[SACastSystem] 施法者节点无效");
@@ -219,7 +215,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
const targetPos = targets[0]; // 使用第一个目标位置
// console.log(`[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`);
// 加载技能实体(包括预制体、组件初始化等)
skill.load(startPos, parent, s_uuid, targetPos, caster,damage);
skill.load(startPos, parent, s_uuid, targetPos, caster,exr_dmg);
}