fix(map): 统一英雄相关提示的弹窗逻辑与文案

1. 调整出售英雄时的提示方式,复用smalltip气泡弹窗而非独立toast
2. 优化MissionCardComp的smalltip提示方法,支持自定义文案和多负载格式
3. 补充英雄满员提示的自定义文案,与出售限制提示保持统一提示样式
This commit is contained in:
panFD
2026-08-02 10:17:10 +08:00
parent 401a5daf77
commit 67c2a53211
3 changed files with 1455 additions and 1199 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -189,9 +189,9 @@ export class HeroBoxComp extends CCComp {
*/
private onSellHeroClick() {
if (!this.eid || !this.model) return;
// 场上仅剩 1 个英雄时不允许出售(至少保留一个作战单位
// 场上仅剩 1 个英雄时不允许出售:复用英雄栏 smalltip 气泡提示(与满员同一挂载点
if (HeroBoxComp.getAliveHeroCount() <= 1) {
oops.gui.toast("至少保留 1 个英雄");
oops.message.dispatchEvent(GameEvent.ShowSmallTip, { type: "hero_full", text: "至少保留 1 个英雄" });
return;
}
oops.audio.playEffect("music/button");

View File

@@ -455,11 +455,17 @@ export class MissionCardComp extends CCComp {
}
private onShowSmallTip(event: string, args: any) {
const type = args as string;
this.showSmallTip(type as any);
// 支持字符串(仅类型)或 { type, text }(类型 + 自定义文案)两种负载
const payload = typeof args === "string" ? { type: args } : (args ?? {});
this.showSmallTip(payload.type, payload.text);
}
public showSmallTip(type: "refresh_coin" | "buy_coin" | "hero_full") {
/**
* 在目标节点上弹出 smalltip 气泡(缩放动画)。
* @param type 提示类型(决定挂载到哪个节点)
* @param text 可选:覆盖气泡文字(默认读 prefab 中配置的文本)
*/
public showSmallTip(type: "refresh_coin" | "buy_coin" | "hero_full", text?: string) {
let targetNode: Node | null = null;
switch (type) {
case "refresh_coin":
@@ -475,6 +481,11 @@ export class MissionCardComp extends CCComp {
if (targetNode && targetNode.isValid) {
const tipNode = targetNode.getChildByName("smalltip");
if (tipNode) {
// 动态覆盖气泡文字box/Label用于同节点多文案场景如英雄满员 / 至少保留 1 人)
if (text) {
const label = tipNode.getComponentInChildren(Label);
if (label) label.string = text;
}
tipNode.active = true;
Tween.stopAllByTarget(tipNode);
@@ -740,7 +751,7 @@ export class MissionCardComp extends CCComp {
if (current >= heroMax) {
payload.cancel = true;
payload.reason = "hero_limit";
this.showSmallTip("hero_full");
this.showSmallTip("hero_full", "英雄队伍已满");
this.playHeroNumDeniedAnim();
}
}