feat(英雄天赋): 添加升级事件监听以触发天赋更新
监听英雄升级事件,当等级提升时自动更新升级类型的天赋进度
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { basename } from "path/win32";
|
import { basename } from "path/win32";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
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 { Attrs, BType } from "../common/config/HeroAttrs";
|
||||||
import { BuffConf } from "../common/config/SkillSet";
|
import { BuffConf } from "../common/config/SkillSet";
|
||||||
import { TalAttrs, talConf, TalEffet, TalTarget, TriType} from "../common/config/TalSet";
|
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.heroView = this.ent.get(HeroViewComp);
|
||||||
// 初始化天赋集合
|
// 初始化天赋集合
|
||||||
this.Tals = {};
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user