feat(hero card): add upgrade reminder feature

1. 新增英雄升级配置判定模块,封装升级条件校验逻辑
2. 为卡牌组件添加可升级标识节点和刷新逻辑
3. 实现英雄列表面板统一刷新所有卡牌的升级标识
4. 监听英雄成长变更事件实时更新升级提示状态
This commit is contained in:
panFD
2026-08-30 23:10:08 +08:00
parent 6e38e062b7
commit af4c45dc28
5 changed files with 123 additions and 0 deletions

View File

@@ -6,22 +6,28 @@
* 1. 管理英雄图鉴中单张英雄卡牌的 **显示**(名称、图标动画、卡池等级、英雄等级)。
* 2. 接收英雄 UUID 并渲染对应卡面。
* 3. 点击卡牌时通过事件通知父组件(HerosListComp)切换选中英雄详情。
* 4. 英雄碎片满足升级条件时显示 canup 标识。
*
* 关键设计:
* - 轻量展示组件,仅用于英雄展示,无拖拽使用、无锁定、无费用扣除等交互。
* - 英雄卡图标加载 idle 动画剪辑并提取首帧静态展示。
* - 通过 iconVisualToken 防止异步加载竞态。
* - canup 标识监听 HERO_GROWTH_UPDATE 事件实时刷新(碎片变动/升级后自动更新)。
*
* 依赖:
* - HeroInfo(heroSet)—— 用于渲染英雄卡面信息
* - canHeroUpgrade(heroUpSet)—— 英雄升级条件判定
* - smc —— 全局单例,访问图标图集缓存与英雄局外等级
*/
import { mLogger } from "../common/Logger";
import { _decorator, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteFrame, Tween, tween, UIOpacity, Vec3, resources } 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 { oops } from "db://oops-framework/core/Oops";
import { HeroInfo } from "../common/config/heroSet";
import { getLvColor, CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { canHeroUpgrade } from "../common/config/heroUpSet";
import { GameEvent } from "../common/config/GameEvent";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
@@ -55,6 +61,10 @@ export class CardLiteComp extends CCComp {
@property(Label)
lvl_node: Label = null!
/** 可升级标识节点(碎片满足升级条件时显示) */
@property(Node)
canup_node: Node = null!
// ======================== 运行时状态 ========================
card_uuid: number = 0
@@ -108,9 +118,24 @@ export class CardLiteComp extends CCComp {
clear() {
this.card_uuid = 0;
this.applyEmptyUI();
if (this.canup_node) this.canup_node.active = false;
this.node.active = false;
}
/**
* 刷新可升级标识:碎片满足升级条件时显示 canup 节点。
* 渲染时自动调用一次;升级后由 HerosListComp 统一触发刷新。
*/
refreshCanUp() {
if (!this.canup_node) return;
if (!this.hasCard()) {
this.canup_node.active = false;
return;
}
const growth = smc.getHeroGrowth(this.card_uuid);
this.canup_node.active = canHeroUpgrade(growth.lv, growth.fragments);
}
/**
* 设置选中态:选中卡微微放大,取消选中恢复原尺寸。
* @param selected 是否选中