refactor(map): 调整英雄列表布局参数与添加页签红点逻辑

1. 新增英雄列表卡片宽度、间距、边距可配置属性,修正列表内容宽度计算
2. 为任务主页添加英雄成长和天赋更新事件监听,实现页签红点自动刷新
3. 补充全英雄可升级状态检测与红点显示逻辑
This commit is contained in:
panFD
2026-09-08 22:20:22 +08:00
parent cfaed3b63f
commit 214231d64f
4 changed files with 1190 additions and 739 deletions

View File

@@ -26,6 +26,8 @@ import { GameEvent } from "../common/config/GameEvent";
import { Timer } from "db://oops-framework/core/common/timer/Timer";
import { mLogger } from "../common/Logger";
import { UIID } from "../common/config/GameUIConfig";
import { HeroList } from "../common/config/heroSet";
import { canHeroUpgrade } from "../common/config/heroUpSet";
const { ccclass, property } = _decorator;
@@ -84,6 +86,14 @@ export class MissionHomeComp extends CCComp {
/** 注册任务结束事件 */
protected onLoad(): void {
this.on(GameEvent.MissionEnd, this.mission_end, this)
// oops.message 事件总线:成长/天赋数据变化时刷新页签红点
oops.message.on(GameEvent.HERO_GROWTH_UPDATE, this.refreshRedDots, this)
oops.message.on(GameEvent.TALENT_UPDATE, this.refreshRedDots, this)
}
protected onDestroy(): void {
oops.message.off(GameEvent.HERO_GROWTH_UPDATE, this.refreshRedDots, this)
oops.message.off(GameEvent.TALENT_UPDATE, this.refreshRedDots, this)
}
/** 启动时显示主页 */
@@ -97,6 +107,8 @@ export class MissionHomeComp extends CCComp {
}
onEnable() {
// 节点重新激活时补刷一次红点(事件分发期间本节点可能处于隐藏态)
this.refreshRedDots()
}
update(dt: number) {
@@ -233,6 +245,32 @@ export class MissionHomeComp extends CCComp {
if (child) child.active = active
}
/**
* 刷新页签按钮红点:
* - hero_btn/red_dot:任意英雄碎片满足升级条件(canHeroUpgrade)时显示
* - tals_btn/red_dot:存在未分配的天赋点(talent_points > 0)时显示
*/
private refreshRedDots() {
this.setRedDot(this.hero_btn, this.hasUpgradableHero())
this.setRedDot(this.tals_btn, smc.getTalentPoints() > 0)
}
/** 遍历全量英雄,判定是否存在可升级者(未满级且碎片充足) */
private hasUpgradableHero(): boolean {
for (const uuid of HeroList) {
const growth = smc.getHeroGrowth(uuid);
if (canHeroUpgrade(growth.lv, growth.fragments)) return true;
}
return false;
}
/** 切换按钮下 red_dot 子节点的显示 */
private setRedDot(btn: Node, active: boolean) {
if (!btn || !btn.isValid) return
const dot = btn.getChildByName("red_dot")
if (dot) dot.active = active
}
openRanks() {
this.showPage(this.ranks_page)
}
@@ -254,6 +292,7 @@ export class MissionHomeComp extends CCComp {
this.stopStartGuide();
this.uodate_data()
this.hideAllPages()
this.refreshRedDots()
this.node.active = true
// 播放主页背景音乐,恢复默认音量
oops.audio.volumeMusic = 1.0;