refactor: 将代码中的card_lv统一替换为rarity

本次提交完成了全项目范围内术语的统一替换,将原本指代卡牌品质/等级的card_lv字段全部重命名为rarity,对齐了设计文档中的命名规范,避免了术语混淆:
1.  更新了所有配置文件、组件类、数据结构中的字段定义
2.  同步修改了注释、文档说明中的相关表述
3.  修正了英雄、技能、装备卡牌的品质显示逻辑
4.  调整了背景颜色切换、属性计算等相关业务逻辑
This commit is contained in:
pan
2026-09-02 16:42:54 +08:00
parent 6620b67103
commit d9bccd7c93
36 changed files with 312 additions and 312 deletions

View File

@@ -158,7 +158,7 @@ export class CHeroComp extends CCComp {
nodeUuid: this.node?.uuid,
uuid: data?.uuid ?? null,
name: data?.name ?? null,
card_lv: data?.card_lv ?? null,
rarity: data?.rarity ?? null,
cost: data?.cost ?? null,
nodeActiveBefore: this.node?.active
});
@@ -267,7 +267,7 @@ export class CHeroComp extends CCComp {
this.level_label.string = heroLv > 1 ? `Lv.${heroLv}` : "";
}
// 背景:按 card_lv 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
// 背景:按 rarity 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
this.updateBgNode();
// 描述富文本:展示英雄当前局外等级的能力(buildHeroSkillDesc 文本一)
@@ -301,13 +301,13 @@ export class CHeroComp extends CCComp {
}
/**
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
* 根据 rarity 切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系:
* card_lv 1 → green
* card_lv 2 → blue
* card_lv 3 → purple
* card_lv 4 → red
* card_lv 5 → yellow
* rarity 1 → green
* rarity 2 → blue
* rarity 3 → purple
* rarity 4 → red
* rarity 5 → yellow
*/
private updateBgNode() {
if (!this.bg_node || !this.cardData) return;
@@ -318,7 +318,7 @@ export class CHeroComp extends CCComp {
4: "red",
5: "yellow",
};
const targetColor = lvToColor[this.cardData.card_lv ?? 1];
const targetColor = lvToColor[this.cardData.rarity ?? 1];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});
@@ -542,7 +542,7 @@ export class CHeroComp extends CCComp {
reason: "",
uuid: this.cardData.uuid,
hero_lv: smc.getHeroOuterLv(this.cardData.uuid),
card_lv: this.cardData.base_card_lv ?? this.cardData.card_lv ?? 1
rarity: this.cardData.base_rarity ?? this.cardData.rarity ?? 1
};
oops.message.dispatchEvent(GameEvent.UseHeroCard, guard);
if (guard.cancel) return;

View File

@@ -1,13 +1,13 @@
import { _decorator, Component } from "cc";
import { CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { RARITY_BG_COLORS } from "../common/config/GameSet";
const { ccclass } = _decorator;
@ccclass('CardBgComp')
export class CardBgComp extends Component {
apply(card_lv: number) {
const color = CARD_LV_BG_COLORS[Math.min(card_lv, 5) - 1];
apply(rarity: number) {
const color = RARITY_BG_COLORS[Math.min(rarity, 5) - 1];
this.node.children.forEach(c => c.active = c.name === color);
}

View File

@@ -25,7 +25,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "db://oops-framework/core/Oops";
import { HeroInfo } from "../common/config/heroSet";
import { getLvColor, CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { getLvColor, RARITY_BG_COLORS } from "../common/config/GameSet";
import { canHeroUpgrade } from "../common/config/heroUpSet";
import { GameEvent } from "../common/config/GameEvent";
import { smc } from "../common/SingletonModuleComp";
@@ -178,7 +178,7 @@ export class CardLiteComp extends CCComp {
/**
* 渲染英雄卡面。
*
* 1. 背景:按 card_lv 切换颜色底框(green/blue/purple/yellow/red)。
* 1. 背景:按 rarity 切换颜色底框(green/blue/purple/yellow/red)。
* 2. 名称:英雄名。
* 3. 等级:局外成长等级(Lv.X),颜色按 getLvColor。
* 4. 图标:idle 动画首帧静态展示。
@@ -187,10 +187,10 @@ export class CardLiteComp extends CCComp {
this.iconVisualToken += 1;
if (this.opacityComp) this.opacityComp.opacity = 255;
// 背景:按 card_lv 切换颜色底框
// 背景:按 rarity 切换颜色底框
if (this.BG_node) {
const bgLv = Math.min(Math.max(hero.card_lv ?? 1, 1), 5);
const color = CARD_LV_BG_COLORS[bgLv - 1];
const bgLv = Math.min(Math.max(hero.rarity ?? 1, 1), 5);
const color = RARITY_BG_COLORS[bgLv - 1];
this.BG_node.children.forEach(child => child.active = (child.name === color));
}

View File

@@ -4,7 +4,7 @@
*
* 职责:
* 1. 根据英雄 UUID 渲染 **图标**(idle 动画首帧静态展示,零运行时动画开销)。
* 2. 根据 HeroInfo.card_lv 切换 **背景底框颜色**(BG_node 下的 green/blue/purple/yellow/red 子节点)。
* 2. 根据 HeroInfo.rarity 切换 **背景底框颜色**(BG_node 下的 green/blue/purple/yellow/red 子节点)。
*
* 说明:
* - 仅处理英雄展示,数据源为 heroSet 的 HeroInfo,不依赖 CardSet。
@@ -16,7 +16,7 @@ import { _decorator, AnimationClip, Node, Sprite, resources, SpriteFrame } from
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroInfo } from "../common/config/heroSet";
import { CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { RARITY_BG_COLORS } from "../common/config/GameSet";
const { ccclass, property } = _decorator;
@@ -55,9 +55,9 @@ export class ChipComp extends CCComp {
this.node.active = true;
this.iconVisualToken += 1;
// 背景:按 card_lv 切换颜色底框(green/blue/purple/yellow/red)
// 背景:按 rarity 切换颜色底框(green/blue/purple/yellow/red)
if (this.BG_node) {
const color = CARD_LV_BG_COLORS[Math.min(Math.max(hero.card_lv ?? 1, 1), 5) - 1];
const color = RARITY_BG_COLORS[Math.min(Math.max(hero.rarity ?? 1, 1), 5) - 1];
this.BG_node.children.forEach(child => child.active = (child.name === color));
}

View File

@@ -29,7 +29,7 @@ export class EBox extends ecs.Entity {
* 1) 创建节点并挂到 parent 下(未传时默认 SKILL 层)
* 2) 初始化表现与属性数据
*/
load(uuid: number, card_lv: number, pos: Vec3, prefab: Prefab, parent?: Node): Node {
load(uuid: number, rarity: number, pos: Vec3, prefab: Prefab, parent?: Node): Node {
let node = instantiate(prefab);
// 默认挂到实体显示层 SKILL 节点下
@@ -47,7 +47,7 @@ export class EBox extends ecs.Entity {
this.add(eboxComp);
// 初始化业务逻辑
eboxComp.init(uuid, card_lv);
eboxComp.init(uuid, rarity);
return node;
}

View File

@@ -82,7 +82,7 @@ export class EquipBoxComp extends CCComp {
/** 技能 UUID */
private s_uuid: number = 0;
/** 卡牌等级 */
private card_lv: number = 1;
private rarity: number = 1;
/** 是否为即时技能(true=使用后立即触发,false=战斗中定时触发) */
private is_instant: boolean = true;
/** 总触发次数 */
@@ -245,10 +245,10 @@ export class EquipBoxComp extends CCComp {
* 3. 按 trigger_type 注册对应事件监听并执行首次触发。
*
* @param uuid 卡牌 UUID
* @param card_lv 技能卡等级
* @param rarity 技能卡等级
*/
init(uuid: number, card_lv: number) {
this.card_lv = card_lv;
init(uuid: number, rarity: number) {
this.rarity = rarity;
// 装备卡配置已迁移至 EquipPoolList
const config = EquipPoolList.find(c => c.uuid === uuid);
@@ -381,9 +381,9 @@ export class EquipBoxComp extends CCComp {
/**
* 根据技能等级切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系(技能卡 wave 档位):
* card_lv 1 (wave 1) → green
* card_lv 2 (wave 5) → blue
* card_lv 3 (wave 8) → purple
* rarity 1 (wave 1) → green
* rarity 2 (wave 5) → blue
* rarity 3 (wave 8) → purple
*/
private updateBgNode() {
if (!this.bg_node) return;
@@ -392,7 +392,7 @@ export class EquipBoxComp extends CCComp {
2: "blue",
3: "purple",
};
const targetColor = lvToColor[this.card_lv];
const targetColor = lvToColor[this.rarity];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});
@@ -625,7 +625,7 @@ export class EquipBoxComp extends CCComp {
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: this.s_uuid,
isCardSkill: true, // 标记为卡牌技能(区别于英雄自身技能)
card_lv: this.card_lv,
rarity: this.rarity,
targetPos: targetPos,
overrides: this.overrides
});

View File

@@ -42,7 +42,7 @@ export class EquipListComp extends CCComp {
@property({ type: Node })
private icon_node: Node = null;
/** 背景节点(含 green/blue/purple/red/yellow 颜色子节点,按 card_lv 激活) */
/** 背景节点(含 green/blue/purple/red/yellow 颜色子节点,按 rarity 激活) */
@property({ type: Node })
private bg_node: Node = null;
@@ -148,11 +148,11 @@ export class EquipListComp extends CCComp {
// 等级标签(Lv.1 / Lv.2 / Lv.3)
if (this.level_label) {
const lv = this.cardData.card_lv ?? 1;
const lv = this.cardData.rarity ?? 1;
this.level_label.string = `Lv.${lv}`;
}
// 背景:按 card_lv 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
// 背景:按 rarity 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
this.updateBgNode();
// 属性词条富文本(多词条装备由 buildEquipRich 按 \n 多行渲染,数值实时高亮)
@@ -187,13 +187,13 @@ export class EquipListComp extends CCComp {
}
/**
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
* 根据 rarity 切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系:
* card_lv 1 → green
* card_lv 2 → blue
* card_lv 3 → purple
* card_lv 4 → red
* card_lv 5 → yellow
* rarity 1 → green
* rarity 2 → blue
* rarity 3 → purple
* rarity 4 → red
* rarity 5 → yellow
*/
private updateBgNode() {
if (!this.bg_node || !this.cardData) return;
@@ -204,7 +204,7 @@ export class EquipListComp extends CCComp {
4: "red",
5: "yellow",
};
const targetColor = lvToColor[this.cardData.card_lv ?? 1];
const targetColor = lvToColor[this.cardData.rarity ?? 1];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});

View File

@@ -512,8 +512,8 @@ export class HeroBoxComp extends CCComp {
const heroUuid = this.model.hero_uuid ?? 0;
const hero = HeroInfo[heroUuid];
// ---- 背景(按 card_lv 切换 bg_node 颜色子节点) ----
this.updateBgNode(hero?.card_lv ?? 1);
// ---- 背景(按 rarity 切换 bg_node 颜色子节点) ----
this.updateBgNode(hero?.rarity ?? 1);
// ---- 名称 ----
if (this.name_label && this.name_label.isValid) {
@@ -568,16 +568,16 @@ export class HeroBoxComp extends CCComp {
// ======================== 内部工具 ========================
/**
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
* 根据 rarity 切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系:
* card_lv 1 → green
* card_lv 2 → blue
* card_lv 3 → purple
* card_lv 4 → red
* card_lv 5 → yellow
* @param cardLv 英雄卡牌等级(HeroInfo.card_lv,缺省按 1 处理)
* rarity 1 → green
* rarity 2 → blue
* rarity 3 → purple
* rarity 4 → red
* rarity 5 → yellow
* @param rarity 英雄卡牌等级(HeroInfo.rarity,缺省按 1 处理)
*/
private updateBgNode(cardLv: number) {
private updateBgNode(rarity: number) {
if (!this.bg_node || !this.bg_node.isValid) return;
const lvToColor: Record<number, string> = {
1: "green",
@@ -586,7 +586,7 @@ export class HeroBoxComp extends CCComp {
4: "red",
5: "yellow",
};
const targetColor = lvToColor[cardLv] ?? lvToColor[1];
const targetColor = lvToColor[rarity] ?? lvToColor[1];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});

View File

@@ -25,7 +25,7 @@ import { mLogger } from "../common/Logger";
import { HeroInfo, HeroList, SkillTriggerType, LvFieldEntry, LvReviveEntry, LvTriggerEntry, TriggerGrouped, getHeroDisplayStats } from "../common/config/heroSet";
import { buildHeroSkillDesc } from "../common/HeroSkillText";
import { GameEvent } from "../common/config/GameEvent";
import { HERO_UPGRADE_NEED_FRAGMENTS, CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { HERO_UPGRADE_NEED_FRAGMENTS, RARITY_BG_COLORS } from "../common/config/GameSet";
import { CardLiteComp } from "./CardLiteComp";
import { ChipComp } from "./ChipComp";
import { SmallTipComp } from "./SmallTipComp";
@@ -313,7 +313,7 @@ export class HerosListComp extends CCComp {
this.cards_node.removeAllChildren()
const sorted = [...HeroList].sort((a, b) => {
return (HeroInfo[a]?.card_lv ?? 1) - (HeroInfo[b]?.card_lv ?? 1);
return (HeroInfo[a]?.rarity ?? 1) - (HeroInfo[b]?.rarity ?? 1);
});
for (const uuid of sorted) {
@@ -410,7 +410,7 @@ export class HerosListComp extends CCComp {
if (infoLabel) infoLabel.string = desc || hero.info || ""
}
this.updatePoolLvBg(hero.card_lv ?? 1)
this.updatePoolLvBg(hero.rarity ?? 1)
this.updateLvDisplay(uuid)
this.updateRoleDisplay(hero)
this.updateHeroAnimation(uuid)
@@ -418,10 +418,10 @@ export class HerosListComp extends CCComp {
this.updateSkillIcons(hero)
}
private updatePoolLvBg(card_lv: number) {
private updatePoolLvBg(rarity: number) {
if (!this.BG_node) return
// BG_node 下直接放置颜色节点(green/blue/purple/yellow/red),按卡池等级激活对应颜色
const color = CARD_LV_BG_COLORS[Math.min(card_lv, 5) - 1]
const color = RARITY_BG_COLORS[Math.min(rarity, 5) - 1]
this.BG_node.children.forEach(child => {
child.active = (child.name === color)
})

View File

@@ -44,7 +44,7 @@ export class ItemListComp extends CCComp {
@property({ type: Node })
private icon_node: Node = null;
/** 背景节点(含 green/blue/purple/red/yellow 颜色子节点,按 card_lv 激活) */
/** 背景节点(含 green/blue/purple/red/yellow 颜色子节点,按 rarity 激活) */
@property({ type: Node })
private bg_node: Node = null;
@@ -156,11 +156,11 @@ export class ItemListComp extends CCComp {
// 等级标签(★ 表示卡牌等级)
if (this.level_label) {
const lv = this.cardData.card_lv ?? 1;
const lv = this.cardData.rarity ?? 1;
this.level_label.string = lv >= 2 ? "★".repeat(lv - 1) : "";
}
// 背景:按 card_lv 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
// 背景:按 rarity 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
this.updateBgNode();
// 描述/属性词条富文本(装备逐词条多行;药品/技能卡数值随 overrides 档位自动同步)
@@ -201,13 +201,13 @@ export class ItemListComp extends CCComp {
}
/**
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
* 根据 rarity 切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系:
* card_lv 1 → green
* card_lv 2 → blue
* card_lv 3 → purple
* card_lv 4 → red
* card_lv 5 → yellow
* rarity 1 → green
* rarity 2 → blue
* rarity 3 → purple
* rarity 4 → red
* rarity 5 → yellow
*/
private updateBgNode() {
if (!this.bg_node || !this.cardData) return;
@@ -218,7 +218,7 @@ export class ItemListComp extends CCComp {
4: "red",
5: "yellow",
};
const targetColor = lvToColor[this.cardData.card_lv ?? 1];
const targetColor = lvToColor[this.cardData.rarity ?? 1];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});

View File

@@ -145,16 +145,16 @@ export class MissEquipComp extends CCComp {
}
/**
* 处理使用装备卡事件:提取 uuid 和 card_lv 后调用 addEquip。
* 处理使用装备卡事件:提取 uuid 和 rarity 后调用 addEquip。
* @param event 事件名
* @param args 卡牌数据(含 uuid、card_lv)
* @param args 卡牌数据(含 uuid、rarity)
*/
private onUseEquipCard(event: string, args: any) {
const payload = args ?? event;
const uuid = Number(payload?.uuid ?? 0);
const card_lv = Math.max(1, Math.floor(Number(payload?.card_lv ?? 1)));
const rarity = Math.max(1, Math.floor(Number(payload?.rarity ?? 1)));
if (!uuid) return;
this.addSkill(uuid, card_lv);
this.addSkill(uuid, rarity);
}
start() {
@@ -168,9 +168,9 @@ export class MissEquipComp extends CCComp {
* 3. 获取或添加 EquipBoxComp 并初始化。
*
* @param uuid 装备 UUID
* @param card_lv 装备卡等级
* @param rarity 装备卡等级
*/
addSkill(uuid: number, card_lv: number) {
addSkill(uuid: number, rarity: number) {
if (!this.equip_box) {
mLogger.error(this.debugMode, "MissEquipComp", "equip_box prefab not set");
return;
@@ -190,7 +190,7 @@ export class MissEquipComp extends CCComp {
// 使用 ECS 实体创建装备节点,挂载到对应 ebar 子节点下
let ebox = ecs.getEntity<EBox>(EBox);
let node = ebox.load(uuid, card_lv, Vec3.ZERO, this.equip_box, this.ebars_node.children[emptyIndex]);
let node = ebox.load(uuid, rarity, Vec3.ZERO, this.equip_box, this.ebars_node.children[emptyIndex]);
this.slots[emptyIndex].used = true;
this.slots[emptyIndex].node = node;

View File

@@ -154,18 +154,18 @@ export class MissSkillsComp extends CCComp {
}
/**
* 处理使用技能卡事件:提取 uuid 和 card_lv 后调用 addSkill。
* 处理使用技能卡事件:提取 uuid 和 rarity 后调用 addSkill。
* @param event 事件名
* @param args 卡牌数据(含 uuid、card_lv)
* @param args 卡牌数据(含 uuid、rarity)
*/
private onUseSkillCard(event: string, args: any) {
const payload = args ?? event;
// 卡 uuid 仅用于查配置;真正施法用技能 id(payload.skill),缺省时退回 uuid(兼容技能卡直接用技能 id 的场景)
const skillUuid = Number(payload?.skill ?? payload?.uuid ?? 0);
const card_lv = Math.max(1, Math.floor(Number(payload?.card_lv ?? 1)));
const rarity = Math.max(1, Math.floor(Number(payload?.rarity ?? 1)));
if (!skillUuid) return;
// 药水/技能卡的 overrides(含 buff_value)需透传到技能实体
this.addSkill(skillUuid, card_lv, payload?.overrides);
this.addSkill(skillUuid, rarity, payload?.overrides);
}
/**
@@ -215,9 +215,9 @@ export class MissSkillsComp extends CCComp {
* 3. 获取或添加 SkillBoxComp 并初始化。
*
* @param uuid 技能 UUID
* @param card_lv 技能卡等级
* @param rarity 技能卡等级
*/
addSkill(uuid: number, card_lv: number, overrides?: SkillOverrides) {
addSkill(uuid: number, rarity: number, overrides?: SkillOverrides) {
if (!this.skill_box) {
mLogger.error(this.debugMode, "MissSkillsComp", "skill_box prefab not set");
return;
@@ -234,7 +234,7 @@ export class MissSkillsComp extends CCComp {
// 使用 ECS 实体创建技能节点
let sbox = ecs.getEntity<SBox>(SBox);
let pos = new Vec3(this.slots[emptyIndex].x, this.slots[emptyIndex].y, 0);
let node = sbox.load(uuid, card_lv, pos, this.skill_box, overrides);
let node = sbox.load(uuid, rarity, pos, this.skill_box, overrides);
this.slots[emptyIndex].used = true;
this.slots[emptyIndex].node = node;

View File

@@ -2152,7 +2152,7 @@ export class MissionCardComp extends CCComp {
model.lv = nextLv;
// 同步 base 快照(与 Hero.load 同公式:固定基础值 × 品质系数,成长由 grow_type 线性递增提供)
const qualityCoef = getHeroQualityCoef(hero.card_lv ?? 1);
const qualityCoef = getHeroQualityCoef(hero.rarity ?? 1);
const base_ap = Math.round(hero.ap * qualityCoef);
const base_hp = Math.round(hero.hp * qualityCoef);
model.base_ap = base_ap;

View File

@@ -96,7 +96,7 @@ export class MissionHeroComp extends CCComp {
/** 是否正在消费召唤队列(防止并发) */
is_processing_queue: boolean = false
/** 召唤请求队列:按职业优先级排序后串行登场 */
summon_queue: { uuid: number; hero_lv: number; card_lv: number; role: HRole }[] = []
summon_queue: { uuid: number; hero_lv: number; rarity: number; role: HRole }[] = []
/** 英雄出生序计数器(编队排队/渲染排序的稳定决胜) */
private heroSpawnOrder = 0
/** 预留英雄列表 */
@@ -160,12 +160,12 @@ export class MissionHeroComp extends CCComp {
/**
* 召唤请求入口:
* 从事件参数中提取 uuid / hero_lv / card_lv,放入串行队列。
* 从事件参数中提取 uuid / hero_lv / rarity,放入串行队列。
* 队列按职业优先级(坦克→战士→刺客→射手→法师→辅助,HRole 升序)排序,
* 保证高优先级职业先登场。
*
* @param event 事件名
* @param args { uuid, hero_lv, card_lv }
* @param args { uuid, hero_lv, rarity }
*/
private async call_hero(event: string, args: any) {
const payload = args ?? event;
@@ -174,10 +174,10 @@ export class MissionHeroComp extends CCComp {
// payload.hero_lv 保留作为下限兜底,防止外部显式指定更高等级
const outer_lv = smc.getHeroOuterLv(uuid);
const hero_lv = Math.max(outer_lv, Math.max(1, Number(payload?.hero_lv ?? 1)));
const card_lv = Math.max(1, Number(payload?.card_lv ?? 1));
const rarity = Math.max(1, Number(payload?.rarity ?? 1));
const role = HeroInfo[uuid]?.role ?? HRole.Support;
this.summon_queue.push({ uuid, hero_lv, card_lv, role });
this.summon_queue.push({ uuid, hero_lv, rarity, role });
// 按职业优先级稳定排序:HRole 升序,同职业保持入队先后
this.summon_queue.sort((a, b) => a.role - b.role);
this.processSummonQueue();
@@ -224,10 +224,10 @@ export class MissionHeroComp extends CCComp {
*
* @param uuid 英雄 UUID
* @param hero_lv 英雄等级
* @param card_lv 卡牌等级(驱动 bg_node 颜色)
* @param rarity 卡牌等级(驱动 bg_node 颜色)
* @returns 创建的 Hero 实体
*/
private spawnHeroAt(uuid: number, hero_lv: number, card_lv: number) {
private spawnHeroAt(uuid: number, hero_lv: number, rarity: number) {
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
const role = HeroInfo[uuid]?.role ?? HRole.Support;
@@ -241,7 +241,7 @@ export class MissionHeroComp extends CCComp {
const landingPos = slot.landingPos;
let spawnPos: Vec3 = v3(landingPos.x, landingPos.y + MissionHeroComp.HERO_DROP_HEIGHT, 0);
hero.load(spawnPos, scale, uuid, landingPos.y, hero_lv, card_lv, finalPosIndex);
hero.load(spawnPos, scale, uuid, landingPos.y, hero_lv, rarity, finalPosIndex);
// 登记出生序,供编队排队/渲染排序做稳定决胜
const move = hero.get(MoveComp);
@@ -289,7 +289,7 @@ export class MissionHeroComp extends CCComp {
while (this.summon_queue.length > 0) {
const payload = this.summon_queue.shift();
if (!payload) continue;
this.spawnHeroAt(payload.uuid, payload.hero_lv, payload.card_lv);
this.spawnHeroAt(payload.uuid, payload.hero_lv, payload.rarity);
// 登场间隔:让掉落动画逐个播放,避免同帧堆叠
if (this.summon_queue.length > 0) {
await new Promise<void>(resolve => setTimeout(resolve, MissionHeroComp.SUMMON_INTERVAL * 1000));

View File

@@ -30,7 +30,7 @@ export class SBox extends ecs.Entity {
* 1) 创建节点并挂到 SKILL 层
* 2) 初始化表现与属性数据
*/
load(uuid: number, card_lv: number, pos: Vec3, prefab: Prefab, overrides?: SkillOverrides): Node {
load(uuid: number, rarity: number, pos: Vec3, prefab: Prefab, overrides?: SkillOverrides): Node {
let node = instantiate(prefab);
let scene = smc.map.MapView.scene;
@@ -46,7 +46,7 @@ export class SBox extends ecs.Entity {
this.add(sboxComp);
// 初始化业务逻辑(透传药水卡 overrides,含 buff_value)
sboxComp.init(uuid, card_lv, overrides);
sboxComp.init(uuid, rarity, overrides);
return node;
}

View File

@@ -43,7 +43,7 @@ export class SCardComp extends CCComp {
@property({ type: Node })
private icon_node: Node = null;
/** 背景节点(含 green/blue/purple/red/yellow 颜色子节点,按 card_lv 激活) */
/** 背景节点(含 green/blue/purple/red/yellow 颜色子节点,按 rarity 激活) */
@property({ type: Node })
private bg_node: Node = null;
@@ -189,11 +189,11 @@ export class SCardComp extends CCComp {
// 等级标签(★ 表示卡牌等级)
if (this.level_label) {
const lv = this.cardData.card_lv ?? 1;
const lv = this.cardData.rarity ?? 1;
this.level_label.string = lv >= 2 ? "★".repeat(lv - 1) : "";
}
// 背景:按 card_lv 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
// 背景:按 rarity 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
this.updateBgNode();
// 描述富文本(数值随 overrides 档位自动同步高亮)
@@ -228,13 +228,13 @@ export class SCardComp extends CCComp {
}
/**
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
* 根据 rarity 切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系:
* card_lv 1 → green
* card_lv 2 → blue
* card_lv 3 → purple
* card_lv 4 → red
* card_lv 5 → yellow
* rarity 1 → green
* rarity 2 → blue
* rarity 3 → purple
* rarity 4 → red
* rarity 5 → yellow
*/
private updateBgNode() {
if (!this.bg_node || !this.cardData) return;
@@ -245,7 +245,7 @@ export class SCardComp extends CCComp {
4: "red",
5: "yellow",
};
const targetColor = lvToColor[this.cardData.card_lv ?? 1];
const targetColor = lvToColor[this.cardData.rarity ?? 1];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});

View File

@@ -46,7 +46,7 @@ export class SSkillBoxComp extends CCComp {
* 弹窗按槽位精确取档,避免自动定位命中错误分组 */
private hero_slot?: SkillTriggerType;
/** 卡牌等级 */
private card_lv: number = 1;
private rarity: number = 1;
/** 卡牌自定义图标ID(优先级最高,未定义则按 trigger_type 自动取) */
private card_icon?: string;
/** 技能名称(装备卡取卡牌名,英雄图鉴取技能名) */
@@ -75,7 +75,7 @@ export class SSkillBoxComp extends CCComp {
oops.audio.playEffect("music/button");
oops.gui.open(UIID.SInfo, {
uuid: this.s_uuid,
skill_lv: this.card_lv,
skill_lv: this.rarity,
card_icon: this.card_icon,
skill_name: this.resolveSkillName(),
field: this.field,
@@ -112,7 +112,7 @@ export class SSkillBoxComp extends CCComp {
this.s_uuid = s_uuid;
this.hero_uuid = heroUuid;
this.hero_slot = slot;
this.card_lv = s_lv;
this.rarity = s_lv;
this.hero_icon_source = isField ? "field" : "skill";
this.updateUI();
this.setLocked(locked);
@@ -244,7 +244,7 @@ export class SSkillBoxComp extends CCComp {
// 显示技能等级(Lv.x 样式)
if (this.lv_label) {
this.lv_label.string = `Lv.${this.card_lv}`;
this.lv_label.string = `Lv.${this.rarity}`;
}
}

View File

@@ -82,7 +82,7 @@ export class SkillBoxComp extends CCComp {
/** 技能 UUID */
private s_uuid: number = 0;
/** 卡牌等级 */
private card_lv: number = 1;
private rarity: number = 1;
/** 是否为即时技能(true=使用后立即触发,false=战斗中定时触发) */
private is_instant: boolean = true;
/** 总触发次数 */
@@ -218,7 +218,7 @@ export class SkillBoxComp extends CCComp {
});
ibox?.init({
skillUuid,
skillLv: this.card_lv,
skillLv: this.rarity,
overrides: this.overrides,
});
mLogger.log(this.debugMode, "SkillBoxComp", "ibox init done", {
@@ -241,10 +241,10 @@ export class SkillBoxComp extends CCComp {
* 3. 按 trigger_type 注册对应事件监听并执行首次触发。
*
* @param uuid 卡牌 UUID
* @param card_lv 技能卡等级
* @param rarity 技能卡等级
*/
init(uuid: number, card_lv: number, overrides?: SkillOverrides) {
this.card_lv = card_lv;
init(uuid: number, rarity: number, overrides?: SkillOverrides) {
this.rarity = rarity;
// 查询触发配置(药水卡不在 SkillCardList,会走 else 分支)
// 同时按 卡uuid 或 技能skill id 查找:MissSkillsComp.addSkill 传入的是 payload.skill(技能ID),
@@ -388,9 +388,9 @@ export class SkillBoxComp extends CCComp {
/**
* 根据技能等级切换 bg_node 下的颜色子节点显示。
* 等级与颜色对应关系(技能卡 wave 档位):
* card_lv 1 (wave 1) → green
* card_lv 2 (wave 5) → blue
* card_lv 3 (wave 8) → purple
* rarity 1 (wave 1) → green
* rarity 2 (wave 5) → blue
* rarity 3 (wave 8) → purple
*/
private updateBgNode() {
if (!this.bg_node) return;
@@ -399,7 +399,7 @@ export class SkillBoxComp extends CCComp {
2: "blue",
3: "purple",
};
const targetColor = lvToColor[this.card_lv];
const targetColor = lvToColor[this.rarity];
this.bg_node.children.forEach(child => {
child.active = (child.name === targetColor);
});
@@ -631,7 +631,7 @@ export class SkillBoxComp extends CCComp {
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: this.s_uuid,
isCardSkill: true, // 标记为卡牌技能(区别于英雄自身技能)
card_lv: this.card_lv,
rarity: this.rarity,
targetPos: targetPos,
overrides: this.overrides
});