diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index c9fed450..006dacdb 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -7,6 +7,7 @@ import { HeroInfo, AttrSet } from "../common/config/heroSet"; import { HeroSkillsComp } from "./HeroSkills"; import { smc } from "../common/SingletonModuleComp"; import { ItemSet } from "../common/config/ItemSet"; +import { AttrCards } from "../common/config/AttrSet"; interface talTrigger{ @@ -80,11 +81,32 @@ export class HeroAttrsComp extends ecs.Comp { // 监听升级事件 oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this); oops.message.on(GameEvent.UseItemCard, this.onUseItemCard, this); + oops.message.on(GameEvent.UseAttrCard, this.onUseAttrCard, this); } onDestroy() { oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this); oops.message.off(GameEvent.UseItemCard, this.onUseItemCard, this); + oops.message.off(GameEvent.UseAttrCard, this.onUseAttrCard, this); + } + + onUseAttrCard(event: string, args: any) { + if (!this.is_master) return; + const uuid = args; + const attrCard = AttrCards[uuid]; + if (attrCard) { + console.log(`[HeroAttrs] 使用属性卡: ${attrCard.desc}`); + // 构造 BuffConf,默认使用 BType.VALUE,永久生效 (time: 0) + const buffConf: BuffConf = { + buff: attrCard.attr, + value: attrCard.value, + BType: BType.VALUE, + time: 0, + chance: 1, // 必中 + }; + this.addBuff(buffConf); + oops.gui.toast(attrCard.desc); + } } onUseItemCard(event: string, args: any) {