feat(英雄属性): 添加处理属性卡使用的功能
实现属性卡使用逻辑,当使用属性卡时根据配置添加对应buff效果并显示提示信息
This commit is contained in:
@@ -7,6 +7,7 @@ import { HeroInfo, AttrSet } from "../common/config/heroSet";
|
|||||||
import { HeroSkillsComp } from "./HeroSkills";
|
import { HeroSkillsComp } from "./HeroSkills";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
import { ItemSet } from "../common/config/ItemSet";
|
import { ItemSet } from "../common/config/ItemSet";
|
||||||
|
import { AttrCards } from "../common/config/AttrSet";
|
||||||
|
|
||||||
|
|
||||||
interface talTrigger{
|
interface talTrigger{
|
||||||
@@ -80,11 +81,32 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
// 监听升级事件
|
// 监听升级事件
|
||||||
oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
oops.message.on(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
||||||
oops.message.on(GameEvent.UseItemCard, this.onUseItemCard, this);
|
oops.message.on(GameEvent.UseItemCard, this.onUseItemCard, this);
|
||||||
|
oops.message.on(GameEvent.UseAttrCard, this.onUseAttrCard, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
oops.message.off(GameEvent.CanUpdateLv, this.onLevelUp, this);
|
||||||
oops.message.off(GameEvent.UseItemCard, this.onUseItemCard, 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) {
|
onUseItemCard(event: string, args: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user