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); } /**