feat(map:heroBox): add upgrade cost display and insufficient gold prompt

新增英雄升级费用显示控件,添加金币不足时的小提示和费用标红逻辑,清空旧的升级费用标签引用
This commit is contained in:
panFD
2026-08-05 09:21:22 +08:00
parent 4938e8468e
commit 95969781fb
2 changed files with 11745 additions and 11014 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@
* - HeroInfoheroSet—— 英雄静态配置
*/
import { mLogger } from "../common/Logger";
import { _decorator, Node, Sprite, Label, RichText, resources, AnimationClip, SpriteFrame, NodeEventType, Tween, tween, Vec3 } from "cc";
import { _decorator, Node, Sprite, Label, RichText, resources, AnimationClip, SpriteFrame, NodeEventType, Tween, tween, Vec3, Color } 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";
@@ -37,6 +37,9 @@ const { ccclass, property } = _decorator;
export class HeroBoxComp extends CCComp {
private debugMode: boolean = false;
/** 金币不足时升级费用标红色(暗红,区别于正常白色) */
private static readonly INSUFFICIENT_COLOR: Color = new Color(231, 76, 60);
// ======================== 编辑器绑定节点 ========================
/** 英雄图标节点 */
@@ -68,6 +71,10 @@ export class HeroBoxComp extends CCComp {
@property(Label)
private sell_price_label: Label = null;
/** 升级费用标签(按当前等级显示升级消耗金币,满级时隐藏) */
@property(Label)
private upgrade_price_label: Label = null;
/** 技能描述富文本(多行,展示当前等级触发技能,数值高亮) */
@property(RichText)
private skill_label: RichText = null;
@@ -209,6 +216,11 @@ export class HeroBoxComp extends CCComp {
const heroName = this.model.hero_name ?? "";
const nextLv = heroLv + 1;
const cost = MissionEconomy.getUpgradeCost(heroLv);
// 金币不足smalltip 气泡提示(挂载金币节点),不弹确认框
if (MissionEconomy.getCoin() < cost) {
oops.message.dispatchEvent(GameEvent.ShowSmallTip, { type: "buy_coin", text: "金币不足" });
return;
}
const preview = this.buildUpgradePreview(nextLv);
// oops.gui 公共确认窗口(自定义 CommonPrompt内容支持富文本高亮
@@ -442,6 +454,9 @@ export class HeroBoxComp extends CCComp {
if (this.sell_price_label && this.sell_price_label.isValid) {
this.sell_price_label.string = "";
}
if (this.upgrade_price_label && this.upgrade_price_label.isValid) {
this.upgrade_price_label.string = "";
}
if (this.name_label && this.name_label.isValid) {
this.name_label.string = "";
@@ -500,6 +515,19 @@ export class HeroBoxComp extends CCComp {
this.sell_price_label.string = `${MissionEconomy.getSellGold(lv)}`;
}
// ---- 升级费用(满级隐藏;金币不足时标红提示) ----
if (this.upgrade_price_label && this.upgrade_price_label.isValid) {
const lv = Math.max(1, Math.floor(this.model.lv ?? 1));
if (lv >= FightSet.HERO_MAX_LV) {
this.upgrade_price_label.string = "";
} else {
const cost = MissionEconomy.getUpgradeCost(lv);
this.upgrade_price_label.string = `${cost}`;
// 金币不足标红,足够恢复默认色,给玩家直观的可升级反馈
this.upgrade_price_label.color = MissionEconomy.getCoin() >= cost ? Color.WHITE : HeroBoxComp.INSUFFICIENT_COLOR;
}
}
// ---- AP / HP ----
const finalAp = Math.max(0, Math.floor(this.model.getFinalAp()));
const baseAp = Math.max(0, Math.floor(this.model.base_ap ?? 0));