重构了 技能系统,还需要完善

This commit is contained in:
2025-10-30 15:12:49 +08:00
parent 1281cbd32d
commit 55646c3a11
27 changed files with 1022 additions and 595 deletions

View File

@@ -11,29 +11,27 @@ import { GameEvent } from "../common/config/GameEvent";
import { SkillSet } from "../common/config/SkillSet";
import { time } from "console";
import { getNeAttrs, getAttrs ,Attrs} from "../common/config/HeroAttrs";
import { TalComp } from "./TalComp";
import { EBusComp } from "./EBusComp";
import { HeroSkillsComp } from "./HeroSkills";
/** 角色实体 */
@ecs.register(`Hero`)
export class Hero extends ecs.Entity {
HeroModel!: HeroAttrsComp;
HeroSkills!: HeroSkillsComp;
View!: HeroViewComp;
BattleMove!: BattleMoveComp;
protected init() {
this.addComponents<ecs.Comp>(
BattleMoveComp,
HeroAttrsComp,
TalComp,
EBusComp,
HeroSkillsComp,
);
}
destroy(): void {
this.remove(HeroViewComp);
this.remove(HeroAttrsComp);
this.remove(TalComp);
this.remove(EBusComp);
this.remove(HeroSkillsComp);
super.destroy();
}
@@ -54,6 +52,7 @@ export class Hero extends ecs.Entity {
// console.log("hero load",pos)
var hv = node.getComponent(HeroViewComp)!;
const model = this.get(HeroAttrsComp);
const skillsComp = this.get(HeroSkillsComp);
let hero = HeroInfo[uuid]; // 共用英雄数据
// 设置 View 层属性(表现相关)
@@ -68,16 +67,8 @@ export class Hero extends ecs.Entity {
model.fac = FacSet.HERO;
model.is_master = true;
// 设置技能
for(let i=0; i<hero.skills.length; i++){
let skill = {
uuid: SkillSet[hero.skills[i]].uuid,
cd_max: SkillSet[hero.skills[i]].cd,
cost: SkillSet[hero.skills[i]].cost,
cd: 0
};
model.skills.push(skill);
}
// ✅ 初始化技能数据(迁移到 HeroSkillsComp
skillsComp.initSkills(hero.skills);
// 设置基础属性
model.base_ap = hero.ap;