From 1c36718876447168f8ec738adf0f3a03d362d037 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 20:21:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=B7=BB=E5=8A=A0=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E7=95=8C=E9=9D=A2=E5=B9=B6=E9=9B=86=E6=88=90=E5=88=B0?= =?UTF-8?q?=E8=83=9C=E5=88=A9=E5=9C=BA=E6=99=AF=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在胜利场景中添加新的加载界面元素,包括: 1. 创建loading.prefab资源文件 2. 在MissionHomeComp中处理MissionStart事件 3. 在VictoryComp中控制loading节点的显示逻辑 4. 更新victory.prefab结构以包含loading节点 --- assets/resources/gui/element/loading.prefab | 506 ++++++++++++++++++ .../resources/gui/element/loading.prefab.meta | 13 + assets/resources/gui/element/victory.prefab | 251 ++++++++- assets/script/game/map/MissionHomeComp.ts | 4 + assets/script/game/map/VictoryComp.ts | 4 + 5 files changed, 766 insertions(+), 12 deletions(-) create mode 100644 assets/resources/gui/element/loading.prefab create mode 100644 assets/resources/gui/element/loading.prefab.meta diff --git a/assets/resources/gui/element/loading.prefab b/assets/resources/gui/element/loading.prefab new file mode 100644 index 00000000..bc5fb784 --- /dev/null +++ b/assets/resources/gui/element/loading.prefab @@ -0,0 +1,506 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "loading", + "_objFlags": 0, + "__editorExtras__": {}, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "persistent": false + }, + { + "__type__": "cc.Node", + "_name": "loading", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 10 + } + ], + "_active": false, + "_components": [ + { + "__id__": 22 + }, + { + "__id__": 24 + }, + { + "__id__": 26 + } + ], + "_prefab": { + "__id__": 28 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 640, + "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": "bg1", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 9 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -650, + "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__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 4 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 740, + "height": 1300 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "9d1lAxVeZJsI6hfgmn16l0" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 6 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73@2ef13", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 1, + "_fillType": 0, + "_sizeMode": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_useGrayscale": false, + "_atlas": { + "__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73", + "__expectedType__": "cc.SpriteAtlas" + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "b1XGKSWqlF/Yf7yyv3neih" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 8 + }, + "_alignFlags": 45, + "_target": null, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 20, + "_originalHeight": 20, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "3djIeuqDpPZbBlEA+Wmqzv" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "bblW/bQxdMP5lraMnWpYVC", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.Node", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_prefab": { + "__id__": 11 + }, + "__editorExtras__": {} + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 10 + }, + "asset": { + "__uuid__": "9cc71d8c-192a-4234-8204-352f42b95c65", + "__expectedType__": "cc.Prefab" + }, + "fileId": "a0daVw8DRLi6ToMaTA0VS2", + "instance": { + "__id__": 12 + }, + "targetOverrides": null + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "7eQv5ppk1Hpr0USxE6y7Ww", + "prefabRootNode": { + "__id__": 1 + }, + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 13 + }, + { + "__id__": 15 + }, + { + "__id__": 16 + }, + { + "__id__": 17 + }, + { + "__id__": 18 + }, + { + "__id__": 20 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 14 + }, + "propertyPath": [ + "_name" + ], + "value": "netinstable" + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "a0daVw8DRLi6ToMaTA0VS2" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 14 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 14 + }, + "propertyPath": [ + "_lrot" + ], + "value": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 14 + }, + "propertyPath": [ + "_euler" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 19 + }, + "propertyPath": [ + "_contentSize" + ], + "value": { + "__type__": "cc.Size", + "width": 740, + "height": 1300 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "77N2cid5pKDpXplRH/AWEU" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 21 + }, + "propertyPath": [ + "_contentSize" + ], + "value": { + "__type__": "cc.Size", + "width": 740, + "height": 1300 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "fbb9ezFuVDaKU7Tqqncexy" + ] + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 23 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 740, + "height": 1300 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5f/wlde7xDGqRmc4TaTJHZ" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 25 + }, + "_alignFlags": 45, + "_target": null, + "_left": -10, + "_right": -10, + "_top": -10, + "_bottom": -10, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 100, + "_originalHeight": 100, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "cenzbCwmZE56xRaac3dhPZ" + }, + { + "__type__": "cc.BlockInputEvents", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 27 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "91NOQbZ0pEZpdUsC/eNF62" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "5a9CMsVQhKP5Y+UJfTKPbx", + "targetOverrides": null, + "nestedPrefabInstanceRoots": [ + { + "__id__": 10 + } + ] + } +] \ No newline at end of file diff --git a/assets/resources/gui/element/loading.prefab.meta b/assets/resources/gui/element/loading.prefab.meta new file mode 100644 index 00000000..e8a3c7c3 --- /dev/null +++ b/assets/resources/gui/element/loading.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.50", + "importer": "prefab", + "imported": true, + "uuid": "26bff847-cd29-48a5-bbfa-c3e2dbda688d", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "loading" + } +} diff --git a/assets/resources/gui/element/victory.prefab b/assets/resources/gui/element/victory.prefab index 746bf400..e31a2d43 100644 --- a/assets/resources/gui/element/victory.prefab +++ b/assets/resources/gui/element/victory.prefab @@ -26,28 +26,31 @@ }, { "__id__": 36 + }, + { + "__id__": 89 } ], "_active": true, "_components": [ { - "__id__": 89 + "__id__": 106 }, { - "__id__": 91 + "__id__": 108 }, { - "__id__": 93 + "__id__": 110 }, { - "__id__": 95 + "__id__": 112 }, { - "__id__": 97 + "__id__": 114 } ], "_prefab": { - "__id__": 99 + "__id__": 116 }, "_lpos": { "__type__": "cc.Vec3", @@ -2172,6 +2175,225 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_prefab": { + "__id__": 90 + }, + "__editorExtras__": {} + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 89 + }, + "asset": { + "__uuid__": "26bff847-cd29-48a5-bbfa-c3e2dbda688d", + "__expectedType__": "cc.Prefab" + }, + "fileId": "5a9CMsVQhKP5Y+UJfTKPbx", + "instance": { + "__id__": 91 + }, + "targetOverrides": null + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "baAcuO8pBEOJtTY5r2CdgQ", + "prefabRootNode": { + "__id__": 1 + }, + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 92 + }, + { + "__id__": 94 + }, + { + "__id__": 95 + }, + { + "__id__": 96 + }, + { + "__id__": 97 + }, + { + "__id__": 98 + }, + { + "__id__": 100 + }, + { + "__id__": 102 + }, + { + "__id__": 104 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 93 + }, + "propertyPath": [ + "_name" + ], + "value": "loading" + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "5a9CMsVQhKP5Y+UJfTKPbx" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 93 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 93 + }, + "propertyPath": [ + "_lrot" + ], + "value": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 93 + }, + "propertyPath": [ + "_euler" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 93 + }, + "propertyPath": [ + "_active" + ], + "value": false + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 99 + }, + "propertyPath": [ + "_contentSize" + ], + "value": { + "__type__": "cc.Size", + "width": 740.0000000000006, + "height": 1300 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "5f/wlde7xDGqRmc4TaTJHZ" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 101 + }, + "propertyPath": [ + "_contentSize" + ], + "value": { + "__type__": "cc.Size", + "width": 740.0000000000006, + "height": 1300 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "9d1lAxVeZJsI6hfgmn16l0" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 103 + }, + "propertyPath": [ + "_contentSize" + ], + "value": { + "__type__": "cc.Size", + "width": 740.0000000000006, + "height": 1300 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "7eQv5ppk1Hpr0USxE6y7Ww", + "77N2cid5pKDpXplRH/AWEU" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 105 + }, + "propertyPath": [ + "_contentSize" + ], + "value": { + "__type__": "cc.Size", + "width": 740.0000000000006, + "height": 1300 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "7eQv5ppk1Hpr0USxE6y7Ww", + "fbb9ezFuVDaKU7Tqqncexy" + ] + }, { "__type__": "cc.UITransform", "_name": "", @@ -2182,7 +2404,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 90 + "__id__": 107 }, "_contentSize": { "__type__": "cc.Size", @@ -2210,7 +2432,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 92 + "__id__": 109 }, "_id": "" }, @@ -2228,7 +2450,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 94 + "__id__": 111 }, "_alignFlags": 45, "_target": null, @@ -2264,7 +2486,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 96 + "__id__": 113 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2306,7 +2528,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 98 + "__id__": 115 }, "_id": "" }, @@ -2324,6 +2546,11 @@ }, "fileId": "d0FqR3MNdHHKbJYj7BXmc4", "instance": null, - "targetOverrides": null + "targetOverrides": null, + "nestedPrefabInstanceRoots": [ + { + "__id__": 89 + } + ] } ] \ No newline at end of file diff --git a/assets/script/game/map/MissionHomeComp.ts b/assets/script/game/map/MissionHomeComp.ts index 5441f095..2b413a1b 100644 --- a/assets/script/game/map/MissionHomeComp.ts +++ b/assets/script/game/map/MissionHomeComp.ts @@ -14,6 +14,7 @@ const { ccclass, property } = _decorator; export class MissionHomeComp extends CCComp { protected onLoad(): void { this.on(GameEvent.MissionEnd,this.mission_end,this) + this.on(GameEvent.MissionStart,this.mission_start,this) } /** 视图层逻辑代码分离演示 */ start() { @@ -31,6 +32,9 @@ export class MissionHomeComp extends CCComp { console.log("[MissionHomeComp]=>mission_end") this.home_active() } + mission_start(){ + this.node.active=false + } home_active(){ this.uodate_data() this.node.active=true diff --git a/assets/script/game/map/VictoryComp.ts b/assets/script/game/map/VictoryComp.ts index ec8f7a2d..4af40988 100644 --- a/assets/script/game/map/VictoryComp.ts +++ b/assets/script/game/map/VictoryComp.ts @@ -32,11 +32,13 @@ export class VictoryComp extends CCComp { /** 视图层逻辑代码分离演示 */ protected onLoad(): void { + this.node.getChildByName("loading").active=false // this.canRevive = true; // this.reviveCount = 0; } onAdded(args: any) { + this.node.getChildByName("loading").active=false console.log("[VictoryComp] onAdded",args) if(args.game_data){ this.game_data=args.game_data @@ -142,8 +144,10 @@ export class VictoryComp extends CCComp { this.clear_data() // 确保游戏结束事件被触发,以便重置状态 oops.message.dispatchEvent(GameEvent.MissionEnd) + this.node.getChildByName("loading").active=true this.scheduleOnce(()=>{ oops.message.dispatchEvent(GameEvent.MissionStart) + this.node.getChildByName("loading").active=false oops.gui.removeByNode(this.node) },0.5) }