refactor(game): 将技能触发逻辑从回合制改为全局次数制
移除技能卡的持续回合数(d_rds)和当前回合计数(current_round),改为仅使用全局触发次数(current_trigger_times)控制技能生命周期 更新UI显示从剩余回合改为剩余触发次数,技能在达到总触发次数后立即销毁而非等待回合结束
This commit is contained in:
@@ -24,9 +24,7 @@ export class SkillBoxComp extends CCComp {
|
||||
private is_instant: boolean = true;
|
||||
private trigger_times: number = 1;
|
||||
private trigger_interval: number = 0;
|
||||
private duration_rounds: number = 1;
|
||||
|
||||
private current_round: number = 0;
|
||||
private current_trigger_times: number = 0;
|
||||
private timer: number = 0;
|
||||
private in_combat: boolean = false;
|
||||
@@ -56,10 +54,8 @@ 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.duration_rounds = config.d_rds ?? 1;
|
||||
}
|
||||
|
||||
this.current_round = 0;
|
||||
this.current_trigger_times = 0;
|
||||
this.timer = 0;
|
||||
this.initialized = true;
|
||||
@@ -93,7 +89,8 @@ export class SkillBoxComp extends CCComp {
|
||||
|
||||
if (this.info_label) {
|
||||
if (!this.is_instant) {
|
||||
this.info_label.string = `${this.duration_rounds - this.current_round}回`;
|
||||
const remain = Math.max(0, this.trigger_times - this.current_trigger_times);
|
||||
this.info_label.string = `${remain}次`;
|
||||
} else {
|
||||
this.info_label.string = "";
|
||||
}
|
||||
@@ -107,8 +104,6 @@ export class SkillBoxComp extends CCComp {
|
||||
if (!this.is_instant) {
|
||||
// 战斗开始时,计时归0,重新计时
|
||||
this.timer = 0;
|
||||
// 如果这个技能每回合都可以触发 t_times 次,则在每回合开始时重置当前回合触发次数
|
||||
this.current_trigger_times = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +120,8 @@ export class SkillBoxComp extends CCComp {
|
||||
this.in_combat = false;
|
||||
|
||||
if (!this.is_instant) {
|
||||
this.current_round++;
|
||||
this.updateUI();
|
||||
if (this.current_round >= this.duration_rounds) {
|
||||
// 每回合不再重置次数,由全局次数进行控制
|
||||
if (this.current_trigger_times >= this.trigger_times) {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -147,6 +141,15 @@ export class SkillBoxComp extends CCComp {
|
||||
this.timer = 0; // 触发后重新计时
|
||||
this.triggerSkill();
|
||||
this.current_trigger_times++;
|
||||
this.updateUI(); // 触发后更新界面显示的剩余次数
|
||||
|
||||
// 如果在战斗中就达到触发次数上限,则可以在此回合战斗结束或者立即销毁
|
||||
if (this.current_trigger_times >= this.trigger_times) {
|
||||
// 可以选择直接销毁,不等到下一回合
|
||||
this.scheduleOnce(() => {
|
||||
if (this.node.isValid) this.node.destroy();
|
||||
}, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user