fix(skillBox): 适配技能ID匹配逻辑并补全战斗启动兼容
1. 扩展技能箱配置查找逻辑,同时支持卡uuid和技能skill id匹配 2. 战斗已进行时直接初始化技能箱计时状态,避免延迟触发
This commit is contained in:
@@ -65,7 +65,7 @@ export class SkillBoxComp extends CCComp {
|
||||
|
||||
/** 剩余次数标签 */
|
||||
@property(Label)
|
||||
private info_label: Label = null;
|
||||
private num_label: Label = null;
|
||||
|
||||
/** cd计时遮罩 */
|
||||
@property({ type: Node })
|
||||
@@ -248,7 +248,9 @@ export class SkillBoxComp extends CCComp {
|
||||
this.card_lv = card_lv;
|
||||
|
||||
// 查询触发配置(药水卡不在 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) {
|
||||
this.s_uuid = config.skill ?? uuid; // 获取实际的技能 UUID
|
||||
this.is_instant = config.is_inst ?? true;
|
||||
@@ -302,6 +304,11 @@ export class SkillBoxComp extends CCComp {
|
||||
case CardTriggerType.Interval:
|
||||
// 定时循环:监听 FightStart 进入战斗后启动计时
|
||||
oops.message.on(GameEvent.FightStart, this.onFightStart, this);
|
||||
// 若购买时战斗已在进行(FightStart 已派发过),立即进入战斗态,避免空等下一波
|
||||
if (smc.mission.in_fight) {
|
||||
this.in_combat = true;
|
||||
this.timer = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case CardTriggerType.Field:
|
||||
@@ -437,7 +444,7 @@ export class SkillBoxComp extends CCComp {
|
||||
this.trigger_type === CardTriggerType.HeroDead ||
|
||||
this.trigger_type === CardTriggerType.HeroCall;
|
||||
|
||||
if (this.info_label) {
|
||||
if (this.num_label) {
|
||||
if (showRemainCount) {
|
||||
// 事件型按 trigger_limit;Interval 按 t_times
|
||||
const isEvent =
|
||||
@@ -449,24 +456,31 @@ export class SkillBoxComp extends CCComp {
|
||||
const total = isEvent ? this.trigger_limit : this.trigger_times;
|
||||
if (isEvent && !isFinite(total)) {
|
||||
// 无上限:显示已触发次数
|
||||
this.info_label.string = `${used}`;
|
||||
this.num_label.string = `${used}`;
|
||||
} else {
|
||||
const remain = Math.max(0, Math.floor(total) - used);
|
||||
this.info_label.string = `${remain}`;
|
||||
this.num_label.string = `${remain}`;
|
||||
}
|
||||
} else {
|
||||
this.info_label.string = "";
|
||||
this.num_label.string = "";
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化或重置 CD 遮罩表现(仅 Interval 类型有冷却进度)
|
||||
// cd_mask 使用 Sprite.Type.FILLED + FillType.RADIAL(径向擦除,典型 CD 表现)
|
||||
if (this.cd_mask && this.cd_mask.isValid) {
|
||||
let sprite = this.cd_mask.getComponent(Sprite);
|
||||
if (sprite) {
|
||||
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));
|
||||
} else {
|
||||
sprite.fillRange = 0; // 非冷却类型直接归 0
|
||||
// 非冷却类型直接隐藏遮罩
|
||||
this.cd_mask.active = false;
|
||||
sprite.fillRange = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user