fix(skillBox): 适配技能ID匹配逻辑并补全战斗启动兼容

1.  扩展技能箱配置查找逻辑,同时支持卡uuid和技能skill id匹配
2.  战斗已进行时直接初始化技能箱计时状态,避免延迟触发
This commit is contained in:
panFD
2026-08-02 17:53:48 +08:00
parent c202f2a751
commit 7033390417
4 changed files with 37 additions and 14 deletions

View File

@@ -848,15 +848,15 @@
"__id__": 42 "__id__": 42
}, },
"_lineHeight": 21, "_lineHeight": 21,
"_string": "<color=#00ff00>Rich</color><color=#0fffff>Text</color>", "_string": "ewrwerwer",
"_horizontalAlign": 0, "_horizontalAlign": 0,
"_verticalAlign": 1, "_verticalAlign": 1,
"_fontSize": 20, "_fontSize": 20,
"_fontColor": { "_fontColor": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 48,
"g": 255, "g": 48,
"b": 255, "b": 48,
"a": 255 "a": 255
}, },
"_maxWidth": 680, "_maxWidth": 680,

View File

@@ -3715,7 +3715,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Label", "_name": "num",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
@@ -3737,7 +3737,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": -26.82,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -3918,7 +3918,9 @@
"bg_node": { "bg_node": {
"__id__": 2 "__id__": 2
}, },
"info_label": null, "num_label": {
"__id__": 167
},
"cd_mask": { "cd_mask": {
"__id__": 156 "__id__": 156
}, },

View File

@@ -160,4 +160,11 @@ export const BuffList: Record<number, BuffConfig> = {
modifiers: [{ attr: Attrs.critical_damage, op: ModOp.Flat, value: 30 }], modifiers: [{ attr: Attrs.critical_damage, op: ModOp.Flat, value: 30 }],
info: "暴击伤害提升 30%,持续 5 秒", info: "暴击伤害提升 30%,持续 5 秒",
}, },
// 冰冻概率强化(限时)
7021: {
id: 7021, name: "冰冻概率爆发", icon: "Stat_Freeze",
category: BuffCategory.Buff, duration: 5, max_stack: 1,
modifiers: [{ attr: Attrs.freeze_chance, op: ModOp.Flat, value: 5 }],
info: "冰冻概率提升 5%,持续 5 秒",
},
}; };

View File

@@ -65,7 +65,7 @@ export class SkillBoxComp extends CCComp {
/** 剩余次数标签 */ /** 剩余次数标签 */
@property(Label) @property(Label)
private info_label: Label = null; private num_label: Label = null;
/** cd计时遮罩 */ /** cd计时遮罩 */
@property({ type: Node }) @property({ type: Node })
@@ -248,7 +248,9 @@ export class SkillBoxComp extends CCComp {
this.card_lv = card_lv; this.card_lv = card_lv;
// 查询触发配置(药水卡不在 SkillCardList会走 else 分支) // 查询触发配置(药水卡不在 SkillCardList会走 else 分支)
const config = SkillCardList.find(c => c.uuid === uuid); // 同时按 卡uuid 或 技能skill id 查找MissSkillsComp.addSkill 传入的是 payload.skill技能ID
// 而 SkillCardList 的 uuid 字段是卡ID如 8101必须兼容 skill 字段匹配(如 6001
const config = SkillCardList.find(c => c.uuid === uuid || c.skill === uuid);
if (config) { if (config) {
this.s_uuid = config.skill ?? uuid; // 获取实际的技能 UUID this.s_uuid = config.skill ?? uuid; // 获取实际的技能 UUID
this.is_instant = config.is_inst ?? true; this.is_instant = config.is_inst ?? true;
@@ -302,6 +304,11 @@ export class SkillBoxComp extends CCComp {
case CardTriggerType.Interval: case CardTriggerType.Interval:
// 定时循环:监听 FightStart 进入战斗后启动计时 // 定时循环:监听 FightStart 进入战斗后启动计时
oops.message.on(GameEvent.FightStart, this.onFightStart, this); oops.message.on(GameEvent.FightStart, this.onFightStart, this);
// 若购买时战斗已在进行FightStart 已派发过),立即进入战斗态,避免空等下一波
if (smc.mission.in_fight) {
this.in_combat = true;
this.timer = 0;
}
break; break;
case CardTriggerType.Field: case CardTriggerType.Field:
@@ -437,7 +444,7 @@ export class SkillBoxComp extends CCComp {
this.trigger_type === CardTriggerType.HeroDead || this.trigger_type === CardTriggerType.HeroDead ||
this.trigger_type === CardTriggerType.HeroCall; this.trigger_type === CardTriggerType.HeroCall;
if (this.info_label) { if (this.num_label) {
if (showRemainCount) { if (showRemainCount) {
// 事件型按 trigger_limitInterval 按 t_times // 事件型按 trigger_limitInterval 按 t_times
const isEvent = const isEvent =
@@ -449,24 +456,31 @@ export class SkillBoxComp extends CCComp {
const total = isEvent ? this.trigger_limit : this.trigger_times; const total = isEvent ? this.trigger_limit : this.trigger_times;
if (isEvent && !isFinite(total)) { if (isEvent && !isFinite(total)) {
// 无上限:显示已触发次数 // 无上限:显示已触发次数
this.info_label.string = `${used}`; this.num_label.string = `${used}`;
} else { } else {
const remain = Math.max(0, Math.floor(total) - used); const remain = Math.max(0, Math.floor(total) - used);
this.info_label.string = `${remain}`; this.num_label.string = `${remain}`;
} }
} else { } else {
this.info_label.string = ""; this.num_label.string = "";
} }
} }
// 初始化或重置 CD 遮罩表现(仅 Interval 类型有冷却进度) // 初始化或重置 CD 遮罩表现(仅 Interval 类型有冷却进度)
// cd_mask 使用 Sprite.Type.FILLED + FillType.RADIAL径向擦除典型 CD 表现)
if (this.cd_mask && this.cd_mask.isValid) { if (this.cd_mask && this.cd_mask.isValid) {
let sprite = this.cd_mask.getComponent(Sprite); let sprite = this.cd_mask.getComponent(Sprite);
if (sprite) { if (sprite) {
if (this.trigger_type === CardTriggerType.Interval && this.trigger_interval > 0) { if (this.trigger_type === CardTriggerType.Interval && this.trigger_interval > 0) {
// 强制设为 FILLED + RADIAL确保在编辑器里漏配也能正常运行
if (sprite.type !== Sprite.Type.FILLED) sprite.type = Sprite.Type.FILLED;
if (sprite.fillType !== Sprite.FillType.RADIAL) sprite.fillType = Sprite.FillType.RADIAL;
this.cd_mask.active = true;
sprite.fillRange = Math.max(0, 1 - (this.timer / this.trigger_interval)); sprite.fillRange = Math.max(0, 1 - (this.timer / this.trigger_interval));
} else { } else {
sprite.fillRange = 0; // 非冷却类型直接归 0 // 非冷却类型直接隐藏遮罩
this.cd_mask.active = false;
sprite.fillRange = 0;
} }
} }
} }