refactor(game): 将技能触发逻辑从回合制改为全局次数制
移除技能卡的持续回合数(d_rds)和当前回合计数(current_round),改为仅使用全局触发次数(current_trigger_times)控制技能生命周期 更新UI显示从剩余回合改为剩余触发次数,技能在达到总触发次数后立即销毁而非等待回合结束
This commit is contained in:
@@ -43,7 +43,6 @@ export interface CardConfig {
|
||||
is_inst?: boolean // 是否即时起效
|
||||
t_times?: number // 触发次数
|
||||
t_inv?: number // 触发间隔(秒)
|
||||
d_rds?: number // 持续回合数
|
||||
}
|
||||
export const CardsUpSet: Record<number, number> = {
|
||||
1: 50,
|
||||
@@ -89,14 +88,14 @@ export const CardPoolList: CardConfig[] = [
|
||||
{ uuid: 5304, type: CardType.Hero, cost: 3, weight: 25, pool_lv: 5, kind: CKind.Hero, hero_lv: 1 },
|
||||
|
||||
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
|
||||
{ uuid: 6401, type: CardType.Skill, cost: 2, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体攻击", info: "随机1个友方+5攻击", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6402, type: CardType.Skill, cost: 2, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体生命", info: "随机1个友方+20最大生命值", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6403, type: CardType.Skill, cost: 3, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: "单体全能", info: "随机1个友方+2攻击,+10最大生命值", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6404, type: CardType.Skill, cost: 4, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: "群体攻击", info: "随机3个友方+2攻击", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6405, type: CardType.Skill, cost: 4, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: "群体生命", info: "随机3个友方+10最大生命值", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6406, type: CardType.Skill, cost: 5, weight: 20, pool_lv: 4, kind: CKind.Skill, card_lv: 1, name: "群体全能", info: "为随机3个友方单位增加攻击力和生命上限", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6304, type: CardType.Skill, cost: 3, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: "神圣治疗", info: "恢复场上随机3个友方单位的生命值", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6305, type: CardType.Skill, cost: 4, weight: 20, pool_lv: 4, kind: CKind.Skill, card_lv: 1, name: "群体护盾", info: "随机3个友方获得2次伤害免疫", is_inst: true, t_times: 1, t_inv: 0, d_rds: 1 },
|
||||
{ uuid: 6401, type: CardType.Skill, cost: 2, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体攻击", info: "随机1个友方+5攻击", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6402, type: CardType.Skill, cost: 2, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体生命", info: "随机1个友方+20最大生命值", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6403, type: CardType.Skill, cost: 3, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: "单体全能", info: "随机1个友方+2攻击,+10最大生命值", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6404, type: CardType.Skill, cost: 4, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: "群体攻击", info: "随机3个友方+2攻击", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6405, type: CardType.Skill, cost: 4, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: "群体生命", info: "随机3个友方+10最大生命值", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6406, type: CardType.Skill, cost: 5, weight: 20, pool_lv: 4, kind: CKind.Skill, card_lv: 1, name: "群体全能", info: "为随机3个友方单位增加攻击力和生命上限", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6304, type: CardType.Skill, cost: 3, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: "神圣治疗", info: "恢复场上随机3个友方单位的生命值", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
{ uuid: 6305, type: CardType.Skill, cost: 4, weight: 20, pool_lv: 4, kind: CKind.Skill, card_lv: 1, name: "群体护盾", info: "随机3个友方获得2次伤害免疫", is_inst: true, t_times: 1, t_inv: 0 },
|
||||
|
||||
{ uuid: 7001, type: CardType.SpecialUpgrade, cost: 6, weight: 16, pool_lv: 1 ,kind: CKind.Card },
|
||||
{ uuid: 7002, type: CardType.SpecialUpgrade, cost: 6, weight: 14, pool_lv: 2 ,kind: CKind.Card },
|
||||
|
||||
@@ -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