feat: 添加回合进度指示 UI 组件及刷新逻辑
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
* - 第 5 节胜利 → open_Victory(final) 弹结算,确认退出并存档进下一关。
|
||||
* - cleanComponents() / clearBattlePools() 仅在整关开始/结束时执行,节间不调用。
|
||||
*/
|
||||
import { _decorator, Node, NodeEventType, Label, tween, v3, Tween, Widget } from "cc";
|
||||
import { _decorator, Node, NodeEventType, Label, tween, v3, Tween, Widget, Color, Sprite, ProgressBar } 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 { smc } from "../common/SingletonModuleComp";
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
getProgressText,
|
||||
getMonsterLv,
|
||||
BOSS_SECTION,
|
||||
SECTIONS_PER_STAGE,
|
||||
} from "../common/config/StageSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -93,6 +94,21 @@ export class MissionComp extends CCComp {
|
||||
@property(Node)
|
||||
tooltip: Node = null!
|
||||
|
||||
/** 回合指示节点(5 个,索引 0~4 对应回合 1~5),按回合进度染色 */
|
||||
@property({ type: [Node], tooltip: "回合指示节点(按回合 1~5 顺序绑定)" })
|
||||
round_nodes: Node[] = [];
|
||||
|
||||
/** 回合进度条:第 1 回合 0%,每推进一回合 +25%(第 5 回合满格) */
|
||||
@property({ type: ProgressBar, tooltip: "回合进度条(第 1 回合 0%,每回合 +25%)" })
|
||||
round_progress: ProgressBar = null!;
|
||||
|
||||
/** 回合指示:未激活(白色) */
|
||||
private static readonly ROUND_INACTIVE = new Color(255, 255, 255, 255);
|
||||
/** 回合指示:已激活(橙黄 #FFA300) */
|
||||
private static readonly ROUND_ACTIVE = new Color(255, 163, 0, 255);
|
||||
/** 回合指示:Boss 当前回合(红色) */
|
||||
private static readonly ROUND_BOSS = new Color(230, 60, 60, 255);
|
||||
|
||||
/** 阶段名称映射表(用于 UI 显示) */
|
||||
private static readonly PhaseNameMap: Record<MissionPhase, string> = {
|
||||
[MissionPhase.None]: "未开始",
|
||||
@@ -797,6 +813,7 @@ export class MissionComp extends CCComp {
|
||||
this.currentWave = 1;
|
||||
this.isBossWave = false;
|
||||
this.skipRemainScoreOnBattleEnd = false;
|
||||
this.updateRoundNodes();
|
||||
this.rewards = []
|
||||
this.revive_times = 1;
|
||||
this.lastTimeStr = "";
|
||||
@@ -909,12 +926,46 @@ export class MissionComp extends CCComp {
|
||||
|
||||
this.currentWave = wave;
|
||||
smc.vmdata.mission_data.level = wave;
|
||||
this.updateRoundNodes();
|
||||
// 金币改为怪物死亡掉落(见 HeroAtkSystem),不再每回合固定发放
|
||||
this.lastTimeSecond = -1;
|
||||
this.clearTime = 0;
|
||||
this.update_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新回合指示节点颜色:
|
||||
* - 已激活(已完成 + 当前回合)→ 黄色;当前回合且为 Boss 节 → 红色;未激活 → 白色。
|
||||
* Why: 回合推进时(onNewWave)与开局重置(data_init)调用,驱动 HUD 回合指示实时反馈。
|
||||
*/
|
||||
private updateRoundNodes() {
|
||||
const len = Math.min(this.round_nodes.length, SECTIONS_PER_STAGE);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const node = this.round_nodes[i];
|
||||
if (!node || !node.isValid) continue;
|
||||
const round = i + 1;
|
||||
const color = round > this.currentWave
|
||||
? MissionComp.ROUND_INACTIVE
|
||||
: (round === this.currentWave && this.isBossWave)
|
||||
? MissionComp.ROUND_BOSS
|
||||
: MissionComp.ROUND_ACTIVE;
|
||||
// 优先染色 Sprite(图标配色),无 Sprite 时退化到 Label,均无则跳过
|
||||
const sprite = node.getComponent(Sprite);
|
||||
if (sprite) {
|
||||
sprite.color = color;
|
||||
} else {
|
||||
const label = node.getComponent(Label);
|
||||
if (label) label.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
// 进度条:第 1 回合 0%,每推进一回合 +25%(第 5 回合满格)
|
||||
if (this.round_progress && this.round_progress.isValid) {
|
||||
this.round_progress.progress =
|
||||
Math.max(0, Math.min(SECTIONS_PER_STAGE, this.currentWave) - 1) / (SECTIONS_PER_STAGE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================== 怪物数量管理 ========================
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user