From 66ab6bc2cdb9051635c1270502d3c2f34e726ced Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 4 Jan 2026 20:23:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=8B=B1=E9=9B=84=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=A9=E8=B5=8B=E9=80=89=E6=8B=A9=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为TalComp组件添加对GameEvent.UseTalentCard事件的监听和处理,当收到天赋选择事件时调用addTal方法添加对应天赋 --- assets/script/game/hero/TalComp.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assets/script/game/hero/TalComp.ts b/assets/script/game/hero/TalComp.ts index 6e2db005..370f51cb 100644 --- a/assets/script/game/hero/TalComp.ts +++ b/assets/script/game/hero/TalComp.ts @@ -64,10 +64,24 @@ export class TalComp extends ecs.Comp { // 监听升级事件 oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this); + // 监听天赋选择事件 + oops.message.on(GameEvent.UseTalentCard, this.onUseTalentCard, this); } onDestroy() { oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this); + oops.message.off(GameEvent.UseTalentCard, this.onUseTalentCard, this); + } + + /** + * 处理天赋选择事件 + * @param event 事件名 + * @param args 天赋UUID + */ + private onUseTalentCard(event: string, args: any) { + const uuid = args as number; + console.log(`[TalComp] 收到天赋选择事件,添加天赋 ID: ${uuid}`); + this.addTal(uuid); } /**