瀏覽代碼

启动场景

181404010226 1 月之前
父節點
當前提交
6988998fbd
共有 3 個文件被更改,包括 515 次插入126 次删除
  1. 488 15
      assets/Scenes/First.scene
  2. 0 1
      assets/scripts/CombatSystem/BlockManager.ts
  3. 27 110
      assets/scripts/LaunchScreen.ts

+ 488 - 15
assets/Scenes/First.scene

@@ -23,7 +23,7 @@
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 23
+      "__id__": 36
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -54,7 +54,7 @@
     },
     "autoReleaseAssets": false,
     "_globals": {
-      "__id__": 24
+      "__id__": 37
     },
     "_id": "fe370c6c-b377-4d05-b788-cd7ada03d5fb"
   },
@@ -77,13 +77,16 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 20
+        "__id__": 32
       },
       {
-        "__id__": 21
+        "__id__": 33
       },
       {
-        "__id__": 22
+        "__id__": 34
+      },
+      {
+        "__id__": 35
       }
     ],
     "_prefab": null,
@@ -224,15 +227,21 @@
       },
       {
         "__id__": 14
+      },
+      {
+        "__id__": 18
+      },
+      {
+        "__id__": 26
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 18
+        "__id__": 30
       },
       {
-        "__id__": 19
+        "__id__": 31
       }
     ],
     "_prefab": null,
@@ -714,6 +723,448 @@
     "_lockFlags": 0,
     "_id": "87VVpqjFlBdrLM0gGKy2sU"
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "ProgressBar",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 5
+    },
+    "_children": [
+      {
+        "__id__": 19
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 22
+      },
+      {
+        "__id__": 23
+      },
+      {
+        "__id__": 24
+      },
+      {
+        "__id__": 25
+      }
+    ],
+    "_prefab": null,
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": -353.527,
+      "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": "0fkwsMlEpP3pRepyNPCjK+"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Bar",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 18
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 20
+      },
+      {
+        "__id__": 21
+      }
+    ],
+    "_prefab": null,
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": -225.372,
+      "y": 0,
+      "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": "4fVPd5O9dFg5QbN+OChQ8M"
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 19
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 450,
+      "height": 15
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0.5
+    },
+    "_id": "77zEhuoBBMjISM5irM29Tk"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 19
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "fbe63d94-4bfc-4053-8a62-932adf1fdb2b@f9941",
+      "__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": null,
+    "_id": "aaWf3LGjZH+b8ro5UJOTxX"
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 18
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 450,
+      "height": 15
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": "faht5JgUZE9LOy0Tm312HL"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 18
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 7,
+      "g": 27,
+      "b": 5,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "bffbc0e8-bbbd-45e6-a933-1390b22f6947@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 1,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": true,
+    "_atlas": null,
+    "_id": "6dPuEJiUVFNbpGfZ7s27c6"
+  },
+  {
+    "__type__": "cc.ProgressBar",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 18
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_barSprite": {
+      "__id__": 21
+    },
+    "_mode": 0,
+    "_totalLength": 450,
+    "_progress": 1,
+    "_reverse": false,
+    "_id": "b4oPfUhLtAn6n55JIivl4x"
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 18
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_alignFlags": 16,
+    "_target": null,
+    "_left": 0,
+    "_right": 0,
+    "_top": 0,
+    "_bottom": 0,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": false,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 0,
+    "_originalHeight": 0,
+    "_alignMode": 2,
+    "_lockFlags": 0,
+    "_id": "ea2YY2Xn1JjpF159SPDfpR"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "label",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 5
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 27
+      },
+      {
+        "__id__": 28
+      },
+      {
+        "__id__": 29
+      }
+    ],
+    "_prefab": null,
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": -303.124,
+      "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": "fazhzxuV9FNbe1fgokf7j8"
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 26
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 500,
+      "height": 70
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": "f1m17prSFEVL0Vuj3HkEGz"
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 26
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_alignFlags": 17,
+    "_target": null,
+    "_left": 162.74,
+    "_right": 0,
+    "_top": 0.6640905752753978,
+    "_bottom": 0,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": false,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": false,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 0,
+    "_originalHeight": 0,
+    "_alignMode": 2,
+    "_lockFlags": 0,
+    "_id": "23EeuYpF9Po5TneNjlpB1f"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 26
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_string": "加 载 中...",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 36,
+    "_fontSize": 35,
+    "_fontFamily": "Adobe 黑体 Std",
+    "_lineHeight": 40,
+    "_overflow": 2,
+    "_enableWrapText": true,
+    "_font": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_isItalic": false,
+    "_isBold": true,
+    "_isUnderline": false,
+    "_underlineHeight": 2,
+    "_cacheMode": 0,
+    "_enableOutline": true,
+    "_outlineColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_outlineWidth": 2,
+    "_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": "c5V/iXUFJDeoAc2U+D4oRX"
+  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -834,6 +1285,28 @@
     "_lockFlags": 0,
     "_id": "c5V1EV8IpMtrIvY1OE9t2u"
   },
+  {
+    "__type__": "243b0bXHvNGN6K4LlyEPXc3",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "progressBar": {
+      "__id__": 24
+    },
+    "progressLabel": {
+      "__id__": 29
+    },
+    "backgroundSprite": {
+      "__id__": 9
+    },
+    "launchBackground": null,
+    "_id": "43fyDkSTFPpJhqPs0O/bn0"
+  },
   {
     "__type__": "cc.PrefabInfo",
     "root": null,
@@ -845,28 +1318,28 @@
   {
     "__type__": "cc.SceneGlobals",
     "ambient": {
-      "__id__": 25
+      "__id__": 38
     },
     "shadows": {
-      "__id__": 26
+      "__id__": 39
     },
     "_skybox": {
-      "__id__": 27
+      "__id__": 40
     },
     "fog": {
-      "__id__": 28
+      "__id__": 41
     },
     "octree": {
-      "__id__": 29
+      "__id__": 42
     },
     "skin": {
-      "__id__": 30
+      "__id__": 43
     },
     "lightProbeInfo": {
-      "__id__": 31
+      "__id__": 44
     },
     "postSettings": {
-      "__id__": 32
+      "__id__": 45
     },
     "bakedWithStationaryMainLight": false,
     "bakedWithHighpLightmap": false

+ 0 - 1
assets/scripts/CombatSystem/BlockManager.ts

@@ -625,7 +625,6 @@ export class BlockManager extends Component {
                 }
             }
         }
-        
         // 动态计算网格间距,适应不同分辨率
         this.calculateGridSpacing();
         

+ 27 - 110
assets/scripts/LaunchScreen.ts

@@ -68,8 +68,8 @@ export class LaunchScreen extends Component {
             // 更新进度显示
             this.updateProgress(0, '正在加载游戏资源...');
 
-            // 预加载game-level分包
-            await this.loadSubpackage('game-level');
+            // 直接预加载GameLevel场景(不使用分包)
+            await this.preloadGameLevelScene();
             
             // 预加载完成,跳转到游戏场景
             this.loadGameScene();
@@ -81,69 +81,23 @@ export class LaunchScreen extends Component {
     }
 
     /**
-     * 加载分包
+     * 直接预加载GameLevel场景
      */
-    private loadSubpackage(bundleName: string): Promise<void> {
-        return new Promise((resolve, reject) => {
-            console.log(`[LaunchScreen] 开始加载分包: ${bundleName}`);
+    private preloadGameLevelScene(): Promise<void> {
+        return new Promise<void>((resolve, reject) => {
+            console.log('[LaunchScreen] 开始预加载GameLevel场景');
             
-            // 检查是否在微信小游戏环境
-            if (typeof wx !== 'undefined' && wx && wx.loadSubpackage) {
-                // 微信小游戏分包加载
-                const loadTask = wx.loadSubpackage({
-                    name: bundleName,
-                    success: () => {
-                        console.log(`[LaunchScreen] 微信分包 ${bundleName} 加载成功`);
-                        // 分包加载成功后,再加载bundle
-                        this.loadBundleAfterSubpackage(bundleName, resolve, reject);
-                    },
-                    fail: (err) => {
-                        console.error(`[LaunchScreen] 微信分包 ${bundleName} 加载失败:`, err);
-                        // 微信分包加载失败时,尝试直接加载bundle作为降级方案
-                        console.log(`[LaunchScreen] 尝试直接加载bundle作为降级方案`);
-                        this.loadBundleAfterSubpackage(bundleName, resolve, reject);
-                    }
-                });
-                
-                // 监听分包加载进度
-                if (loadTask && loadTask.onProgressUpdate) {
-                    loadTask.onProgressUpdate((res) => {
-                        const progress = res.progress || 0;
-                        this.updateProgress(progress, `正在下载分包... ${progress}%`);
-                    });
-                }
-            } else {
-                // 非微信环境,直接加载bundle
-                console.log(`[LaunchScreen] 非微信环境,直接加载bundle`);
-                this.loadBundleAfterSubpackage(bundleName, resolve, reject);
-            }
-        });
-    }
-    
-    /**
-     * 分包下载完成后加载bundle
-     */
-    private loadBundleAfterSubpackage(bundleName: string, resolve: Function, reject: Function) {
-        assetManager.loadBundle(bundleName, (err, bundle) => {
-            if (err) {
-                console.error(`[LaunchScreen] Bundle ${bundleName} 加载失败:`, err);
-                // 如果bundle加载失败,尝试跳过分包直接进入主场景
-                console.log(`[LaunchScreen] Bundle加载失败,尝试跳过分包加载`);
-                this.skipSubpackageAndLoadMainScene(resolve, reject);
-                return;
-            }
-            
-            console.log(`[LaunchScreen] Bundle ${bundleName} 加载成功`);
-            
-            // 预加载分包中的场景
-            bundle.preloadScene('GameLevel', (finished: number, total: number) => {
+            // 直接预加载场景
+            director.preloadScene('GameLevel', (finished: number, total: number) => {
                 const progress = finished / total;
                 this.updateProgress(progress * 100, `正在加载游戏场景... ${Math.floor(progress * 100)}%`);
             }, (err) => {
                 if (err) {
                     console.error('[LaunchScreen] GameLevel场景预加载失败:', err);
-                    // 场景预加载失败时,也尝试跳过分包
-                    this.skipSubpackageAndLoadMainScene(resolve, reject);
+                    // 预加载失败时,仍然尝试直接跳转(可能场景存在但预加载失败)
+                    console.log('[LaunchScreen] 预加载失败,但仍将尝试直接加载场景');
+                    this.updateProgress(100, '准备进入游戏...');
+                    resolve();
                     return;
                 }
                 
@@ -169,26 +123,6 @@ export class LaunchScreen extends Component {
         console.log(`[LaunchScreen] ${message} (${progress.toFixed(1)}%)`);
     }
 
-    /**
-     * 跳过分包加载,直接进入主场景的降级方案
-     */
-    private skipSubpackageAndLoadMainScene(resolve: Function, reject: Function) {
-        console.log('[LaunchScreen] 执行降级方案:跳过分包,尝试加载主场景');
-        
-        // 尝试加载主场景(如果存在的话)
-        director.loadScene('First', (err) => {
-            if (err) {
-                console.error('[LaunchScreen] 主场景加载也失败:', err);
-                this.updateProgress(0, '游戏加载失败,请刷新重试');
-                reject(err);
-            } else {
-                console.log('[LaunchScreen] 成功加载主场景作为降级方案');
-                this.updateProgress(100, '加载完成(降级模式)');
-                resolve();
-            }
-        });
-    }
-
     /**
      * 跳转到游戏场景
      */
@@ -197,39 +131,22 @@ export class LaunchScreen extends Component {
         
         // 延迟一秒后跳转,让用户看到加载完成的提示
         this.scheduleOnce(() => {
-            // 使用分包中的场景
-            const bundle = assetManager.getBundle('game-level');
-            if (bundle) {
-                bundle.loadScene('GameLevel', (err, scene) => {
-                    if (err) {
-                        console.error('[LaunchScreen] GameLevel场景加载失败:', err);
-                        // 如果分包场景加载失败,尝试加载主场景
-                        this.loadFallbackScene();
-                        return;
-                    }
+            // 直接加载GameLevel场景
+            director.loadScene('GameLevel', (err) => {
+                if (err) {
+                    console.error('[LaunchScreen] GameLevel场景加载失败:', err);
+                    console.log('[LaunchScreen] 尝试降级方案:停留在启动页面');
+                    this.updateProgress(0, 'GameLevel场景不存在,请检查场景配置');
                     
-                    console.log('[LaunchScreen] 正在切换到GameLevel场景');
-                    director.runScene(scene);
-                });
-            } else {
-                console.error('[LaunchScreen] game-level分包未找到,尝试加载主场景');
-                this.loadFallbackScene();
-            }
+                    // 提供重试按钮或其他交互方式
+                    this.scheduleOnce(() => {
+                        this.updateProgress(0, '点击屏幕重试或检查场景配置');
+                    }, 2.0);
+                    return;
+                }
+                
+                console.log('[LaunchScreen] 成功切换到GameLevel场景');
+            });
         }, 1.0);
     }
-
-    /**
-     * 加载降级场景
-     */
-    private loadFallbackScene() {
-        console.log('[LaunchScreen] 尝试加载降级场景');
-        director.loadScene('First', (err) => {
-            if (err) {
-                console.error('[LaunchScreen] 降级场景加载失败:', err);
-                this.updateProgress(0, '游戏启动失败,请刷新页面重试');
-            } else {
-                console.log('[LaunchScreen] 成功加载降级场景');
-            }
-        });
-    }
 }