Files
pixelheros/assets/script/game/map/RewardItemComp.ts
panFD c239eafc10 fix(map): 移除奖励数字前的加号前缀
调整RewardItemComp和VictoryComp中的奖励数量显示逻辑,去掉原本的+号前缀,统一展示原始数值
2026-09-04 22:26:01 +08:00

61 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file RewardItemComp.ts
* @description 结算奖励条目组件(UI 视图层)
*
* 挂载在 reward_item.prefab 上,用于展示单个非英雄碎片类奖励(金币 / 天赋经验等)。
* 图标在编辑器内直接配置好(Sprite 静态图),组件只负责:
* 1. 设置数量文本("+N")。
* 2. 播放入场弹跳动画(scale 0 → 1,backOut)。
*
* 英雄碎片奖励不使用本组件,而是复用 clips.prefab + ChipComp(见 VictoryComp.renderRewards)。
*/
import { _decorator, Label, tween, v3, Tween } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
const { ccclass, property } = _decorator;
/** 奖励条目入场动画时长(秒) */
const ENTER_DURATION = 0.35;
/**
* RewardItemComp —— 单个结算奖励条目视图组件
*/
@ccclass('RewardItemComp')
@ecs.register('RewardItemComp', false)
export class RewardItemComp extends CCComp {
@property({ type: Label, tooltip: "数量文本(count_label)" })
count_label: Label = null!;
/**
* 设置奖励数量并播放入场动画。
* @param count 奖励数量(展示为 "+N")
*/
setReward(count: number) {
if (this.count_label) {
this.count_label.string = `${count}`;
}
this.playEnter();
}
/** 入场动画:从 0 缩放弹至 1 */
private playEnter() {
Tween.stopAllByTarget(this.node);
this.node.setScale(0, 0, 1);
tween(this.node)
.to(ENTER_DURATION, { scale: v3(1, 1, 1) }, { easing: 'backOut' })
.start();
}
protected onDestroy(): void {
Tween.stopAllByTarget(this.node);
super.onDestroy();
}
/** ECS 组件移除时销毁节点 */
reset() {
this.node.destroy();
}
}