From 9ada743451b189f87d6dacfdec699929a4b012f0 Mon Sep 17 00:00:00 2001 From: panw Date: Sun, 4 Jan 2026 16:49:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84=E5=A4=A9=E8=B5=8B):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=87=E7=BA=A7=E4=BA=8B=E4=BB=B6=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E4=BB=A5=E8=A7=A6=E5=8F=91=E5=A4=A9=E8=B5=8B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 监听英雄升级事件,当等级提升时自动更新升级类型的天赋进度 --- assets/script/game/hero/TalComp.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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); } /**