feat(skillBox): 添加技能跨波次维持功能

1. 新增keep_waves配置字段控制技能维持波次
2. 重构技能盒组件的波次切换逻辑,支持跨波次持续生效
3. 为默认技能卡添加15波次的维持配置
4. 优化节点销毁的合法性校验逻辑
This commit is contained in:
pan
2026-06-04 10:34:51 +08:00
parent 7e86aed500
commit 73214dbb10
3 changed files with 45 additions and 59 deletions

View File

@@ -68,6 +68,8 @@ export class SkillBoxComp extends CCComp {
private trigger_times: number = 1;
/** 触发间隔(秒,仅持续技能有效) */
private trigger_interval: number = 0;
/** 维持的波次数(-1表示直到战斗结束0表示不跨波次>0表示维持的具体波次数 */
private keep_waves: number = 0;
// ======================== 运行时状态 ========================
@@ -122,6 +124,7 @@ export class SkillBoxComp extends CCComp {
this.is_instant = config.is_inst ?? true;
this.trigger_times = config.t_times ?? 1;
this.trigger_interval = config.t_inv ?? 0;
this.keep_waves = config.keep_waves ?? 0;
}
this.current_trigger_times = 0;
@@ -134,10 +137,10 @@ export class SkillBoxComp extends CCComp {
// 即时技能:立即触发
this.triggerSkill();
this.current_trigger_times++;
if (this.current_trigger_times >= this.trigger_times) {
// 次数已满 → 延迟 1 秒后销毁(保留短暂视觉反馈)
if (this.keep_waves === 0 && this.current_trigger_times >= this.trigger_times) {
// 次数已满且不跨波次维持 → 延迟 1 秒后销毁(保留短暂视觉反馈)
this.scheduleOnce(() => {
this.node.destroy();
if (this.node && this.node.isValid) this.node.destroy();
}, 1.0);
}
}
@@ -196,15 +199,36 @@ export class SkillBoxComp extends CCComp {
/**
* 新一波:退出战斗状态。
* 持续技能:若总次数已用完则销毁
* 处理维持波次逻辑:递减剩余波次,或者重置触发次数
*/
private handleNewWave() {
if (!this.initialized) return;
this.in_combat = false;
if (!this.is_instant) {
if (this.current_trigger_times >= this.trigger_times) {
this.node.destroy();
if (this.keep_waves !== 0) {
if (this.keep_waves > 0) {
this.keep_waves--;
if (this.keep_waves <= 0) {
if (this.node && this.node.isValid) this.node.destroy();
return;
}
}
// 能够跨波次维持,重置触发次数和计时器,以便新一波继续触发
this.current_trigger_times = 0;
this.timer = 0;
// 即时技能在新一波开始时立即触发一次
if (this.is_instant) {
this.triggerSkill();
this.current_trigger_times++;
}
this.updateUI();
} else {
// 默认逻辑:不跨波次维持
if (!this.is_instant) {
if (this.current_trigger_times >= this.trigger_times) {
if (this.node && this.node.isValid) this.node.destroy();
}
}
}
}
@@ -234,10 +258,10 @@ export class SkillBoxComp extends CCComp {
this.current_trigger_times++;
this.updateUI();
// 次数用完 → 延迟销毁
if (this.current_trigger_times >= this.trigger_times) {
// 次数用完且不跨波次维持 → 延迟销毁
if (this.keep_waves === 0 && this.current_trigger_times >= this.trigger_times) {
this.scheduleOnce(() => {
if (this.node.isValid) this.node.destroy();
if (this.node && this.node.isValid) this.node.destroy();
}, 0.5);
}
}