feat: 支持关卡详情页 UI
This commit is contained in:
@@ -9471,6 +9471,36 @@
|
||||
"titleLevelLabel": {
|
||||
"__id__": 22
|
||||
},
|
||||
"bgNode": {
|
||||
"__id__": 2
|
||||
},
|
||||
"pkBgNode": {
|
||||
"__id__": 10
|
||||
},
|
||||
"titleLevelNode": {
|
||||
"__id__": 18
|
||||
},
|
||||
"pkTitleLevelNode": {
|
||||
"__id__": 32
|
||||
},
|
||||
"pkTitleLevelLabel": {
|
||||
"__id__": 36
|
||||
},
|
||||
"liveNode": {
|
||||
"__id__": 106
|
||||
},
|
||||
"pkLevelProgressNode": {
|
||||
"__id__": 130
|
||||
},
|
||||
"pkLevelProgressLabel": {
|
||||
"__id__": 140
|
||||
},
|
||||
"bottomLayoutNode": {
|
||||
"__id__": 248
|
||||
},
|
||||
"pkNextLevelButton": {
|
||||
"__id__": 364
|
||||
},
|
||||
"clickAudio": {
|
||||
"__uuid__": "a68a6314-fb7c-48a9-bd6c-0a65ef665d50",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
|
||||
@@ -132,6 +132,46 @@ export class PageLevel extends BaseView {
|
||||
@property(Label)
|
||||
titleLevelLabel: Label | null = null;
|
||||
|
||||
/** 普通模式背景 */
|
||||
@property(Node)
|
||||
bgNode: Node | null = null;
|
||||
|
||||
/** 分享 / PK 模式背景 */
|
||||
@property(Node)
|
||||
pkBgNode: Node | null = null;
|
||||
|
||||
/** 普通模式标题容器 */
|
||||
@property(Node)
|
||||
titleLevelNode: Node | null = null;
|
||||
|
||||
/** 分享 / PK 模式标题容器 */
|
||||
@property(Node)
|
||||
pkTitleLevelNode: Node | null = null;
|
||||
|
||||
/** 分享 / PK 模式标题标签 */
|
||||
@property(Label)
|
||||
pkTitleLevelLabel: Label | null = null;
|
||||
|
||||
/** 普通模式体力区域容器 */
|
||||
@property(Node)
|
||||
liveNode: Node | null = null;
|
||||
|
||||
/** 分享 / PK 模式进度容器 */
|
||||
@property(Node)
|
||||
pkLevelProgressNode: Node | null = null;
|
||||
|
||||
/** 分享 / PK 模式进度标签 */
|
||||
@property(Label)
|
||||
pkLevelProgressLabel: Label | null = null;
|
||||
|
||||
/** 普通模式底部按钮区域 */
|
||||
@property(Node)
|
||||
bottomLayoutNode: Node | null = null;
|
||||
|
||||
/** 分享 / PK 模式底部下一题按钮 */
|
||||
@property(Node)
|
||||
pkNextLevelButton: Node | null = null;
|
||||
|
||||
// ========== 配置属性 ==========
|
||||
@property(AudioClip)
|
||||
clickAudio: AudioClip | null = null;
|
||||
@@ -273,10 +313,12 @@ export class PageLevel extends BaseView {
|
||||
}
|
||||
}
|
||||
|
||||
this._refreshModeUI();
|
||||
this.updateStaminaLabel();
|
||||
this.initIconSetting();
|
||||
this.initUnlockButtons();
|
||||
this.initSubmitButton();
|
||||
this.initPkNextLevelButton();
|
||||
|
||||
// 异步加载关卡资源并调用进入关卡接口,完成后启动倒计时
|
||||
this._enterAndInitLevel().catch(err => {
|
||||
@@ -289,8 +331,11 @@ export class PageLevel extends BaseView {
|
||||
*/
|
||||
onViewShow(): void {
|
||||
console.log('[PageLevel] onViewShow');
|
||||
this._refreshModeUI();
|
||||
this.updateStaminaLabel();
|
||||
this._startStaminaRecoverTimer();
|
||||
if (!this._isShareMode) {
|
||||
this._startStaminaRecoverTimer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,6 +364,7 @@ export class PageLevel extends BaseView {
|
||||
this.unLockTipsBtn?.off(Node.EventType.TOUCH_END);
|
||||
this.addTimeBtn?.off(Node.EventType.TOUCH_END);
|
||||
this.submitButton?.off(Node.EventType.TOUCH_END, this.onSubmitAnswer, this);
|
||||
this.pkNextLevelButton?.off(Node.EventType.TOUCH_END, this.onPkNextLevelClick, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,6 +474,7 @@ export class PageLevel extends BaseView {
|
||||
|
||||
// 设置关卡标题
|
||||
this.updateTitleLevelLabel();
|
||||
this.updatePkLevelProgressLabel();
|
||||
|
||||
// 隐藏包袱答案,通关后再按 punchline 展示
|
||||
this.hidePunchline();
|
||||
@@ -853,6 +900,24 @@ export class PageLevel extends BaseView {
|
||||
console.log('[PageLevel] 提交按钮事件已绑定');
|
||||
}
|
||||
|
||||
private initPkNextLevelButton(): void {
|
||||
if (!this.pkNextLevelButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pkNextLevelButton.on(Node.EventType.TOUCH_END, this.onPkNextLevelClick, this);
|
||||
console.log('[PageLevel] PK 下一题按钮事件已绑定');
|
||||
}
|
||||
|
||||
private onPkNextLevelClick(): void {
|
||||
if (!this._isShareMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.playClickSound();
|
||||
void this.goToNextLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击解锁线索(顺序解锁:先线索2,再线索3;全部解锁后切换为查看答案入口)
|
||||
*/
|
||||
@@ -993,9 +1058,64 @@ export class PageLevel extends BaseView {
|
||||
}
|
||||
|
||||
private updateTitleLevelLabel(): void {
|
||||
if (!this.titleLevelLabel) return;
|
||||
const titleText = `第 ${this.getDisplayLevelNumber()} 关`;
|
||||
|
||||
this.titleLevelLabel.string = `第 ${this.getDisplayLevelNumber()} 关`;
|
||||
if (this.titleLevelLabel) {
|
||||
this.titleLevelLabel.string = titleText;
|
||||
}
|
||||
|
||||
if (this.pkTitleLevelLabel) {
|
||||
this.pkTitleLevelLabel.string = titleText;
|
||||
}
|
||||
}
|
||||
|
||||
private updatePkLevelProgressLabel(): void {
|
||||
if (!this.pkLevelProgressLabel) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._isShareMode) {
|
||||
this.pkLevelProgressLabel.string = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const totalLevels = ShareManager.instance.getShareLevelCount();
|
||||
const currentIndex = this._shareLevelIndex + 1;
|
||||
this.pkLevelProgressLabel.string = totalLevels > 0
|
||||
? `${currentIndex}/${totalLevels}`
|
||||
: `${currentIndex}`;
|
||||
}
|
||||
|
||||
private _refreshModeUI(): void {
|
||||
const isPkMode = this._isShareMode;
|
||||
|
||||
if (this.bgNode) {
|
||||
this.bgNode.active = !isPkMode;
|
||||
}
|
||||
if (this.pkBgNode) {
|
||||
this.pkBgNode.active = isPkMode;
|
||||
}
|
||||
if (this.titleLevelNode) {
|
||||
this.titleLevelNode.active = !isPkMode;
|
||||
}
|
||||
if (this.pkTitleLevelNode) {
|
||||
this.pkTitleLevelNode.active = isPkMode;
|
||||
}
|
||||
if (this.liveNode) {
|
||||
this.liveNode.active = !isPkMode;
|
||||
}
|
||||
if (this.pkLevelProgressNode) {
|
||||
this.pkLevelProgressNode.active = isPkMode;
|
||||
}
|
||||
if (this.bottomLayoutNode) {
|
||||
this.bottomLayoutNode.active = !isPkMode;
|
||||
}
|
||||
if (this.pkNextLevelButton) {
|
||||
this.pkNextLevelButton.active = isPkMode;
|
||||
}
|
||||
|
||||
this.updateTitleLevelLabel();
|
||||
this.updatePkLevelProgressLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1434,6 +1554,10 @@ export class PageLevel extends BaseView {
|
||||
* 更新体力值显示(仅值变化时更新 UI)
|
||||
*/
|
||||
private updateStaminaLabel(): void {
|
||||
if (this._isShareMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.liveLabel) {
|
||||
const stamina = StaminaManager.instance.getStamina();
|
||||
const maxStamina = this._getStaminaMax(stamina);
|
||||
@@ -1449,6 +1573,10 @@ export class PageLevel extends BaseView {
|
||||
* 启动体力恢复倒计时 UI
|
||||
*/
|
||||
private _startStaminaRecoverTimer(): void {
|
||||
if (this._isShareMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._stopStaminaRecoverTimer();
|
||||
|
||||
const stamina = StaminaManager.instance.getStamina();
|
||||
@@ -1889,6 +2017,8 @@ export class PageLevel extends BaseView {
|
||||
ViewManager.instance.replace('PageHome');
|
||||
return;
|
||||
}
|
||||
|
||||
this._refreshModeUI();
|
||||
} else {
|
||||
// 正常模式:使用 complete 返回的 nextLevel
|
||||
if (!this._nextLevelData) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user