feat: 优化分享模式通关判定逻辑
This commit is contained in:
@@ -40,7 +40,7 @@ Git 历史采用 Conventional Commits,且摘要多为中文,例如 `feat:
|
|||||||
<claude-mem-context>
|
<claude-mem-context>
|
||||||
# Memory Context
|
# Memory Context
|
||||||
|
|
||||||
# $CMEM mp-xieyingeng 2026-05-10 9:35pm GMT+8
|
# $CMEM mp-xieyingeng 2026-05-10 10:19pm GMT+8
|
||||||
|
|
||||||
Legend: 🎯session 🔴bugfix 🟣feature 🔄refactor ✅change 🔵discovery ⚖️decision
|
Legend: 🎯session 🔴bugfix 🟣feature 🔄refactor ✅change 🔵discovery ⚖️decision
|
||||||
Format: ID TIME TYPE TITLE
|
Format: ID TIME TYPE TITLE
|
||||||
|
|||||||
@@ -711,7 +711,6 @@ export class PageLevel extends BaseView {
|
|||||||
|
|
||||||
private tryAutoSubmitAnswer(): void {
|
private tryAutoSubmitAnswer(): void {
|
||||||
if (!this._currentConfig || this._isTransitioning) return;
|
if (!this._currentConfig || this._isTransitioning) return;
|
||||||
if (this._isShareMode) return;
|
|
||||||
|
|
||||||
const values = this.getInputValues();
|
const values = this.getInputValues();
|
||||||
const isFilled = values.length === Array.from(this._currentConfig.answer ?? '').length && values.every(value => value.length === 1);
|
const isFilled = values.length === Array.from(this._currentConfig.answer ?? '').length && values.every(value => value.length === 1);
|
||||||
@@ -1655,12 +1654,10 @@ export class PageLevel extends BaseView {
|
|||||||
const userAnswer = this.getAnswer();
|
const userAnswer = this.getAnswer();
|
||||||
console.log(`[PageLevel] 提交答案: ${userAnswer}, 正确答案: ${this._currentConfig.answer}`);
|
console.log(`[PageLevel] 提交答案: ${userAnswer}, 正确答案: ${this._currentConfig.answer}`);
|
||||||
|
|
||||||
if (this._isShareMode) {
|
|
||||||
void this._submitShareAnswerAndContinue(userAnswer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userAnswer === this._currentConfig.answer) {
|
if (userAnswer === this._currentConfig.answer) {
|
||||||
|
if (this._isShareMode) {
|
||||||
|
this._recordCurrentShareSubmission(userAnswer);
|
||||||
|
}
|
||||||
// 答案正确,只播放成功音效(不播放点击音效,避免重合)
|
// 答案正确,只播放成功音效(不播放点击音效,避免重合)
|
||||||
this.showSuccess();
|
this.showSuccess();
|
||||||
} else {
|
} else {
|
||||||
@@ -1700,37 +1697,10 @@ export class PageLevel extends BaseView {
|
|||||||
// 不论是否有谐音梗,都停留固定时间,保证玩家能看到答案反馈
|
// 不论是否有谐音梗,都停留固定时间,保证玩家能看到答案反馈
|
||||||
await this.delay(PageLevel.PASS_MODAL_DELAY_MS);
|
await this.delay(PageLevel.PASS_MODAL_DELAY_MS);
|
||||||
|
|
||||||
if (this._isShareMode) {
|
|
||||||
if (this._isFinalShareLevel()) {
|
|
||||||
await this._showShareEndPage();
|
|
||||||
} else {
|
|
||||||
await this.goToNextLevel();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示通关弹窗
|
// 显示通关弹窗
|
||||||
this._showPassModal();
|
this._showPassModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _submitShareAnswerAndContinue(userAnswer: string): Promise<void> {
|
|
||||||
if (!this._currentConfig || this._isTransitioning || this._isSubmittingShareResult) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._isTransitioning = true;
|
|
||||||
this.stopCountdown();
|
|
||||||
this.hidePunchline();
|
|
||||||
this._recordCurrentShareSubmission(userAnswer);
|
|
||||||
|
|
||||||
if (this._isFinalShareLevel()) {
|
|
||||||
await this._showShareEndPage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.goToNextLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private getValidPunchline(punchline: string | null): string | null {
|
private getValidPunchline(punchline: string | null): string | null {
|
||||||
if (!punchline?.trim()) {
|
if (!punchline?.trim()) {
|
||||||
return null;
|
return null;
|
||||||
@@ -2030,7 +2000,8 @@ export class PageLevel extends BaseView {
|
|||||||
const timeoutModal = modalNode.getComponent(TimeoutModal);
|
const timeoutModal = modalNode.getComponent(TimeoutModal);
|
||||||
if (timeoutModal) {
|
if (timeoutModal) {
|
||||||
timeoutModal.setParams({
|
timeoutModal.setParams({
|
||||||
levelIndex: this.getDisplayLevelNumber()
|
levelIndex: this.getDisplayLevelNumber(),
|
||||||
|
shareMode: this._isShareMode,
|
||||||
});
|
});
|
||||||
timeoutModal.setCallbacks({
|
timeoutModal.setCallbacks({
|
||||||
onShare: () => {
|
onShare: () => {
|
||||||
@@ -2042,6 +2013,11 @@ export class PageLevel extends BaseView {
|
|||||||
console.error('[PageLevel] 重新进入关卡失败:', err);
|
console.error('[PageLevel] 重新进入关卡失败:', err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onNext: () => {
|
||||||
|
this._closeTimeoutModal();
|
||||||
|
this._recordCurrentShareSubmission();
|
||||||
|
void this.goToNextLevel();
|
||||||
|
},
|
||||||
onHome: () => {
|
onHome: () => {
|
||||||
this._closeTimeoutModal();
|
this._closeTimeoutModal();
|
||||||
if (this._isShareMode) {
|
if (this._isShareMode) {
|
||||||
|
|||||||
@@ -213,11 +213,9 @@ export class PassModal extends BaseModal {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const audioSource = this.node.getComponent(AudioSource);
|
const audioSource = this.node.getComponent(AudioSource) ?? this.node.addComponent(AudioSource);
|
||||||
if (audioSource) {
|
|
||||||
audioSource.playOneShot(this.successAudio);
|
audioSource.playOneShot(this.successAudio);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用当前 _titleInfo 刷新视图(称号、进度条、进度文案)
|
* 用当前 _titleInfo 刷新视图(称号、进度条、进度文案)
|
||||||
|
|||||||
@@ -28,17 +28,17 @@
|
|||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 114
|
"__id__": 136
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 116
|
"__id__": 138
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 118
|
"__id__": 140
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": {
|
"_prefab": {
|
||||||
"__id__": 120
|
"__id__": 142
|
||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
@@ -270,19 +270,22 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 85
|
"__id__": 85
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 109
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 109
|
"__id__": 131
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 111
|
"__id__": 133
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": {
|
"_prefab": {
|
||||||
"__id__": 113
|
"__id__": 135
|
||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
@@ -2646,6 +2649,545 @@
|
|||||||
"targetOverrides": null,
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "ButtonNext",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 10
|
||||||
|
},
|
||||||
|
"_children": [
|
||||||
|
{
|
||||||
|
"__id__": 110
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 118
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 124
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 126
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 128
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 130
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": -656.544,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_lrot": {
|
||||||
|
"__type__": "cc.Quat",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_lscale": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 1,
|
||||||
|
"y": 1,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"_mobility": 0,
|
||||||
|
"_layer": 1073741824,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "Label",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 109
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 111
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 113
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 115
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 117
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 49.166,
|
||||||
|
"y": 7.598,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_lrot": {
|
||||||
|
"__type__": "cc.Quat",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_lscale": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 1,
|
||||||
|
"y": 1,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"_mobility": 0,
|
||||||
|
"_layer": 1073741824,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 110
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 112
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 250,
|
||||||
|
"height": 136
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "5cJMgtHxZC2bMNF2M/+dQ2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Label",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 110
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 114
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_string": "下一题",
|
||||||
|
"_horizontalAlign": 1,
|
||||||
|
"_verticalAlign": 1,
|
||||||
|
"_actualFontSize": 80,
|
||||||
|
"_fontSize": 80,
|
||||||
|
"_fontFamily": "Arial",
|
||||||
|
"_lineHeight": 100,
|
||||||
|
"_overflow": 0,
|
||||||
|
"_enableWrapText": true,
|
||||||
|
"_font": {
|
||||||
|
"__uuid__": "fb4acba6-6bc7-4eb3-be34-8f2ac9823a80",
|
||||||
|
"__expectedType__": "cc.TTFFont"
|
||||||
|
},
|
||||||
|
"_isSystemFontUsed": false,
|
||||||
|
"_spacingX": 0,
|
||||||
|
"_isItalic": false,
|
||||||
|
"_isBold": true,
|
||||||
|
"_isUnderline": false,
|
||||||
|
"_underlineHeight": 2,
|
||||||
|
"_cacheMode": 0,
|
||||||
|
"_enableOutline": true,
|
||||||
|
"_outlineColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 74,
|
||||||
|
"g": 153,
|
||||||
|
"b": 38,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_outlineWidth": 5,
|
||||||
|
"_enableShadow": false,
|
||||||
|
"_shadowColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 0,
|
||||||
|
"g": 0,
|
||||||
|
"b": 0,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_shadowOffset": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 2,
|
||||||
|
"y": 2
|
||||||
|
},
|
||||||
|
"_shadowBlur": 2,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "41omOoOSxFeIx6Ortmh+kF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Widget",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 110
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 116
|
||||||
|
},
|
||||||
|
"_alignFlags": 18,
|
||||||
|
"_target": null,
|
||||||
|
"_left": 0,
|
||||||
|
"_right": 0,
|
||||||
|
"_top": 0,
|
||||||
|
"_bottom": 0,
|
||||||
|
"_horizontalCenter": 49.166,
|
||||||
|
"_verticalCenter": 7.598,
|
||||||
|
"_isAbsLeft": true,
|
||||||
|
"_isAbsRight": true,
|
||||||
|
"_isAbsTop": true,
|
||||||
|
"_isAbsBottom": true,
|
||||||
|
"_isAbsHorizontalCenter": true,
|
||||||
|
"_isAbsVerticalCenter": true,
|
||||||
|
"_originalWidth": 0,
|
||||||
|
"_originalHeight": 0,
|
||||||
|
"_alignMode": 2,
|
||||||
|
"_lockFlags": 0,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "96ZDIo7hZHRaFDyjySJRpK"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "32g7Wv2cFCSLeRoG8Z0oLW",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "flatIconNext",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 109
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 119
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 121
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 123
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": -171.99,
|
||||||
|
"y": 5.432,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_lrot": {
|
||||||
|
"__type__": "cc.Quat",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_lscale": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0.2,
|
||||||
|
"y": 0.2,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"_mobility": 0,
|
||||||
|
"_layer": 1073741824,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 118
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 120
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 490,
|
||||||
|
"height": 492
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "baNH5M4YdCjqLtWEvYvS5o"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Sprite",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 118
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 122
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_spriteFrame": {
|
||||||
|
"__uuid__": "86bc53aa-3088-4af8-bda7-d3ad2f709922@f9941",
|
||||||
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
|
},
|
||||||
|
"_type": 0,
|
||||||
|
"_fillType": 0,
|
||||||
|
"_sizeMode": 0,
|
||||||
|
"_fillCenter": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_fillStart": 0,
|
||||||
|
"_fillRange": 0,
|
||||||
|
"_isTrimmedMode": true,
|
||||||
|
"_useGrayscale": false,
|
||||||
|
"_atlas": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "7dBIuDrLFK+KVuJ0YfQdHR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "50qNdubeJFALomx5o7tz4K",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 109
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 125
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 1200,
|
||||||
|
"height": 234
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "a3FUBQ/oNAP7NyCWcw+cPb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Sprite",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 109
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 127
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_spriteFrame": {
|
||||||
|
"__uuid__": "f87d228a-c520-499a-bf3a-e66cbb6def64@f9941",
|
||||||
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
|
},
|
||||||
|
"_type": 1,
|
||||||
|
"_fillType": 0,
|
||||||
|
"_sizeMode": 0,
|
||||||
|
"_fillCenter": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_fillStart": 0,
|
||||||
|
"_fillRange": 0,
|
||||||
|
"_isTrimmedMode": false,
|
||||||
|
"_useGrayscale": false,
|
||||||
|
"_atlas": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "c5QVPkh0xB7ZjNMPm/HnZ4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Button",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 109
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 129
|
||||||
|
},
|
||||||
|
"clickEvents": [],
|
||||||
|
"_interactable": true,
|
||||||
|
"_transition": 3,
|
||||||
|
"_normalColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_hoverColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 211,
|
||||||
|
"g": 211,
|
||||||
|
"b": 211,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_pressedColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_disabledColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 124,
|
||||||
|
"g": 124,
|
||||||
|
"b": 124,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_normalSprite": null,
|
||||||
|
"_hoverSprite": null,
|
||||||
|
"_pressedSprite": null,
|
||||||
|
"_disabledSprite": null,
|
||||||
|
"_duration": 0.1,
|
||||||
|
"_zoomScale": 1.2,
|
||||||
|
"_target": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "595KyRqElPS7nG4GQmOF0i"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "c25DEYrTdGBqtGNoSUPy2z",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.UITransform",
|
"__type__": "cc.UITransform",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
@@ -2656,7 +3198,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 110
|
"__id__": 132
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
@@ -2684,7 +3226,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 112
|
"__id__": 134
|
||||||
},
|
},
|
||||||
"_customMaterial": null,
|
"_customMaterial": null,
|
||||||
"_srcBlendFactor": 2,
|
"_srcBlendFactor": 2,
|
||||||
@@ -2742,7 +3284,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 115
|
"__id__": 137
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
@@ -2770,7 +3312,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 117
|
"__id__": 139
|
||||||
},
|
},
|
||||||
"_alignFlags": 45,
|
"_alignFlags": 45,
|
||||||
"_target": null,
|
"_target": null,
|
||||||
@@ -2806,7 +3348,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 119
|
"__id__": 141
|
||||||
},
|
},
|
||||||
"animationNodes": [],
|
"animationNodes": [],
|
||||||
"backdropNode": null,
|
"backdropNode": null,
|
||||||
@@ -2821,6 +3363,9 @@
|
|||||||
"buttonRestart": {
|
"buttonRestart": {
|
||||||
"__id__": 63
|
"__id__": 63
|
||||||
},
|
},
|
||||||
|
"buttonNext": {
|
||||||
|
"__id__": 109
|
||||||
|
},
|
||||||
"buttonHome": {
|
"buttonHome": {
|
||||||
"__id__": 85
|
"__id__": 85
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,12 +11,15 @@ export interface TimeoutModalCallbacks {
|
|||||||
onShare?: () => void;
|
onShare?: () => void;
|
||||||
/** 点击再次挑战回调 */
|
/** 点击再次挑战回调 */
|
||||||
onRestart?: () => void;
|
onRestart?: () => void;
|
||||||
|
/** 点击下一题回调 */
|
||||||
|
onNext?: () => void;
|
||||||
/** 点击返回主页 / 关闭按钮回调 */
|
/** 点击返回主页 / 关闭按钮回调 */
|
||||||
onHome?: () => void;
|
onHome?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TimeoutModalParams {
|
interface TimeoutModalParams {
|
||||||
levelIndex?: number;
|
levelIndex?: number;
|
||||||
|
shareMode?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +43,10 @@ export class TimeoutModal extends BaseModal {
|
|||||||
@property(Node)
|
@property(Node)
|
||||||
buttonRestart: Node | null = null;
|
buttonRestart: Node | null = null;
|
||||||
|
|
||||||
|
/** 下一题按钮(分享挑战超时时显示) */
|
||||||
|
@property(Node)
|
||||||
|
buttonNext: Node | null = null;
|
||||||
|
|
||||||
/** 返回主页按钮 */
|
/** 返回主页按钮 */
|
||||||
@property(Node)
|
@property(Node)
|
||||||
buttonHome: Node | null = null;
|
buttonHome: Node | null = null;
|
||||||
@@ -62,7 +69,9 @@ export class TimeoutModal extends BaseModal {
|
|||||||
*/
|
*/
|
||||||
onViewLoad(): void {
|
onViewLoad(): void {
|
||||||
console.log('[TimeoutModal] onViewLoad');
|
console.log('[TimeoutModal] onViewLoad');
|
||||||
|
this._resolveNodes();
|
||||||
this._bindButtonEvents();
|
this._bindButtonEvents();
|
||||||
|
this._refreshModeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,6 +80,7 @@ export class TimeoutModal extends BaseModal {
|
|||||||
onViewShow(): void {
|
onViewShow(): void {
|
||||||
super.onViewShow();
|
super.onViewShow();
|
||||||
this._updateWidget();
|
this._updateWidget();
|
||||||
|
this._refreshModeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,6 +117,9 @@ export class TimeoutModal extends BaseModal {
|
|||||||
if (this.buttonRestart) {
|
if (this.buttonRestart) {
|
||||||
this.buttonRestart.on(Node.EventType.TOUCH_END, this._onRestartClick, this);
|
this.buttonRestart.on(Node.EventType.TOUCH_END, this._onRestartClick, this);
|
||||||
}
|
}
|
||||||
|
if (this.buttonNext) {
|
||||||
|
this.buttonNext.on(Node.EventType.TOUCH_END, this._onNextClick, this);
|
||||||
|
}
|
||||||
if (this.buttonHome) {
|
if (this.buttonHome) {
|
||||||
this.buttonHome.on(Node.EventType.TOUCH_END, this._onHomeClick, this);
|
this.buttonHome.on(Node.EventType.TOUCH_END, this._onHomeClick, this);
|
||||||
}
|
}
|
||||||
@@ -125,11 +138,32 @@ export class TimeoutModal extends BaseModal {
|
|||||||
if (this.buttonRestart && this.buttonRestart.isValid) {
|
if (this.buttonRestart && this.buttonRestart.isValid) {
|
||||||
this.buttonRestart.off(Node.EventType.TOUCH_END, this._onRestartClick, this);
|
this.buttonRestart.off(Node.EventType.TOUCH_END, this._onRestartClick, this);
|
||||||
}
|
}
|
||||||
|
if (this.buttonNext && this.buttonNext.isValid) {
|
||||||
|
this.buttonNext.off(Node.EventType.TOUCH_END, this._onNextClick, this);
|
||||||
|
}
|
||||||
if (this.buttonHome && this.buttonHome.isValid) {
|
if (this.buttonHome && this.buttonHome.isValid) {
|
||||||
this.buttonHome.off(Node.EventType.TOUCH_END, this._onHomeClick, this);
|
this.buttonHome.off(Node.EventType.TOUCH_END, this._onHomeClick, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _resolveNodes(): void {
|
||||||
|
this.closeBtn = this.closeBtn ?? this._findChild(this.node, 'closeBtn');
|
||||||
|
this.buttonShare = this.buttonShare ?? this._findChild(this.node, 'ButtonShare');
|
||||||
|
this.buttonRestart = this.buttonRestart ?? this._findChild(this.node, 'ButtonRestart');
|
||||||
|
this.buttonNext = this.buttonNext ?? this._findChild(this.node, 'ButtonNext');
|
||||||
|
this.buttonHome = this.buttonHome ?? this._findChild(this.node, 'ButtonHome');
|
||||||
|
}
|
||||||
|
|
||||||
|
private _refreshModeButtons(): void {
|
||||||
|
const isShareMode = this._params?.shareMode === true;
|
||||||
|
if (this.buttonRestart) {
|
||||||
|
this.buttonRestart.active = !isShareMode;
|
||||||
|
}
|
||||||
|
if (this.buttonNext) {
|
||||||
|
this.buttonNext.active = isShareMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 求助好友按钮点击
|
* 求助好友按钮点击
|
||||||
*/
|
*/
|
||||||
@@ -152,6 +186,14 @@ export class TimeoutModal extends BaseModal {
|
|||||||
this._callbacks.onRestart?.();
|
this._callbacks.onRestart?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下一题按钮点击
|
||||||
|
*/
|
||||||
|
private _onNextClick(): void {
|
||||||
|
console.log('[TimeoutModal] 点击下一题');
|
||||||
|
this._callbacks.onNext?.();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回主页 / 关闭按钮点击
|
* 返回主页 / 关闭按钮点击
|
||||||
*/
|
*/
|
||||||
@@ -159,4 +201,19 @@ export class TimeoutModal extends BaseModal {
|
|||||||
console.log('[TimeoutModal] 点击返回主页');
|
console.log('[TimeoutModal] 点击返回主页');
|
||||||
this._callbacks.onHome?.();
|
this._callbacks.onHome?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _findChild(root: Node, nodeName: string): Node | null {
|
||||||
|
if (root.name === nodeName) {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const child of root.children) {
|
||||||
|
const found = this._findChild(child, nodeName);
|
||||||
|
if (found) {
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user