feat(物品系统): 重构药水系统并移除旧物品配置
将药水物品从ItemSet迁移到AttrSet作为PotionCards,并实现新的药水使用逻辑 移除已废弃的ItemSet.ts文件
This commit is contained in:
@@ -6,8 +6,7 @@ import { BuffConf, SkillRange } from "../common/config/SkillSet";
|
||||
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";
|
||||
import { AttrCards, PotionCards } from "../common/config/AttrSet";
|
||||
|
||||
|
||||
interface talTrigger{
|
||||
@@ -111,7 +110,23 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
onUseItemCard(event: string, args: any) {
|
||||
if (!this.is_master) return;
|
||||
this.useItem(args);
|
||||
const itemId = args;
|
||||
|
||||
// 1. 尝试从 PotionCards 获取 (新版药水)
|
||||
const potion = PotionCards[itemId];
|
||||
if (potion) {
|
||||
console.log(`[HeroAttrs] 使用药水: ${potion.desc}`);
|
||||
const buffConf: BuffConf = {
|
||||
buff: potion.attr,
|
||||
value: potion.value,
|
||||
BType: BType.RATIO, // 药水默认是百分比加成
|
||||
time: potion.duration,
|
||||
chance: 1,
|
||||
};
|
||||
this.addBuff(buffConf);
|
||||
oops.gui.toast(potion.desc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,35 +628,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.recalculateSingleAttr(buff.attrIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用物品
|
||||
* @param itemId 物品ID
|
||||
*/
|
||||
useItem(itemId: number) {
|
||||
const item = ItemSet[itemId];
|
||||
if (!item) return;
|
||||
|
||||
console.log(`[HeroAttrs] 使用物品: ${item.name} (${item.desc})`);
|
||||
|
||||
// 直接添加到 BUFFS_TEMP
|
||||
const attrIndex = item.attr;
|
||||
|
||||
if (!this.BUFFS_TEMP[attrIndex]) {
|
||||
this.BUFFS_TEMP[attrIndex] = [];
|
||||
}
|
||||
|
||||
this.BUFFS_TEMP[attrIndex].push({
|
||||
value: item.value,
|
||||
BType: item.bType,
|
||||
remainTime: item.duration
|
||||
});
|
||||
|
||||
// 重新计算受影响的属性
|
||||
this.recalculateSingleAttr(attrIndex);
|
||||
|
||||
oops.gui.toast(`使用了 ${item.name}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据属性索引移除数值型天赋buff
|
||||
* @param attrIndex 属性索引
|
||||
|
||||
Reference in New Issue
Block a user