feat(skillBox): 添加技能跨波次维持功能
1. 新增keep_waves配置字段控制技能维持波次 2. 重构技能盒组件的波次切换逻辑,支持跨波次持续生效 3. 为默认技能卡添加15波次的维持配置 4. 优化节点销毁的合法性校验逻辑
This commit is contained in:
@@ -38,13 +38,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 179
|
"__id__": 179
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 181
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": {
|
"_prefab": {
|
||||||
"__id__": 183
|
"__id__": 181
|
||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
@@ -2941,42 +2938,6 @@
|
|||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
"fileId": "20N3saNnNERbP8SNI6KMUs"
|
"fileId": "20N3saNnNERbP8SNI6KMUs"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"__type__": "85b24f6HyJBGrOmgul5dRLh",
|
|
||||||
"_name": "",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"__editorExtras__": {},
|
|
||||||
"node": {
|
|
||||||
"__id__": 1
|
|
||||||
},
|
|
||||||
"_enabled": true,
|
|
||||||
"__prefab": {
|
|
||||||
"__id__": 180
|
|
||||||
},
|
|
||||||
"card1": {
|
|
||||||
"__id__": 11
|
|
||||||
},
|
|
||||||
"card2": {
|
|
||||||
"__id__": 48
|
|
||||||
},
|
|
||||||
"card3": {
|
|
||||||
"__id__": 85
|
|
||||||
},
|
|
||||||
"refreshBtn": {
|
|
||||||
"__id__": 132
|
|
||||||
},
|
|
||||||
"adRefreshBtn": {
|
|
||||||
"__id__": 153
|
|
||||||
},
|
|
||||||
"refreshCountLabel": {
|
|
||||||
"__id__": 142
|
|
||||||
},
|
|
||||||
"_id": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.CompPrefabInfo",
|
|
||||||
"fileId": "3eEXZZeMJExoKLpjpFECeL"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"__type__": "cc.BlockInputEvents",
|
"__type__": "cc.BlockInputEvents",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
@@ -2987,7 +2948,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 182
|
"__id__": 180
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export interface CardConfig {
|
|||||||
is_inst?: boolean // 是否即时起效
|
is_inst?: boolean // 是否即时起效
|
||||||
t_times?: number // 触发次数
|
t_times?: number // 触发次数
|
||||||
t_inv?: number // 触发间隔(秒)
|
t_inv?: number // 触发间隔(秒)
|
||||||
|
keep_waves?: number // 维持的波次数(-1表示持续到战斗结束,0或undefined表示仅本波次)
|
||||||
}
|
}
|
||||||
export const CardsUpSet: Record<number, number> = {
|
export const CardsUpSet: Record<number, number> = {
|
||||||
1: 50,
|
1: 50,
|
||||||
@@ -126,14 +127,14 @@ HeroList.forEach(uuid => {
|
|||||||
// 添加非英雄卡牌 (技能、功能卡)
|
// 添加非英雄卡牌 (技能、功能卡)
|
||||||
CardPoolList.push(
|
CardPoolList.push(
|
||||||
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
|
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
|
||||||
{ uuid: 6401, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6401"), info: t("skill_info_6401"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6401, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6401"), info: t("skill_info_6401"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15},
|
||||||
{ uuid: 6402, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6402"), info: t("skill_info_6402"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6402, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6402"), info: t("skill_info_6402"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
{ uuid: 6403, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6403"), info: t("skill_info_6403"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6403, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6403"), info: t("skill_info_6403"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
{ uuid: 6404, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6404"), info: t("skill_info_6404"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6404, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6404"), info: t("skill_info_6404"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
{ uuid: 6405, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6405"), info: t("skill_info_6405"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6405, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6405"), info: t("skill_info_6405"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
{ uuid: 6406, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6406"), info: t("skill_info_6406"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6406, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6406"), info: t("skill_info_6406"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
{ uuid: 6304, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6304"), info: t("skill_info_6304"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6304, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6304"), info: t("skill_info_6304"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
{ uuid: 6305, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6305"), info: t("skill_info_6305"), is_inst: true, t_times: 1, t_inv: 0 },
|
{ uuid: 6305, type: CardType.Skill, cost: 0, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6305"), info: t("skill_info_6305"), is_inst: true, t_times: 1, t_inv: 0, keep_waves:15 },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ export class SkillBoxComp extends CCComp {
|
|||||||
private trigger_times: number = 1;
|
private trigger_times: number = 1;
|
||||||
/** 触发间隔(秒,仅持续技能有效) */
|
/** 触发间隔(秒,仅持续技能有效) */
|
||||||
private trigger_interval: number = 0;
|
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.is_instant = config.is_inst ?? true;
|
||||||
this.trigger_times = config.t_times ?? 1;
|
this.trigger_times = config.t_times ?? 1;
|
||||||
this.trigger_interval = config.t_inv ?? 0;
|
this.trigger_interval = config.t_inv ?? 0;
|
||||||
|
this.keep_waves = config.keep_waves ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.current_trigger_times = 0;
|
this.current_trigger_times = 0;
|
||||||
@@ -134,10 +137,10 @@ export class SkillBoxComp extends CCComp {
|
|||||||
// 即时技能:立即触发
|
// 即时技能:立即触发
|
||||||
this.triggerSkill();
|
this.triggerSkill();
|
||||||
this.current_trigger_times++;
|
this.current_trigger_times++;
|
||||||
if (this.current_trigger_times >= this.trigger_times) {
|
if (this.keep_waves === 0 && this.current_trigger_times >= this.trigger_times) {
|
||||||
// 次数已满 → 延迟 1 秒后销毁(保留短暂视觉反馈)
|
// 次数已满且不跨波次维持 → 延迟 1 秒后销毁(保留短暂视觉反馈)
|
||||||
this.scheduleOnce(() => {
|
this.scheduleOnce(() => {
|
||||||
this.node.destroy();
|
if (this.node && this.node.isValid) this.node.destroy();
|
||||||
}, 1.0);
|
}, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,15 +199,36 @@ export class SkillBoxComp extends CCComp {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新一波:退出战斗状态。
|
* 新一波:退出战斗状态。
|
||||||
* 持续技能:若总次数已用完则销毁。
|
* 处理维持波次逻辑:递减剩余波次,或者重置触发次数。
|
||||||
*/
|
*/
|
||||||
private handleNewWave() {
|
private handleNewWave() {
|
||||||
if (!this.initialized) return;
|
if (!this.initialized) return;
|
||||||
this.in_combat = false;
|
this.in_combat = false;
|
||||||
|
|
||||||
if (!this.is_instant) {
|
if (this.keep_waves !== 0) {
|
||||||
if (this.current_trigger_times >= this.trigger_times) {
|
if (this.keep_waves > 0) {
|
||||||
this.node.destroy();
|
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.current_trigger_times++;
|
||||||
this.updateUI();
|
this.updateUI();
|
||||||
|
|
||||||
// 次数用完 → 延迟销毁
|
// 次数用完且不跨波次维持 → 延迟销毁
|
||||||
if (this.current_trigger_times >= this.trigger_times) {
|
if (this.keep_waves === 0 && this.current_trigger_times >= this.trigger_times) {
|
||||||
this.scheduleOnce(() => {
|
this.scheduleOnce(() => {
|
||||||
if (this.node.isValid) this.node.destroy();
|
if (this.node && this.node.isValid) this.node.destroy();
|
||||||
}, 0.5);
|
}, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user