feat: 添加战斗结算奖励系统
1. 新增结算奖励配置常量,定义金币、天赋经验、英雄碎片的发放规则与胜利加成系数 2. 新增RewardItemComp通用奖励条目组件,实现数量展示与弹跳入场动画 3. 为VictoryComp添加结算奖励逻辑:计算发放奖励、渲染奖励UI并添加入场动画效果 4. 新增金币、天赋经验奖励预制体并配置到结算弹窗中 5. 调整ui3.plist的图片边框参数适配新奖励图标
This commit is contained in:
60
assets/script/game/map/RewardItemComp.ts
Normal file
60
assets/script/game/map/RewardItemComp.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user