fix(map): 统一英雄相关提示的弹窗逻辑与文案
1. 调整出售英雄时的提示方式,复用smalltip气泡弹窗而非独立toast 2. 优化MissionCardComp的smalltip提示方法,支持自定义文案和多负载格式 3. 补充英雄满员提示的自定义文案,与出售限制提示保持统一提示样式
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user