refactor(game): 拆分装备卡配置与逻辑,独立管理装备系统
1. 将装备卡从原技能卡池拆分至独立的EquipSet.ts配置 2. 新增专用的装备盒实体与事件流程,替换原有技能卡复用逻辑 3. 调整FieldSkillHelper以支持装备卡的属性加成统计 4. 优化装备商店与抽卡逻辑,移除装备卡的抽卡参与
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
* - 销毁时通过 GameEvent.RemoveSkillBox 通知 MissSkillsComp 回收槽位
|
||||
*
|
||||
* 依赖:
|
||||
* - CardPoolList / CardTriggerType(CardSet)—— 查询技能卡的触发配置
|
||||
* - CardPoolList / CardTriggerType(CardSet)—— 通用卡牌类型定义
|
||||
* - EquipPoolList(EquipSet)—— 装备卡池配置(查询触发配置)
|
||||
* - SkillSet —— 技能静态配置(icon 字段)
|
||||
* - GameEvent —— 各类游戏事件
|
||||
* - smc.mission —— 游戏运行状态
|
||||
@@ -34,6 +35,7 @@ import { _decorator, Node, Prefab, Sprite, Label, Vec3, resources, SpriteAtlas,
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { CardPoolList, CardTriggerType } from "../common/config/CardSet";
|
||||
import { EquipPoolList } from "../common/config/EquipSet";
|
||||
import { SkillSet, SkillOverrides, FieldSkillSet } from "../common/config/SkillSet";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
@@ -149,7 +151,9 @@ export class EquipBoxComp extends CCComp {
|
||||
if (!this.initialized) return;
|
||||
oops.audio.playEffect("music/button");
|
||||
// 点击时弹出 HInfoComp,传入卡牌 UUID 和等级以启用预览模式
|
||||
const config = CardPoolList.find(c => c.uuid === this.s_uuid || c.skill === this.s_uuid);
|
||||
// 优先从装备卡池查找,找不到再从技能卡池查找
|
||||
const config = EquipPoolList.find(c => c.uuid === this.s_uuid || c.skill === this.s_uuid)
|
||||
?? CardPoolList.find(c => c.uuid === this.s_uuid || c.skill === this.s_uuid);
|
||||
const cardUuid = config ? config.uuid : this.s_uuid;
|
||||
|
||||
oops.gui.remove(UIID.HInfo);
|
||||
@@ -158,7 +162,7 @@ export class EquipBoxComp extends CCComp {
|
||||
|
||||
/**
|
||||
* 初始化技能卡效果:
|
||||
* 1. 从 CardPoolList 查询技能卡的触发配置(含 trigger_type)。
|
||||
* 1. 从 EquipPoolList 查询装备卡的触发配置(含 trigger_type)。
|
||||
* 2. 更新 UI 显示(图标 + 次数)。
|
||||
* 3. 按 trigger_type 注册对应事件监听并执行首次触发。
|
||||
*
|
||||
@@ -168,8 +172,8 @@ export class EquipBoxComp extends CCComp {
|
||||
init(uuid: number, card_lv: number) {
|
||||
this.card_lv = card_lv;
|
||||
|
||||
// 查询触发配置
|
||||
const config = CardPoolList.find(c => c.uuid === uuid);
|
||||
// 装备卡配置已迁移至 EquipPoolList
|
||||
const config = EquipPoolList.find(c => c.uuid === uuid);
|
||||
if (config) {
|
||||
this.s_uuid = config.skill ?? uuid; // 获取实际的技能 UUID
|
||||
this.is_instant = config.is_inst ?? true;
|
||||
|
||||
@@ -4,18 +4,19 @@
|
||||
*
|
||||
* 职责:
|
||||
* 1. 渲染单个装备卡的显示信息(名称、等级、属性词条、图标)。
|
||||
* 2. 处理购买点击 → 扣费 → 派发 UseSkillCard 事件触发装备生效。
|
||||
* 2. 处理购买点击 → 扣费 → 派发 UseEquipCard 事件触发装备生效。
|
||||
*
|
||||
* 装备使用机制:
|
||||
* 与技能卡使用流程一致——购买后派发 GameEvent.UseSkillCard,
|
||||
* 由 MissSkillsComp 接收并创建 SkillBoxComp 实体,
|
||||
* SkillBoxComp 按 Field 类型被动驻场,属性加成由 FieldSkillHelper 全局聚合。
|
||||
* 与技能卡使用流程一致——购买后派发 GameEvent.UseEquipCard,
|
||||
* 由 MissEquipComp 接收并创建 EquipBoxComp 实体,
|
||||
* EquipBoxComp 按 Field 类型被动驻场,属性加成由 FieldSkillHelper 全局聚合。
|
||||
*/
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { _decorator, Node, Sprite, Label, NodeEventType } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { CardConfig, CardPoolList } from "../common/config/CardSet";
|
||||
import { CardConfig } from "../common/config/CardSet";
|
||||
import { EquipPoolList } from "../common/config/EquipSet";
|
||||
import { FieldSkillSet } from "../common/config/SkillSet";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
@@ -106,7 +107,7 @@ export class EquipListComp extends CCComp {
|
||||
updateUI() {
|
||||
if (!this.cardData) return;
|
||||
|
||||
const cardConfig = CardPoolList.find(c => c.uuid === this.cardData!.uuid);
|
||||
const cardConfig = EquipPoolList.find(c => c.uuid === this.cardData!.uuid);
|
||||
|
||||
// 名称
|
||||
if (this.name_label) {
|
||||
@@ -191,8 +192,8 @@ export class EquipListComp extends CCComp {
|
||||
return;
|
||||
}
|
||||
|
||||
// 派发 UseSkillCard,装备生效流程与技能卡一致
|
||||
oops.message.dispatchEvent(GameEvent.UseSkillCard, this.cardData);
|
||||
// 派发 UseEquipCard,装备生效流程由 MissEquipComp 接收处理
|
||||
oops.message.dispatchEvent(GameEvent.UseEquipCard, this.cardData);
|
||||
|
||||
// 标记已购买
|
||||
this.isPurchased = true;
|
||||
|
||||
@@ -39,7 +39,8 @@ import { _decorator, instantiate, Label, Node, NodeEventType, Prefab, Tween, twe
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { CardConfig, CardPoolList, CardType, drawCardsByRule, isEquipmentCard, SpecialRefreshCardList, SpecialRefreshHeroType, SpecialUpgradeCardList } from "../common/config/CardSet";
|
||||
import { CardConfig, CardPoolList, CardType, drawCardsByRule, SpecialRefreshCardList, SpecialRefreshHeroType, SpecialUpgradeCardList } from "../common/config/CardSet";
|
||||
import { EquipPoolList } from "../common/config/EquipSet";
|
||||
import { CardComp } from "./CardComp";
|
||||
import { SCardComp } from "./SCardComp";
|
||||
import { EquipListComp } from "./EquipListComp";
|
||||
@@ -319,6 +320,8 @@ export class MissionCardComp extends CCComp {
|
||||
oops.message.on(GameEvent.HeroSell, this.onHeroSell, this);
|
||||
oops.message.on(GameEvent.UseHeroCard, this.onUseHeroCard, this);
|
||||
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
// 监听装备购买事件,追踪已购记录
|
||||
oops.message.on(GameEvent.UseEquipCard, this.onUseEquipCard, this);
|
||||
oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
|
||||
oops.message.on(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
|
||||
oops.message.on(GameEvent.CardUsed, this.onCardUsed, this);
|
||||
@@ -475,12 +478,6 @@ export class MissionCardComp extends CCComp {
|
||||
// 由 onCardUsed 立即向被使用的槽位补充一张新技能卡。
|
||||
// 弹窗由外部(按钮/阶段切换)控制显隐。
|
||||
|
||||
// 追踪装备购买记录(EquipListComp 购买后也会派发此事件)
|
||||
const usedCard = args as CardConfig;
|
||||
if (usedCard && isEquipmentCard(usedCard)) {
|
||||
this.purchasedEquipUuids.add(usedCard.uuid);
|
||||
}
|
||||
|
||||
// 修复:独立判断 guide2 的关闭 和 guide3 的开启
|
||||
if (!smc.finish_guides.includes(2)) {
|
||||
smc.finish_guides.push(2);
|
||||
@@ -495,6 +492,14 @@ export class MissionCardComp extends CCComp {
|
||||
this.scheduleOnce(() => this.updateCoinAndCostUI(), 0);
|
||||
}
|
||||
|
||||
/** 装备购买事件回调:记录已购 UUID,防止重复购买 */
|
||||
private onUseEquipCard(event: string, args: any) {
|
||||
const usedCard = args as CardConfig;
|
||||
if (usedCard) {
|
||||
this.purchasedEquipUuids.add(usedCard.uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/** 解除按钮监听,避免节点销毁后回调泄漏 */
|
||||
private unbindEvents() {
|
||||
oops.message.off(GameEvent.CoinAdd, this.onCoinAdd, this);
|
||||
@@ -503,6 +508,7 @@ export class MissionCardComp extends CCComp {
|
||||
oops.message.off(GameEvent.HeroSell, this.onHeroSell, this);
|
||||
oops.message.off(GameEvent.UseHeroCard, this.onUseHeroCard, this);
|
||||
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
oops.message.off(GameEvent.UseEquipCard, this.onUseEquipCard, this);
|
||||
oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
|
||||
oops.message.off(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
|
||||
oops.message.off(GameEvent.CardUsed, this.onCardUsed, this);
|
||||
@@ -744,10 +750,8 @@ export class MissionCardComp extends CCComp {
|
||||
// 清空旧列表
|
||||
this.equipsBoxNode.removeAllChildren();
|
||||
|
||||
// 获取所有装备卡
|
||||
const equipments = CardPoolList.filter(c => isEquipmentCard(c));
|
||||
|
||||
for (const equip of equipments) {
|
||||
// 从独立装备卡池获取所有装备
|
||||
for (const equip of EquipPoolList) {
|
||||
const node = instantiate(this.equipPrefab);
|
||||
this.equipsBoxNode.addChild(node);
|
||||
const comp = node.getComponent(EquipListComp) || node.addComponent(EquipListComp);
|
||||
@@ -765,7 +769,7 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
|
||||
mLogger.log(this.debugMode, "MissionCardComp", "populate equipments", {
|
||||
count: equipments.length
|
||||
count: EquipPoolList.length
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1082,13 +1086,11 @@ export class MissionCardComp extends CCComp {
|
||||
private buildSkillDrawCards(): CardConfig[] {
|
||||
const currentWave = this.getCurrentWave();
|
||||
// 使用明确规则的 drawCardsByRule,指定只要 3 张技能卡,并且过滤对应 wave
|
||||
// 装备卡已改为商店直购,不再参与抽卡
|
||||
const cards = drawCardsByRule(1, {
|
||||
count: 3,
|
||||
type: CardType.Skill,
|
||||
wave: currentWave,
|
||||
unique: true, // 保证技能牌不重复
|
||||
excludeEquipment: true, // 排除装备卡
|
||||
});
|
||||
|
||||
if (cards.length >= 3) return cards.slice(0, 3);
|
||||
@@ -1099,7 +1101,6 @@ export class MissionCardComp extends CCComp {
|
||||
type: CardType.Skill,
|
||||
wave: currentWave,
|
||||
unique: true,
|
||||
excludeEquipment: true,
|
||||
});
|
||||
if (fallback.length === 0) break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user