feat(英雄组件): 添加天赋选择事件处理逻辑
为TalComp组件添加对GameEvent.UseTalentCard事件的监听和处理,当收到天赋选择事件时调用addTal方法添加对应天赋
This commit is contained in:
@@ -64,10 +64,24 @@ export class TalComp extends ecs.Comp {
|
|||||||
|
|
||||||
// 监听升级事件
|
// 监听升级事件
|
||||||
oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
||||||
|
// 监听天赋选择事件
|
||||||
|
oops.message.on(GameEvent.UseTalentCard, this.onUseTalentCard, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user