diff --git a/assets/script/game/hero/TalComp.ts b/assets/script/game/hero/TalComp.ts index dd777d4f..515c14b6 100644 --- a/assets/script/game/hero/TalComp.ts +++ b/assets/script/game/hero/TalComp.ts @@ -1,5 +1,7 @@ import { basename } from "path/win32"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; +import { GameEvent } from "../common/config/GameEvent"; import { Attrs, BType } from "../common/config/HeroAttrs"; import { BuffConf } from "../common/config/SkillSet"; import { TalAttrs, talConf, TalEffet, TalTarget, TriType} from "../common/config/TalSet"; @@ -59,6 +61,26 @@ export class TalComp extends ecs.Comp { this.heroView = this.ent.get(HeroViewComp); // 初始化天赋集合 this.Tals = {}; + + // 监听升级事件 + oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this); + } + + onDestroy() { + oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this); + } + + /** + * 处理英雄升级事件,触发升级类型的天赋 + */ + private onLevelUp(event: string, args: any) { + // 只有当前实体是主角时才处理(虽然TalComp只挂载在主角上,但为了安全起见可以再确认,或者直接处理) + // GameEvent.CanUpdateLv 事件参数 { lv: number } + + console.log(`[TalComp] 监听到升级事件,当前等级: ${args.lv}`); + + // 更新升级类型的天赋进度 (默认每次升级触发一次,val=1) + this.updateCur(TriType.LUP, 1); } /**