Browse Source

局内新手引导

181404010226 1 month ago
parent
commit
4c2fdaf50e

+ 35 - 0
assets/NewbieGuidePlugin-v1.0.0/NewbieGuidePlugin-v1.0.0/scripts/GuideManager.ts

@@ -6,6 +6,8 @@
 import { GuideDataManager } from "./GuideDataManager";
 import { GuideStep } from "./GuideStep";
 import { GuideUIController } from "./GuideUIController";
+import { NewbieGuideManager } from '../../../scripts/Core/NewbieGuideManager';
+import { find } from 'cc';
 
 export class GuideManager {
     private static _instance: GuideManager = null;
@@ -62,6 +64,16 @@ export class GuideManager {
         }
         
         this._isGuideActive = true;
+        // 启动引导时确保遮罩根节点可见
+        const guideMaskRoot = find('Canvas/GuideMaskAreas');
+        if (guideMaskRoot) {
+            guideMaskRoot.active = true;
+        }
+        // 同步显示手指动画层(GuideLayer)
+        const guideLayer = find('Canvas/GuideLayer');
+        if (guideLayer) {
+            guideLayer.active = true;
+        }
         this.checkAndTriggerNextStep();
     }
     
@@ -74,6 +86,16 @@ export class GuideManager {
         }
         this._isGuideActive = false;
         this._uiController.hideAllGuideUI();
+        // 同步隐藏根遮罩节点
+        const guideMaskRoot = find('Canvas/GuideMaskAreas');
+        if (guideMaskRoot) {
+            guideMaskRoot.active = false;
+        }
+        // 同步隐藏手指动画层(GuideLayer)
+        const guideLayer = find('Canvas/GuideLayer');
+        if (guideLayer) {
+            guideLayer.active = false;
+        }
     }
     
     /**
@@ -150,8 +172,21 @@ export class GuideManager {
         this._isGuideActive = false;
         this._uiController.hideAllGuideUI();
         
+        // 隐藏整套遮罩根节点,避免场景残留
+        const guideMaskRoot = find('Canvas/GuideMaskAreas');
+        if (guideMaskRoot) {
+            guideMaskRoot.active = false;
+        }
+        // 隐藏手指动画层(GuideLayer)避免残留
+        const guideLayer = find('Canvas/GuideLayer');
+        if (guideLayer) {
+            guideLayer.active = false;
+        }
+
         // 可以在这里添加引导完成的回调
         console.log("新手引导完成!");
+        // 标记玩家已完成新手引导并持久化
+        NewbieGuideManager.getInstance().markNewbieGuideCompleted();
     }
     
     /**

+ 27 - 0
assets/NewbieGuidePlugin-v1.0.0/NewbieGuidePlugin-v1.0.0/scripts/GuideUIController.ts

@@ -669,6 +669,15 @@ export class GuideUIController extends Component {
             console.warn('[GuideUIController] 未配置引导步骤');
             return;
         }
+        // 启动时同步激活遮罩根与引导层,避免场景未显
+        const guideMaskRoot = find('Canvas/GuideMaskAreas');
+        if (guideMaskRoot) {
+            guideMaskRoot.active = true;
+        }
+        const guideLayer = find('Canvas/GuideLayer');
+        if (guideLayer) {
+            guideLayer.active = true;
+        }
         this._currentStepIndex = 0;
         this.runCurrentStep();
     }
@@ -682,6 +691,15 @@ export class GuideUIController extends Component {
             console.log('[GuideUIController] 引导步骤结束');
             this.hideAllGuideUI();
             this.hideAllMasksAndFrames();
+            // 结束时同步关闭遮罩根与引导层,避免残留
+            const guideMaskRoot = find('Canvas/GuideMaskAreas');
+            if (guideMaskRoot) {
+                guideMaskRoot.active = false;
+            }
+            const guideLayer = find('Canvas/GuideLayer');
+            if (guideLayer) {
+                guideLayer.active = false;
+            }
             return;
         }
     
@@ -929,6 +947,15 @@ export class GuideUIController extends Component {
             this._activeBlinkComp.stop();
             this._activeBlinkComp = null;
         }
+        // 停止时同步关闭遮罩根与引导层
+        const guideMaskRoot = find('Canvas/GuideMaskAreas');
+        if (guideMaskRoot) {
+            guideMaskRoot.active = false;
+        }
+        const guideLayer = find('Canvas/GuideLayer');
+        if (guideLayer) {
+            guideLayer.active = false;
+        }
         this._currentStepIndex = -1;
     }
 

+ 124 - 46
assets/Scenes/GameLevel.scene

@@ -57,7 +57,7 @@
     },
     "autoReleaseAssets": false,
     "_globals": {
-      "__id__": 1471
+      "__id__": 1477
     },
     "_id": "29694223-a59c-44b3-acb0-80ab92d103f5"
   },
@@ -176,7 +176,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 360,
+      "x": 360.00000000000006,
       "y": 667,
       "z": 0
     },
@@ -385,7 +385,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1000,
+      "width": 1000.0000000000001,
       "height": 5
     },
     "_anchorPoint": {
@@ -749,7 +749,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 1334
     },
     "_anchorPoint": {
@@ -864,7 +864,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -5.684341886080802e-14,
       "y": 0,
       "z": 0
     },
@@ -9830,7 +9830,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": -5.684341886080802e-14,
       "y": 0,
       "z": 0
     },
@@ -13721,7 +13721,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -310,
+      "x": -310.00000000000006,
       "y": 577.3409999999999,
       "z": 0
     },
@@ -13779,7 +13779,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 360,
+      "x": 360.00000000000006,
       "y": 667,
       "z": 0
     },
@@ -13909,7 +13909,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 1334
     },
     "_anchorPoint": {
@@ -18644,7 +18644,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -133.39999999999998,
+      "y": -151.37,
       "z": 0
     },
     "_lrot": {
@@ -18683,7 +18683,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 720,
-      "height": 1334
+      "height": 1634
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -18702,7 +18702,7 @@
     },
     "_enabled": true,
     "__prefab": null,
-    "_alignFlags": 45,
+    "_alignFlags": 40,
     "_target": null,
     "_left": 0,
     "_right": 0,
@@ -18786,7 +18786,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 317.85,
+      "y": 397.2015742128936,
       "z": 0
     },
     "_lrot": {
@@ -18951,7 +18951,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 199.969,
+      "y": 252.81060419790106,
       "z": 0
     },
     "_lrot": {
@@ -19123,7 +19123,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": 97.5,
+      "y": 137.30509745127438,
       "z": 0
     },
     "_lrot": {
@@ -19900,7 +19900,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -187.60000000000002,
+      "y": -217.7574212893553,
       "z": 0
     },
     "_lrot": {
@@ -21100,7 +21100,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -344.5,
+      "y": -411.06671664167925,
       "z": 0
     },
     "_lrot": {
@@ -21414,7 +21414,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 720,
-      "height": 1334
+      "height": 1634
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -21433,7 +21433,7 @@
     },
     "_enabled": true,
     "__prefab": null,
-    "_alignFlags": 45,
+    "_alignFlags": 40,
     "_target": null,
     "_left": 0,
     "_right": 0,
@@ -21553,7 +21553,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0.14999999999997726,
+      "x": 0.1500000000000341,
       "y": -588.66,
       "z": 0
     },
@@ -21617,7 +21617,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -342.65,
+      "x": -342.6500000000001,
       "y": 0,
       "z": 0
     },
@@ -27005,7 +27005,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 705.3,
+      "width": 705.3000000000002,
       "height": 130
     },
     "_anchorPoint": {
@@ -34387,7 +34387,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 1,
+      "x": 0.9999999999999432,
       "y": -6,
       "z": 0
     },
@@ -36125,7 +36125,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 1334
     },
     "_anchorPoint": {
@@ -36177,7 +36177,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 1334
     },
     "_anchorPoint": {
@@ -36303,7 +36303,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -216,
+      "x": -216.00000000000003,
       "y": 138.5,
       "z": 0
     },
@@ -38091,7 +38091,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 216,
+      "x": 216.00000000000003,
       "y": 138.5,
       "z": 0
     },
@@ -39276,7 +39276,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 469
     },
     "_anchorPoint": {
@@ -39418,7 +39418,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1000,
+      "width": 1000.0000000000001,
       "height": 5
     },
     "_anchorPoint": {
@@ -39792,7 +39792,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 1604.706,
+      "x": 1604.7060000000001,
       "y": 0,
       "z": 0
     },
@@ -39955,7 +39955,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 257,
+      "x": 257.0000000000002,
       "y": 175.274,
       "z": 0
     },
@@ -43823,7 +43823,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 609,
+      "width": 609.0000000000005,
       "height": 428
     },
     "_anchorPoint": {
@@ -44005,7 +44005,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 281.9,
+      "x": 281.90000000000003,
       "y": 553.12,
       "z": 0
     },
@@ -44202,7 +44202,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 281.5,
+      "x": 281.50000000000006,
       "y": 485.124,
       "z": 0
     },
@@ -45322,7 +45322,7 @@
         "__id__": 1308
       }
     ],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 1330
@@ -45705,7 +45705,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 4.989000000000033,
+      "x": 4.988999999999919,
       "y": 6.942,
       "z": 0
     },
@@ -49169,7 +49169,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 1334
     },
     "_anchorPoint": {
@@ -49248,7 +49248,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 720,
+      "width": 720.0000000000001,
       "height": 1334
     },
     "_anchorPoint": {
@@ -49495,6 +49495,15 @@
       },
       {
         "__id__": 1469
+      },
+      {
+        "__id__": 1471
+      },
+      {
+        "__id__": 1473
+      },
+      {
+        "__id__": 1475
       }
     ],
     "nestedPrefabInstanceRoots": [
@@ -49826,31 +49835,100 @@
       "8exFcoNxdHybBIMougc43D"
     ]
   },
+  {
+    "__type__": "cc.TargetOverrideInfo",
+    "source": {
+      "__id__": 446
+    },
+    "sourceInfo": null,
+    "propertyPath": [
+      "skillButtons",
+      "0"
+    ],
+    "target": {
+      "__id__": 297
+    },
+    "targetInfo": {
+      "__id__": 1472
+    }
+  },
+  {
+    "__type__": "cc.TargetInfo",
+    "localID": [
+      "9bckw8VnJAVJfh+LK/5rLp"
+    ]
+  },
+  {
+    "__type__": "cc.TargetOverrideInfo",
+    "source": {
+      "__id__": 446
+    },
+    "sourceInfo": null,
+    "propertyPath": [
+      "skillButtons",
+      "1"
+    ],
+    "target": {
+      "__id__": 345
+    },
+    "targetInfo": {
+      "__id__": 1474
+    }
+  },
+  {
+    "__type__": "cc.TargetInfo",
+    "localID": [
+      "9bckw8VnJAVJfh+LK/5rLp"
+    ]
+  },
+  {
+    "__type__": "cc.TargetOverrideInfo",
+    "source": {
+      "__id__": 446
+    },
+    "sourceInfo": null,
+    "propertyPath": [
+      "skillButtons",
+      "2"
+    ],
+    "target": {
+      "__id__": 393
+    },
+    "targetInfo": {
+      "__id__": 1476
+    }
+  },
+  {
+    "__type__": "cc.TargetInfo",
+    "localID": [
+      "9bckw8VnJAVJfh+LK/5rLp"
+    ]
+  },
   {
     "__type__": "cc.SceneGlobals",
     "ambient": {
-      "__id__": 1472
+      "__id__": 1478
     },
     "shadows": {
-      "__id__": 1473
+      "__id__": 1479
     },
     "_skybox": {
-      "__id__": 1474
+      "__id__": 1480
     },
     "fog": {
-      "__id__": 1475
+      "__id__": 1481
     },
     "octree": {
-      "__id__": 1476
+      "__id__": 1482
     },
     "skin": {
-      "__id__": 1477
+      "__id__": 1483
     },
     "lightProbeInfo": {
-      "__id__": 1478
+      "__id__": 1484
     },
     "postSettings": {
-      "__id__": 1479
+      "__id__": 1485
     },
     "bakedWithStationaryMainLight": false,
     "bakedWithHighpLightmap": false

+ 1 - 1
assets/data/levels/Level1.json

@@ -20,7 +20,7 @@
       "enemies": [
         {
           "enemyType": "normal_zombie",
-          "count": 5,
+          "count": 2,
           "spawnInterval": 1.0,
           "spawnDelay": 0.0,
           "characteristics": "中速移动, 无技能",

+ 10 - 3
assets/scripts/CombatSystem/GainUI.ts

@@ -27,7 +27,7 @@ export class GainUI extends Component {
         this.bundleLoader = BundleLoader.getInstance();
         // 默认隐藏弹窗
         if (this.panel) this.panel.active = false;
-
+        console.log('[GainUI] 已隐藏弹窗(默认状态)');
         // 绑定事件
         EventBus.getInstance().on(GameEvents.NEW_WEAPONS_UNLOCKED, this.onNewWeaponsUnlocked, this);
         EventBus.getInstance().on(GameEvents.REWARD_ANIMATION_COMPLETED, this.onRewardAnimationCompleted, this);
@@ -72,7 +72,14 @@ export class GainUI extends Component {
 
         const nextName = this.pendingWeapons.shift();
         await this.renderWeapon(nextName);
-        this.panel.active = true;
+        // 激活并确保置顶显示,避免被MainUI/TopBar覆盖
+        if (this.panel) {
+            this.panel.active = true;
+            const parent = this.panel.parent;
+            if (parent) {
+                this.panel.setSiblingIndex(parent.children.length - 1);
+            }
+        }
         this.showing = true;
     }
 
@@ -82,7 +89,7 @@ export class GainUI extends Component {
             const nextName = this.pendingWeapons.shift();
             await this.renderWeapon(nextName);
         } else {
-            this.panel.active = false;
+            if (this.panel) this.panel.active = false;
             this.showing = false;
         }
     }

+ 10 - 5
assets/scripts/Core/NewbieGuideManager.ts

@@ -49,11 +49,13 @@ export class NewbieGuideManager {
         this.hasCheckedOnSceneLoad = true;
         console.log('[NewbieGuideManager] 场景加载时检查新手引导状态');
         
-        if (this.isNewPlayer()) {
-            console.log('[NewbieGuideManager] 检测到新用户,启动新手引导流程');
+        const currentLevel = this.saveDataManager?.getCurrentLevel?.() ?? 1;
+        if (currentLevel === 1) {
+            console.log('[NewbieGuideManager] 读取第1关,启动新手引导流程');
             this.startNewbieGuide();
         } else {
-            console.log('[NewbieGuideManager] 用户已完成新手引导,跳过引导流程');
+            this.isInProgress = false;
+            console.log('[NewbieGuideManager] 非第1关,关闭新手引导');
         }
     }
 
@@ -77,7 +79,10 @@ export class NewbieGuideManager {
      * @returns true表示是新用户,需要新手引导
      */
     public isNewUser(): boolean {
-        return this.isNewPlayer();
+        // 重写显示逻辑:仅当当前关卡为第1关时视为需要新手引导
+        if (!this.saveDataManager || typeof this.saveDataManager.getCurrentLevel !== 'function') return false;
+        const currentLevel = this.saveDataManager.getCurrentLevel();
+        return currentLevel === 1;
     }
 
     /**
@@ -138,7 +143,7 @@ export class NewbieGuideManager {
         }
         
         playerData.settings.newbieGuideCompleted = true;
-        this.saveDataManager.savePlayerData();
+        this.saveDataManager.savePlayerData(true);
         this.isInProgress = false;
         
         console.log('[NewbieGuideManager] 新手引导已标记为完成');

+ 22 - 5
assets/scripts/LevelSystem/GameManager.ts

@@ -16,6 +16,7 @@ import { StartGame } from './StartGame';
 import { InGameManager, GameState } from './IN_game';
 import { GuideManager } from '../../NewbieGuidePlugin-v1.0.0/NewbieGuidePlugin-v1.0.0/scripts/GuideManager';
 import DragBlockToGridStep from '../Guide/DragBlockToGridStep';
+import { NewbieGuideManager } from '../Core/NewbieGuideManager';
 const { ccclass, property } = _decorator;
 
 /**
@@ -214,11 +215,27 @@ export class GameManager extends Component {
 
         // 初始化并启动新手引导(仅注册基础拖拽到网格步骤)
         try {
-            const guideManager = GuideManager.getInstance();
-            guideManager.init();
-            guideManager.registerStep(new DragBlockToGridStep());
-            guideManager.startGuide();
-            console.log('[GameManager] 新手引导已初始化并启动');
+            const newbieGuideManager = NewbieGuideManager.getInstance();
+            if (newbieGuideManager.isNewUser()) {
+                const guideManager = GuideManager.getInstance();
+                guideManager.init();
+                guideManager.registerStep(new DragBlockToGridStep());
+                guideManager.startGuide();
+                console.log('[GameManager] 新手引导已初始化并启动');
+            } else {
+                console.log('[GameManager] 检测到用户已完成新手引导,跳过插件引导初始化');
+                const guideMaskAreas = find('Canvas/GuideMaskAreas');
+                if (guideMaskAreas) {
+                    guideMaskAreas.active = false;
+                    console.log('[GameManager] 已隐藏Canvas/GuideMaskAreas(非新手引导)');
+                }
+                // 同步隐藏手指动画层(GuideLayer)
+                const guideLayer = find('Canvas/GuideLayer');
+                if (guideLayer) {
+                    guideLayer.active = false;
+                    console.log('[GameManager] 已隐藏Canvas/GuideLayer(非新手引导)');
+                }
+            }
         } catch (e) {
             console.warn('[GameManager] 新手引导初始化失败:', e);
         }