feat(技能系统): 添加技能类型枚举并重构天赋系统

- 在SkillSet.ts中新增HSSet枚举区分普通攻击、技能和必杀技
- 重构TalSet.ts中的天赋效果枚举,移除N_ATK和N_SKILL类型
- 在HeroSkillsComp中增加hset字段标识技能类型
- 修改SACastSystem以支持根据技能类型触发不同天赋
- 完全重写TalComp组件,实现更完善的天赋触发和效果管理
This commit is contained in:
walkpan
2025-11-18 23:54:25 +08:00
parent 7b067213c0
commit 9798930879
5 changed files with 262 additions and 40 deletions

View File

@@ -2,10 +2,12 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { Vec3, v3 } from "cc";
import { HeroAttrsComp } from "./HeroAttrsComp";
import { HeroViewComp } from "./HeroViewComp";
import { SkillSet, SType } from "../common/config/SkillSet";
import { HSSet, SkillSet, SType } from "../common/config/SkillSet";
import { HeroSkillsComp, SkillSlot } from "./HeroSkills";
import { Skill } from "../skill/Skill";
import { smc } from "../common/SingletonModuleComp";
import { TalComp } from "./TalComp";
import { TalEffet, TriType } from "../common/config/TalSet";
/**
* ==================== 自动施法系统 ====================
@@ -58,13 +60,13 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
if (!this.hasEnemyInSkillRange(heroView, heroAttrs, skill.dis)) continue;
// ✅ 开始执行施法
this.startCast(e,skill);
this.startCast(e,skill,skill.hset);
// 一次只施放一个技能
break;
}
}
private startCast(e: ecs.Entity,skill:SkillSlot): void {
private startCast(e: ecs.Entity,skill:SkillSlot,hset:HSSet): void {
if (!skill||!e) return
const skills = e.get(HeroSkillsComp);
const heroAttrs = e.get(HeroAttrsComp);
@@ -73,7 +75,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
if (!this.checkCastConditions(skills, heroAttrs, skill.s_uuid)) return
// 4. 执行施法
this.executeCast(e, skill.s_uuid, heroView);
this.executeCast(e, skill.s_uuid, heroView,hset);
// 5. 扣除资源和重置CD
heroAttrs.mp -= skill.cost;
skills.resetCD(skill.s_uuid);
@@ -104,7 +106,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
/**
* 执行施法
*/
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp) {
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet) {
const config = SkillSet[s_uuid];
if (!config) {
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
@@ -112,12 +114,36 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
}
// 1. 播放施法动画
heroView.playSkillEffect(s_uuid);
let isDSill=false
let isWFuny=false
// 2. 更新攻击类型的天赋触发值
if(casterEntity.has(TalComp)){
const talComp = casterEntity.get(TalComp);
if (hset === HSSet.atk) {
talComp.updateCur(TriType.ATK);
isWFuny= talComp.checkIsTrigger(TalEffet.WFUNY);
}
if (hset != HSSet.atk) {
talComp.updateCur(TriType.SKILL);
isDSill= talComp.checkIsTrigger(TalEffet.D_SKILL);
}
}
// 2. 延迟创建技能实体(等待动画)
const delay = 0.3
heroView.scheduleOnce(() => {
this.createSkill(s_uuid, heroView);
this.createSkill(s_uuid, heroView,isWFuny);
isWFuny=false
}, delay);
if(isDSill){
heroView.playSkillEffect(s_uuid);
heroView.scheduleOnce(() => {
this.createSkill(s_uuid, heroView,isWFuny);
isWFuny=false
}, delay);
}
const heroAttrs = casterEntity.get(HeroAttrsComp);
// console.log(`[SACastSystem] ${heroAttrs?.hero_name ?? '未知'} 施放技能: ${config.name}`);
@@ -126,7 +152,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
/**
* 创建技能实体
*/
private createSkill(s_uuid: number, caster: HeroViewComp) {
private createSkill(s_uuid: number, caster: HeroViewComp,isWFuny:boolean) {
// 检查节点有效性
if (!caster.node || !caster.node.isValid) {
console.warn("[SACastSystem] 施法者节点无效");