4 Commits 88ffa1ec5e ... 852de98480

Author SHA1 Message Date
  0224995 852de98480 small_Bug 1 month ago
  0224995 db5aa168d4 scene_change_bug 1 month ago
  0224995 9b8044ed48 a_little_problem 1 month ago
  0224995 039f3b75d5 nextLv_gameOver 2 months ago
33 changed files with 815 additions and 391 deletions
  1. 52 52
      assets/Scene/GameScene.scene
  2. 22 20
      assets/Scene/StartScene.scene
  3. 34 32
      assets/Script/Frames/DataManager.ts
  4. 59 32
      assets/Script/Frames/LocalDt.ts
  5. 0 1
      assets/Script/Frames/ResourcesMgr.ts
  6. 1 0
      assets/Script/Game/GameFrameWork/GameMgr.ts
  7. 46 20
      assets/Script/Game/MyApp.ts
  8. 3 2
      assets/Script/Game/MyApp/BattleSceneSelect.ts
  9. 11 0
      assets/Script/Game/MyApp/GameScene/Bottom.ts
  10. 1 1
      assets/Script/Game/MyApp/GameScene/BulletPool.ts
  11. 6 2
      assets/Script/Game/MyApp/GameScene/Data/PopupUIDataConfig.ts
  12. 3 2
      assets/Script/Game/MyApp/GameScene/Enemy.ts
  13. 2 1
      assets/Script/Game/MyApp/GameScene/EnemyMgr.ts
  14. 6 1
      assets/Script/Game/MyApp/GameScene/EnemyTower.ts
  15. 55 25
      assets/Script/Game/MyApp/GameScene/GameOver.ts
  16. 5 6
      assets/Script/Game/MyApp/GameScene/LifeBar.ts
  17. 6 1
      assets/Script/Game/MyApp/GameScene/MyTower.ts
  18. 13 7
      assets/Script/Game/MyApp/GameScene/Pause.ts
  19. 1 1
      assets/Script/Game/MyApp/GameScene/TouchSkill.ts
  20. 8 23
      assets/Script/Game/MyApp/Role.ts
  21. 1 4
      assets/Script/Game/MyApp/SelectTroopsBottom.ts
  22. 4 4
      assets/Script/Game/UI/BattleSceneLeft.ts
  23. 3 1
      assets/Script/Game/UI/BattleSceneTop.ts
  24. 1 1
      assets/Script/Game/UI/LoadingUI.ts
  25. 7 5
      assets/Script/Game/UI/PopupUI.ts
  26. 1 1
      assets/Script/Game/UI/SelectTroops.ts
  27. 9 2
      assets/Script/Game/UI/Start.ts
  28. 6 4
      assets/Script/GameInfo.ts
  29. 449 12
      assets/resources/UI/Start.prefab
  30. 0 3
      build-templates/templates-version.json
  31. 0 80
      build-templates/wechatgame/game.ejs
  32. 0 10
      build-templates/wechatgame/game.json
  33. 0 35
      build-templates/wechatgame/project.config.json

+ 52 - 52
assets/Scene/GameScene.scene

@@ -92,8 +92,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 640,
-      "y": 360.0849256900213,
+      "x": 639.9999999999999,
+      "y": 360.00000000000006,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -178,7 +178,7 @@
     "_priority": 0,
     "_priority": 0,
     "_fov": 45,
     "_fov": 45,
     "_fovAxis": 0,
     "_fovAxis": 0,
-    "_orthoHeight": 360.08492569002124,
+    "_orthoHeight": 360,
     "_near": 0,
     "_near": 0,
     "_far": 1000,
     "_far": 1000,
     "_color": {
     "_color": {
@@ -355,8 +355,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 552.4038513800424
+      "width": 1279.9999999999998,
+      "height": 552.2339999999999
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -457,8 +457,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -640,
-      "y": -360.08492569002124,
+      "x": -639.9999999999999,
+      "y": -360,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -496,8 +496,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -596,8 +596,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -565,
-      "y": 87.58492569002124,
+      "x": -564.9999999999999,
+      "y": 87.5,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -1416,8 +1416,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 565,
-      "y": 87.58492569002124,
+      "x": 564.9999999999999,
+      "y": 87.5,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -2205,7 +2205,7 @@
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
       "x": 0,
       "x": 0,
-      "y": -270.08492569002124,
+      "y": -270,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -2259,7 +2259,7 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -557.33203125,
+      "x": -557.3320312499999,
       "y": 42.8,
       "y": 42.8,
       "z": 0
       "z": 0
     },
     },
@@ -2602,7 +2602,7 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -365,
+      "x": -364.9999999999999,
       "y": 0,
       "y": 0,
       "z": 0
       "z": 0
     },
     },
@@ -3380,7 +3380,7 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 125,
+      "x": 124.99999999999989,
       "y": 0,
       "y": 0,
       "z": 0
       "z": 0
     },
     },
@@ -9578,7 +9578,7 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 558,
+      "x": 557.9999999999999,
       "y": 0,
       "y": 0,
       "z": 0
       "z": 0
     },
     },
@@ -10459,7 +10459,7 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 125,
+      "x": 124.99999999999989,
       "y": 0,
       "y": 0,
       "z": 0
       "z": 0
     },
     },
@@ -10562,7 +10562,7 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
+      "width": 1279.9999999999998,
       "height": 180
       "height": 180
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
@@ -10695,8 +10695,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -640,
-      "y": -360.08492569002124,
+      "x": -639.9999999999999,
+      "y": -360,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -11572,8 +11572,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -11624,8 +11624,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -11687,8 +11687,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -640,
-      "y": -360.08492569002124,
+      "x": -639.9999999999999,
+      "y": -360,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -11726,8 +11726,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -11808,8 +11808,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -640,
-      "y": -360.08492569002124,
+      "x": -639.9999999999999,
+      "y": -360,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -12685,8 +12685,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -12737,8 +12737,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -17667,8 +17667,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": -584.8,
-      "y": 228.68492569002123,
+      "x": -584.7999999999998,
+      "y": 228.6,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -18830,8 +18830,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -18894,8 +18894,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -19064,8 +19064,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -19164,8 +19164,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -19264,8 +19264,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -19316,8 +19316,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -19370,8 +19370,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",

+ 22 - 20
assets/Scene/StartScene.scene

@@ -98,8 +98,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 640,
-      "y": 360.0849256900213,
+      "x": 639.9999999999999,
+      "y": 360.00000000000006,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -184,7 +184,7 @@
     "_priority": 0,
     "_priority": 0,
     "_fov": 45,
     "_fov": 45,
     "_fovAxis": 0,
     "_fovAxis": 0,
-    "_orthoHeight": 360.08492569002124,
+    "_orthoHeight": 360,
     "_near": 0,
     "_near": 0,
     "_far": 1000,
     "_far": 1000,
     "_color": {
     "_color": {
@@ -256,8 +256,8 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 0,
-      "y": -0.08492569002123673,
+      "x": 1.1368683772161603e-13,
+      "y": 0,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -2426,7 +2426,7 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 210,
+      "width": 0,
       "height": 15
       "height": 15
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
@@ -2557,7 +2557,7 @@
     "_prefab": null,
     "_prefab": null,
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
-      "x": 63.34228515625,
+      "x": 50.65228515625,
       "y": 0,
       "y": 0,
       "z": 0
       "z": 0
     },
     },
@@ -2601,7 +2601,7 @@
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
-      "x": 0.5,
+      "x": 0,
       "y": 0.5
       "y": 0.5
     },
     },
     "_id": "25k9HEfQdOJZB/SyG69WMb"
     "_id": "25k9HEfQdOJZB/SyG69WMb"
@@ -3060,7 +3060,7 @@
     },
     },
     "_mode": 0,
     "_mode": 0,
     "_totalLength": 300,
     "_totalLength": 300,
-    "_progress": 0.7,
+    "_progress": 0,
     "_reverse": false,
     "_reverse": false,
     "_id": "59Bip/gnFJZZFeMKxk0y99"
     "_id": "59Bip/gnFJZZFeMKxk0y99"
   },
   },
@@ -12707,8 +12707,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -12807,8 +12807,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -12907,8 +12907,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -12959,8 +12959,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -13876,7 +13876,9 @@
     "_enabled": true,
     "_enabled": true,
     "__prefab": null,
     "__prefab": null,
     "_alignFlags": 45,
     "_alignFlags": 45,
-    "_target": null,
+    "_target": {
+      "__id__": 2
+    },
     "_left": 0,
     "_left": 0,
     "_right": 0,
     "_right": 0,
     "_top": 0,
     "_top": 0,
@@ -13958,8 +13960,8 @@
     "__prefab": null,
     "__prefab": null,
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
-      "width": 1280,
-      "height": 720.1698513800425
+      "width": 1279.9999999999998,
+      "height": 720
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",

+ 34 - 32
assets/Script/Frames/DataManager.ts

@@ -1,40 +1,40 @@
-import { JsonAsset, resources, TextAsset } from "cc";
+import { AssetManager, JsonAsset, resources, TextAsset } from "cc";
 
 
-export interface DataBase{
+export interface DataBase {
     id: number;
     id: number;
 }
 }
 
 
 //一个文件 对应一个数据操作者
 //一个文件 对应一个数据操作者
-class DataCtrl{
+class DataCtrl {
     private _datas: Map<number, DataBase> = new Map();
     private _datas: Map<number, DataBase> = new Map();
-    constructor(asset: JsonAsset | TextAsset){
-        if(asset instanceof JsonAsset){
+    constructor(asset: JsonAsset | TextAsset) {
+        if (asset instanceof JsonAsset) {
             const datas: DataBase[] = <DataBase[]>asset.json;
             const datas: DataBase[] = <DataBase[]>asset.json;
-            for(const data of datas){
+            for (const data of datas) {
                 this._datas.set(Number(data.id), data);
                 this._datas.set(Number(data.id), data);
             }
             }
             return;
             return;
         }
         }
         //表格数据
         //表格数据
-        if(asset instanceof TextAsset){
+        if (asset instanceof TextAsset) {
             this._parseCSV(asset.text);
             this._parseCSV(asset.text);
         }
         }
     }
     }
-    private _parseCSV(text: string){
+    private _parseCSV(text: string) {
         const lines: string[] = text.split("\r\n");
         const lines: string[] = text.split("\r\n");
         //表格中 单元格以逗号,分开
         //表格中 单元格以逗号,分开
         const keys: string[] = lines[0].split(",");
         const keys: string[] = lines[0].split(",");
         const types: string[] = lines[1].split(",");
         const types: string[] = lines[1].split(",");
         //有用的数据
         //有用的数据
-        for(let i = 2; i < lines.length - 1; i++){
+        for (let i = 2; i < lines.length - 1; i++) {
             const cols: string[] = lines[i].split(",");
             const cols: string[] = lines[i].split(",");
             //每一行就是一个数据 创建一个空对象 存储数据
             //每一行就是一个数据 创建一个空对象 存储数据
             let obj = {};
             let obj = {};
-            for(let j = 1; j <cols.length; j++){
+            for (let j = 1; j < cols.length; j++) {
                 //获取当前字符串值 根据类型定数据
                 //获取当前字符串值 根据类型定数据
                 let val = cols[j];
                 let val = cols[j];
                 let v;
                 let v;
-                switch(types[j]){
+                switch (types[j]) {
                     case "boolean":
                     case "boolean":
                         v = Boolean(Number(val));
                         v = Boolean(Number(val));
                         break;
                         break;
@@ -49,8 +49,8 @@ class DataCtrl{
                         break;
                         break;
                     case "number[]":
                     case "number[]":
                         v = val.split(";");
                         v = val.split(";");
-                        let arr:number[] = [];
-                        for(const info of v){
+                        let arr: number[] = [];
+                        for (const info of v) {
                             arr.push(Number(info));
                             arr.push(Number(info));
                         }
                         }
                         v = arr;
                         v = arr;
@@ -66,53 +66,55 @@ class DataCtrl{
     }
     }
 
 
     //通过id获取某个数据
     //通过id获取某个数据
-    getData<T extends DataBase>(id: number):T{
+    getData<T extends DataBase>(id: number): T {
         return <T>this._datas.get(id);
         return <T>this._datas.get(id);
     }
     }
 
 
     //获取当前文件解析的所有数据
     //获取当前文件解析的所有数据
-    getAllData<T extends DataBase>(): T[]{
+    getAllData<T extends DataBase>(): T[] {
         return <T[]>Array.from(this._datas.values());
         return <T[]>Array.from(this._datas.values());
     }
     }
 }
 }
 
 
 //管理所有数据操作者
 //管理所有数据操作者
-class DataManager{
+class DataManager {
     private _dataCtrls: Map<string, DataCtrl> = new Map();
     private _dataCtrls: Map<string, DataCtrl> = new Map();
     static instance: DataManager = null;
     static instance: DataManager = null;
 
 
-    async loadDataDir(dir: string){
-        const assets: TextAsset[] | JsonAsset[] = await new Promise((values, reject)=>{
-            resources.loadDir(dir,(err: Error, assets: TextAsset[] | JsonAsset[])=>{
-                if(err){
-                    reject(err);
-                }
-                else{
-                    values(assets);
-                }
-            })
+    async loadDataDir(dir: string, onProgress: (
+        (finish: number, total: number, item: AssetManager.RequestItem) => void) = null) {
+        const assets: TextAsset[] | JsonAsset[] = await new Promise((values, reject) => {
+            resources.loadDir(dir,
+                onProgress, (err: Error, assets: TextAsset[] | JsonAsset[]) => {
+                    if (err) {
+                        reject(err);
+                    }
+                    else {
+                        values(assets);
+                    }
+                })
         })
         })
 
 
-        for(const asset of assets){
+        for (const asset of assets) {
             this._dataCtrls.set(asset.name, new DataCtrl(asset));
             this._dataCtrls.set(asset.name, new DataCtrl(asset));
         }
         }
     }
     }
 
 
-    getData<T extends DataBase>(id: number, ctrlName?: string):T{
+    getData<T extends DataBase>(id: number, ctrlName?: string): T {
         //通过文件名 获取 数据操作者
         //通过文件名 获取 数据操作者
-        if(ctrlName){
+        if (ctrlName) {
             return this._dataCtrls.get(ctrlName).getData<T>(id);
             return this._dataCtrls.get(ctrlName).getData<T>(id);
         }
         }
         //遍历所有的数据操作者 看看谁有id 为 id 的数据
         //遍历所有的数据操作者 看看谁有id 为 id 的数据
-        for(const ctrl of Array.from(this._dataCtrls.values())){
+        for (const ctrl of Array.from(this._dataCtrls.values())) {
             const data = ctrl.getData<T>(id);
             const data = ctrl.getData<T>(id);
-            if(data){return data;}
+            if (data) { return data; }
         }
         }
         //都没有
         //都没有
         return null;
         return null;
     }
     }
 
 
-    getAllDataByName<T extends DataBase>(name: string):T[]{
+    getAllDataByName<T extends DataBase>(name: string): T[] {
         //获取文件名为 name 的数据操作者的所有数据
         //获取文件名为 name 的数据操作者的所有数据
         return this._dataCtrls.get(name).getAllData<T>();
         return this._dataCtrls.get(name).getAllData<T>();
     }
     }

+ 59 - 32
assets/Script/Frames/LocalDt.ts

@@ -1,41 +1,68 @@
 class LocalStorage {
 class LocalStorage {
     static instance: LocalStorage = null;
     static instance: LocalStorage = null;
-    //保存关卡
-    saveLvDt(curLv: number) {
-        localStorage.setItem("curLv", JSON.stringify(curLv));
+    // //保存关卡
+    // saveLvDt(curLv: number) {
+    //     localStorage.setItem("curLv", JSON.stringify(curLv));
+    // }
+    // //获取关卡
+    // getLvDt(): number {
+    //     const jsonStr = localStorage.getItem("curLv")
+    //     return JSON.parse(jsonStr);
+    // }
+    // //保存玩家名字
+    // savePlayerName(name: string) {
+    //     localStorage.setItem("PlayerName", JSON.stringify(name));
+    // }
+    // //获取玩家名字
+    // getPlayerName(): string {
+    //     const jsonStr = localStorage.getItem("PlayerName")
+    //     return JSON.parse(jsonStr);
+    // }
+    // //金币
+    // saveGold(num: number) {
+    //     localStorage.setItem("Gold", JSON.stringify(num));
+    // }
+    // getGold(): number {
+    //     const jsonStr = localStorage.getItem("Gold")
+    //     return JSON.parse(jsonStr);
+    // }
+    // //钻石
+    // saveDiamond(num: number) {
+    //     localStorage.setItem("Diamond", JSON.stringify(num));
+    // }
+    // getDiamond(): number {
+    //     const jsonStr = localStorage.getItem("Diamond")
+    //     return JSON.parse(jsonStr);
+    // }
+    /**
+     * 保存数据
+     * @param dtName 数据名
+     * @param dt 数据
+     */
+    saveData(dtName: string, dt: number | string) {
+        localStorage.setItem(dtName, JSON.stringify(dt));
     }
     }
-    //获取关卡
-    getLvDt(): number {
-        const jsonStr = localStorage.getItem("curLv")
-        return JSON.parse(jsonStr);
-    }
-    //保存玩家名字
-    savePlayerName(name: string) {
-        localStorage.setItem(`PlayerName`, JSON.stringify(name));
-    }
-    //获取玩家名字
-    getPlayerName(): string {
-        const jsonStr = localStorage.getItem(`PlayerName`)
-        return JSON.parse(jsonStr);
-    }
-    //金币
-    saveGold(num: number) {
-        localStorage.setItem(`Gold`, JSON.stringify(num));
-    }
-    getGold(): number {
-        const jsonStr = localStorage.getItem(`Gold`)
-        return JSON.parse(jsonStr);
-    }
-    //钻石
-    saveDiamond(num: number) {
-        localStorage.setItem(`Diamond`, JSON.stringify(num));
-    }
-    getDiamond(): number {
-        const jsonStr = localStorage.getItem(`Diamond`)
+
+    /**
+     * 获取数据
+     * @param dtName 数据名
+     * @returns 
+     */
+    getData(dtName: string): number | string {
+        const jsonStr = localStorage.getItem(dtName);
         return JSON.parse(jsonStr);
         return JSON.parse(jsonStr);
     }
     }
 
 
-
+    /**
+     * 清除数据并初始化
+     */
+    clearAll() {
+        localStorage.clear();
+        this.saveData("Diamond", 188);
+        this.saveData("Gold", 5888);
+        this.saveData("curLv", 1);
+        this.saveData("availableCardSlot", 5);
+    }
 }
 }
 export const localDt: LocalStorage = LocalStorage.instance = new LocalStorage();
 export const localDt: LocalStorage = LocalStorage.instance = new LocalStorage();
 
 

+ 0 - 1
assets/Script/Frames/ResourcesMgr.ts

@@ -26,7 +26,6 @@ class ResourcesMgr{
        //遍历所有资源 分门别类存储到对应的容器中
        //遍历所有资源 分门别类存储到对应的容器中
        for(const asset of assets){
        for(const asset of assets){
           this.addRes(asset, asset.name);
           this.addRes(asset, asset.name);
-          //console.log(asset)
        }
        }
     }
     }
 
 

+ 1 - 0
assets/Script/Game/GameFrameWork/GameMgr.ts

@@ -10,6 +10,7 @@ export class GameMgr extends Component {
     private _modluers:ModulerBase[] = [];
     private _modluers:ModulerBase[] = [];
     //单例接口
     //单例接口
     static get Instance(){return GameMgr._instance}
     static get Instance(){return GameMgr._instance}
+    
     protected onLoad(): void {
     protected onLoad(): void {
         //单例赋值 this
         //单例赋值 this
         GameMgr._instance = this;
         GameMgr._instance = this;

+ 46 - 20
assets/Script/Game/MyApp.ts

@@ -1,31 +1,57 @@
-import { _decorator, Component } from 'cc';
+import { _decorator, Component, director, EventGamepad, Node } from 'cc';
 import { resMgr } from '../Frames/ResourcesMgr';
 import { resMgr } from '../Frames/ResourcesMgr';
 import { dataMgr } from '../Frames/DataManager';
 import { dataMgr } from '../Frames/DataManager';
 import { LoadingUI } from './UI/LoadingUI';
 import { LoadingUI } from './UI/LoadingUI';
+import { localDt } from '../Frames/LocalDt';
+import { GameInfo } from '../GameInfo';
+import { UIMgr } from '../Frames/UIManager';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('MyApp')
 @ccclass('MyApp')
 export class MyApp extends Component {
 export class MyApp extends Component {
-    protected async start(){
-        // await UIMgr.openUI("LoadingUI",UIType.PAGE);
-        // const loadingUI = UIMgr.getUI(LoadingUI);
-        const loadingUI = this.node.getChildByName("LoadingUI").getComponent(LoadingUI)
-        await dataMgr.loadDataDir("Data");
-        await resMgr.loadAllRes("Res", (finish, total)=>{
-            if(loadingUI){
-                loadingUI.updateProgress(finish / total);
-                loadingUI.updateWhichRes(1);
-            }
+    private static hasOpenedStartUI = false;
+    loadingUI: Node | null = null;
+    protected onLoad(): void {
+        this.loadingUI = this.node.getChildByName("LoadingUI");
+    }
+    protected async start() {
+        if (MyApp.hasOpenedStartUI) return;
+        const loadingUI = this.loadingUI?.getComponent(LoadingUI)
+        if (!this.loadingUI.active) {
+            this.loadingUI.active = true;
+        }
+        await dataMgr.loadDataDir("Data", (finish, total) => {
+            loadingUI?.updateProgress(finish / total);
+            loadingUI?.updateWhichRes(1);
+        });
+        await resMgr.loadAllRes("Res", (finish, total) => {
+            loadingUI?.updateProgress(finish / total);
+            loadingUI?.updateWhichRes(2);
         });
         });
-        await resMgr.loadAllRes("UI", (finish, total)=>{
-            if(loadingUI){
-                loadingUI.updateProgress(finish / total);
-                loadingUI.updateWhichRes(2);
-            }
+        await resMgr.loadAllRes("UI", (finish, total) => {
+            loadingUI?.updateProgress(finish / total);
+            loadingUI?.updateWhichRes(3);
         });
         });
-        
-        this.node.getChildByName("LoadingUI").active = false;
-        // UIMgr.closeUI("LoadingUI");
-        // UIMgr.openUI("Start",UIType.PAGE);
+        this.initData();
+        this.loadingUI.active = false;
+        if (!MyApp.hasOpenedStartUI) {
+            UIMgr.openUI("Start");
+            MyApp.hasOpenedStartUI = true;
+        }
+    }
+
+    private initData() {
+        if (!localDt.getData("Gold")) {
+            localDt.saveData("Gold", 8888);
+        }
+        if (!localDt.getData("Diamond")) {
+            localDt.saveData("Diamond", 200);
+        }
+        if (!localDt.getData("curLv")) {
+            localDt.saveData("curLv", 1);
+        }
+        if (!localDt.getData("availableCardSlot")) {
+            localDt.saveData("availableCardSlot", 4);
+        }
     }
     }
 }
 }

+ 3 - 2
assets/Script/Game/MyApp/BattleSceneSelect.ts

@@ -1,8 +1,9 @@
-import { _decorator, Component, Label, Node, Sprite } from 'cc';
+import { _decorator, Label, Sprite } from 'cc';
 import { UIBase } from '../GameFrameWork/UIBase';
 import { UIBase } from '../GameFrameWork/UIBase';
 import { UIMgr } from '../../Frames/UIManager';
 import { UIMgr } from '../../Frames/UIManager';
 import { resMgr } from '../../Frames/ResourcesMgr';
 import { resMgr } from '../../Frames/ResourcesMgr';
 import { GameInfo } from '../../GameInfo';
 import { GameInfo } from '../../GameInfo';
+import { localDt } from '../../Frames/LocalDt';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('BattleSceneSelect')
 @ccclass('BattleSceneSelect')
@@ -12,7 +13,7 @@ export class BattleSceneSelect extends UIBase {
         this._curLv(GameInfo.Instance.getCurlv());
         this._curLv(GameInfo.Instance.getCurlv());
         this._winNumber(GameInfo.Instance.getWin());
         this._winNumber(GameInfo.Instance.getWin());
         this._failNumber(GameInfo.Instance.getFail());
         this._failNumber(GameInfo.Instance.getFail());
-        this._gold(GameInfo.Instance.getGold());
+        this._gold(Number(localDt.getData("Gold")));
         this._diamond(GameInfo.Instance.getDiamond());
         this._diamond(GameInfo.Instance.getDiamond());
         this._grade(GameInfo.Instance.getGrade());
         this._grade(GameInfo.Instance.getGrade());
     }
     }

+ 11 - 0
assets/Script/Game/MyApp/GameScene/Bottom.ts

@@ -27,6 +27,7 @@ export class Bottom extends ModulerBase {
     }
     }
 
 
     onStart() {
     onStart() {
+        this.initData();
         this.getLabel("_lvNumber").string = String(GameInfo.Instance.getCurlv());
         this.getLabel("_lvNumber").string = String(GameInfo.Instance.getCurlv());
         this.getLabel("_oreGrade").string = `等级:${GameInfo.Instance.getOreGrade()}`;
         this.getLabel("_oreGrade").string = `等级:${GameInfo.Instance.getOreGrade()}`;
         this.getLabel("_ownNumber").string = String(GameInfo.Instance.getOwnDiamondNum());
         this.getLabel("_ownNumber").string = String(GameInfo.Instance.getOwnDiamondNum());
@@ -40,6 +41,13 @@ export class Bottom extends ModulerBase {
         messageMgr.addEvent("addOreCount", this.onEnemyDeath, this)
         messageMgr.addEvent("addOreCount", this.onEnemyDeath, this)
     }
     }
 
 
+    initData(){
+        this.getLabel("_lvNumber").string = String(GameInfo.Instance.getCurlv());
+        this.getLabel("_ownNumber").string = String(GameInfo.Instance.getOwnDiamondNum());
+        this.getLabel("_ownNumber").string = String(GameInfo.Instance.getOwnDiamondNum());
+        this.oreCount = 100;
+    }
+
     protected update(dt: number): void {
     protected update(dt: number): void {
         //累加时间
         //累加时间
         this._elapsedTime += dt;
         this._elapsedTime += dt;
@@ -62,9 +70,12 @@ export class Bottom extends ModulerBase {
             if(lock.active){
             if(lock.active){
                 lock.active = false;
                 lock.active = false;
             }
             }
+            //设置角色图片
             const sprite: Node = role.getChildByName("Sprite");
             const sprite: Node = role.getChildByName("Sprite");
             const imgName: string = GameInfo.Instance.getRoleImgNames()[i];
             const imgName: string = GameInfo.Instance.getRoleImgNames()[i];
             sprite.getComponent(Sprite).spriteFrame = resMgr.getSpriteFrame(imgName);
             sprite.getComponent(Sprite).spriteFrame = resMgr.getSpriteFrame(imgName);
+
+            //设置消耗量
             for (const roleDt of this._roleDts) {
             for (const roleDt of this._roleDts) {
                 if (roleDt.imgName === imgName) {
                 if (roleDt.imgName === imgName) {
                     const count: Node = role.getChildByName("Count");
                     const count: Node = role.getChildByName("Count");

+ 1 - 1
assets/Script/Game/MyApp/GameScene/BulletPool.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, instantiate, Node, NodePool, Pool, Prefab } from 'cc';
+import { _decorator, Component, instantiate, Node, NodePool, Prefab } from 'cc';
 import { resMgr } from '../../../Frames/ResourcesMgr';
 import { resMgr } from '../../../Frames/ResourcesMgr';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 

+ 6 - 2
assets/Script/Game/MyApp/GameScene/Data/PopupUIDataConfig.ts

@@ -1,3 +1,5 @@
+import { localDt } from "db://assets/Script/Frames/LocalDt";
+
 export class PopupUIDataConfig {
 export class PopupUIDataConfig {
     private _uiName: string = null;
     private _uiName: string = null;
     private _typeImg: string = null;
     private _typeImg: string = null;
@@ -41,7 +43,8 @@ export class PopupUIDataConfig {
     }
     }
 
 
     getAvailableCardSlot(): number{
     getAvailableCardSlot(): number{
-        return this._availableCardSlot;
+        return Number(localDt.getData("availableCardSlot"));
+        //return this._availableCardSlot;
     }
     }
 
 
     setUIName(name: string) { this._uiName = name };
     setUIName(name: string) { this._uiName = name };
@@ -58,7 +61,8 @@ export class PopupUIDataConfig {
     }
     }
 
 
     setAvailableCardSlot(nextCount: number){
     setAvailableCardSlot(nextCount: number){
-        this._availableCardSlot = nextCount;
+        localDt.saveData("availableCardSlot", nextCount)
+        //this._availableCardSlot = nextCount;
     }
     }
 }
 }
 
 

+ 3 - 2
assets/Script/Game/MyApp/GameScene/Enemy.ts

@@ -15,11 +15,12 @@ export class Enemy extends Role {
     private _isDie: boolean = false;
     private _isDie: boolean = false;
     private _orePos: Vec3 = new Vec3(200, 100, 0);
     private _orePos: Vec3 = new Vec3(200, 100, 0);
     protected onLoad(): void {
     protected onLoad(): void {
-        this._lifeBar = this.node.getComponent(LifeBar);
-        this._isDie = false;
+        
     }
     }
     init(name: string, pos: Vec3, data: RoleData[], dir?: number) {
     init(name: string, pos: Vec3, data: RoleData[], dir?: number) {
         super.init(name, pos, data, dir);
         super.init(name, pos, data, dir);
+        this._lifeBar = this.node.getComponent(LifeBar);
+        this._isDie = false;
         this._initLifeBar();
         this._initLifeBar();
     }
     }
 
 

+ 2 - 1
assets/Script/Game/MyApp/GameScene/EnemyMgr.ts

@@ -30,10 +30,11 @@ export class EnemyMgr extends ModulerBase {
         this._bg = this.node.parent.getChildByName("Bg");
         this._bg = this.node.parent.getChildByName("Bg");
         this._lvDts = dataMgr.getAllDataByName("LevelDt");
         this._lvDts = dataMgr.getAllDataByName("LevelDt");
         this._hight = GameMgr.Instance.getModuler(TouchGame)._hight;
         this._hight = GameMgr.Instance.getModuler(TouchGame)._hight;
-        this._roleDatas = dataMgr.getAllDataByName("RoleCardData");
+        
         this._enemyTower = this.node.parent.getChildByName("EnemyTower");
         this._enemyTower = this.node.parent.getChildByName("EnemyTower");
     }
     }
     init() {
     init() {
+        this._roleDatas = dataMgr.getAllDataByName("RoleCardData");
         //第几关的数据
         //第几关的数据
         this._lvDt = this._lvDts[GameInfo.Instance.getCurlv() - 1];
         this._lvDt = this._lvDts[GameInfo.Instance.getCurlv() - 1];
         this._createEnemy();
         this._createEnemy();

+ 6 - 1
assets/Script/Game/MyApp/GameScene/EnemyTower.ts

@@ -1,4 +1,4 @@
-import { _decorator, find, Label, PhysicsGroup } from 'cc';
+import { _decorator, director, find, Label, PhysicsGroup } from 'cc';
 import { LifeBar } from './LifeBar';
 import { LifeBar } from './LifeBar';
 import { Role } from '../Role';
 import { Role } from '../Role';
 import { Enemy } from './Enemy';
 import { Enemy } from './Enemy';
@@ -19,6 +19,9 @@ export class EnemyTower extends Role {
         this._strMyHp = this.node.getChildByPath("ProgressBar/Label").getComponent(Label);
         this._strMyHp = this.node.getChildByPath("ProgressBar/Label").getComponent(Label);
     }
     }
     start() {
     start() {
+        this.initData();
+    }
+    initData(){
         this.hp = this.enemyTotalHp;
         this.hp = this.enemyTotalHp;
         this._initLifeBar();
         this._initLifeBar();
     }
     }
@@ -27,6 +30,7 @@ export class EnemyTower extends Role {
     private _initLifeBar() {
     private _initLifeBar() {
         this._lifeBar._curHp = this.hp;
         this._lifeBar._curHp = this.hp;
         this._lifeBar._totalHp = this.hp;
         this._lifeBar._totalHp = this.hp;
+        this._lifeBar.progressBar.progress = 1;
     }
     }
     update(deltaTime: number) {
     update(deltaTime: number) {
         if (this._lifeBar._curHp <= 0) {
         if (this._lifeBar._curHp <= 0) {
@@ -42,6 +46,7 @@ export class EnemyTower extends Role {
         const myTower = find("Canvas/GameRoot/MyTower").getComponent(MyTower);
         const myTower = find("Canvas/GameRoot/MyTower").getComponent(MyTower);
         this._lifePercent(myTower.getCurHp(), myTower.getTotalHp())
         this._lifePercent(myTower.getCurHp(), myTower.getTotalHp())
         GameMgr.Instance.getModuler(GameOver).show();
         GameMgr.Instance.getModuler(GameOver).show();
+        director.pause();
     }
     }
 
 
     private _lifePercent(curHp: number, totalHp: number) {
     private _lifePercent(curHp: number, totalHp: number) {

+ 55 - 25
assets/Script/Game/MyApp/GameScene/GameOver.ts

@@ -1,9 +1,13 @@
-import { _decorator, Director, director, EventKeyboard, find, Label, NodeEventType, } from 'cc';
+import { _decorator, director, EAxisDirection, Label, log, PhysicsSystem, } from 'cc';
 import { ModulerBase } from '../../GameFrameWork/ModulerBase';
 import { ModulerBase } from '../../GameFrameWork/ModulerBase';
 import { resMgr } from '../../../Frames/ResourcesMgr';
 import { resMgr } from '../../../Frames/ResourcesMgr';
 import { GameInfo } from '../../../GameInfo';
 import { GameInfo } from '../../../GameInfo';
-import { messageMgr } from '../../../Frames/MessageMgr';
 import { localDt } from '../../../Frames/LocalDt';
 import { localDt } from '../../../Frames/LocalDt';
+import { GameMgr } from '../../GameFrameWork/GameMgr';
+import { EnemyMgr } from './EnemyMgr';
+import { MyTower } from './MyTower';
+import { Bottom } from './Bottom';
+import { EnemyTower } from './EnemyTower';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('GameOver')
 @ccclass('GameOver')
@@ -46,9 +50,11 @@ export class GameOver extends ModulerBase {
     protected onStart(): void {
     protected onStart(): void {
         this.onBtnClick("_btnLeft", this._onBtnBack, this);
         this.onBtnClick("_btnLeft", this._onBtnBack, this);
         this.onBtnClick("_btnRight", this._onBtnRight, this);
         this.onBtnClick("_btnRight", this._onBtnRight, this);
+
         director.preloadScene("StartScene")
         director.preloadScene("StartScene")
     }
     }
     config() {
     config() {
+        GameInfo.Instance.setIsGameOver(true);
         this.getSprite("_gameOverUITitle").spriteFrame =
         this.getSprite("_gameOverUITitle").spriteFrame =
             GameInfo.Instance.getOverWin() ?
             GameInfo.Instance.getOverWin() ?
                 resMgr.getSpriteFrame("GameWin") :
                 resMgr.getSpriteFrame("GameWin") :
@@ -59,19 +65,19 @@ export class GameOver extends ModulerBase {
 
 
         this.getLabel("_lifePercent").string = `${GameInfo.Instance.getLifePecent()}%`;
         this.getLabel("_lifePercent").string = `${GameInfo.Instance.getLifePecent()}%`;
         this.getLabel("_killCount").string = `${GameInfo.Instance.getKillCount()}`;
         this.getLabel("_killCount").string = `${GameInfo.Instance.getKillCount()}`;
-        
+
         const kill: number = this.calculateReward(GameInfo.Instance.getKillCount(), this.KillRewardConfig);
         const kill: number = this.calculateReward(GameInfo.Instance.getKillCount(), this.KillRewardConfig);
         const life: number = this.calculateReward(GameInfo.Instance.getLifePecent(), this.LifeRewardConfig);
         const life: number = this.calculateReward(GameInfo.Instance.getLifePecent(), this.LifeRewardConfig);
-        const stageClear: number = this.calculateReward(GameInfo.Instance.getCurlv(), this.newresultRewardConfig);
-        
-        this.xp = GameInfo.Instance.getCurlv() * 30;
+        const stageClear: number = this.calculateReward(Number(GameInfo.Instance.getCurlv()), this.newresultRewardConfig);
+
+        this.xp = Number(GameInfo.Instance.getCurlv()) * 30;
         this.totalGold = kill + life + stageClear;
         this.totalGold = kill + life + stageClear;
-        
+
         const lifeDia: number = Math.floor(life * 0.08);
         const lifeDia: number = Math.floor(life * 0.08);
         const stageClearDia: number = Math.floor(stageClear * 0.07);
         const stageClearDia: number = Math.floor(stageClear * 0.07);
-        
+
         this.totalDia = lifeDia + stageClearDia;
         this.totalDia = lifeDia + stageClearDia;
-        
+
         this.getLabel("_kill").string = `${kill}`;
         this.getLabel("_kill").string = `${kill}`;
         this.getLabel("_life").string = `${life}`;
         this.getLabel("_life").string = `${life}`;
         this.getLabel("_stageClear").string = `${stageClear}`;
         this.getLabel("_stageClear").string = `${stageClear}`;
@@ -83,20 +89,26 @@ export class GameOver extends ModulerBase {
     }
     }
 
 
     private _onBtnBack() {
     private _onBtnBack() {
+        //director.purgeDirector();
         this.addReward();
         this.addReward();
         this.clearDt();
         this.clearDt();
         this.hide(false);
         this.hide(false);
-        director.loadScene("StartScene");
+        director.loadScene("StartScene", () => {
+            director.resume();
+            GameInfo.Instance.setIsGameOver(false);
+        });
     }
     }
 
 
     private _onBtnRight() {
     private _onBtnRight() {
-        if(GameInfo.Instance.getOverWin()){
-            this.addReward();
-            console.log("下一关")
+        director.resume();
+        GameInfo.Instance.setIsGameOver(false);
+        if (GameInfo.Instance.getOverWin()) {
+            //初始化场景
+            this._initGameScene();
         } else {
         } else {
-            console.log("重新开始")
+            //初始化场景
+            this._initGameScene();
         }
         }
-        this.clearDt();
     }
     }
 
 
     //计算奖励
     //计算奖励
@@ -111,24 +123,42 @@ export class GameOver extends ModulerBase {
     private clearDt() {
     private clearDt() {
         GameInfo.Instance.setKillCount(0);
         GameInfo.Instance.setKillCount(0);
         GameInfo.Instance.setLifePecent(0);
         GameInfo.Instance.setLifePecent(0);
-        GameInfo.Instance.setOverWin(false)
+        GameInfo.Instance.setOverWin(false);
     }
     }
 
 
-    private addReward(){
+    private addReward() {
         const map: Map<string, number> = new Map();
         const map: Map<string, number> = new Map();
-        map.set("GameOverRewardGold",this.totalGold + GameInfo.Instance.getGold());
+        map.set("GameOverRewardGold", (this.totalGold + Number(localDt.getData("Gold"))));
         map.set("GameOverRewardDia", this.totalDia + GameInfo.Instance.getDiamond());
         map.set("GameOverRewardDia", this.totalDia + GameInfo.Instance.getDiamond());
         map.set("Xp", this.xp + GameInfo.Instance.getCurGradeExp());
         map.set("Xp", this.xp + GameInfo.Instance.getCurGradeExp());
-        
-        if(GameInfo.Instance.getOverWin()){
-            GameInfo.Instance.setCurLv(GameInfo.Instance.getCurlv() + 1);
-            map.set("CurLv", GameInfo.Instance.getCurlv());
+
+        if (GameInfo.Instance.getOverWin()) {
+            GameInfo.Instance.setCurLv(Number(GameInfo.Instance.getCurlv()) + 1);
+            map.set("CurLv", Number(GameInfo.Instance.getCurlv()));
         }
         }
         GameInfo.Instance.setGameOverReward(map);
         GameInfo.Instance.setGameOverReward(map);
-        GameInfo.Instance.setGold(this.totalGold + GameInfo.Instance.getGold());
+        //GameInfo.Instance.setGold(this.totalGold + GameInfo.Instance.getGold());
+        localDt.saveData("Gold", this.totalGold + Number(localDt.getData("Gold")));
+
         GameInfo.Instance.setDiamond(this.totalDia + GameInfo.Instance.getDiamond());
         GameInfo.Instance.setDiamond(this.totalDia + GameInfo.Instance.getDiamond());
-        localDt.saveGold(GameInfo.Instance.getGold());
-        localDt.saveDiamond(GameInfo.Instance.getDiamond());
+        localDt.saveData("Diamond", GameInfo.Instance.getDiamond())
+    }
+
+    //初始化场景 重置数据
+    private _initGameScene() {
+        this.addReward();
+        this.clearDt();
+        GameMgr.Instance.getModuler(EnemyMgr).node.removeAllChildren();
+        this.node.parent.getChildByPath("Road/Roles").removeAllChildren();
+        this.node.parent.getChildByPath("BulletLayer").removeAllChildren();
+
+        GameMgr.Instance.getModuler(EnemyMgr).init();
+        this.node.parent.getComponentInChildren(EnemyTower).initData();
+        this.node.parent.getComponentInChildren(MyTower).initData();
+        GameMgr.Instance.getModuler(Bottom).initData();
+
+        //隐藏
+        this.hide(false);
     }
     }
 }
 }
 
 

+ 5 - 6
assets/Script/Game/MyApp/GameScene/LifeBar.ts

@@ -1,25 +1,24 @@
 import { _decorator, Component, ProgressBar } from 'cc';
 import { _decorator, Component, ProgressBar } from 'cc';
-import { Role, RoleState } from '../Role';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('LifeBar')
 @ccclass('LifeBar')
 export class LifeBar extends Component {
 export class LifeBar extends Component {
     _curHp: number = null;
     _curHp: number = null;
     _totalHp: number = null;
     _totalHp: number = null;
-    private _progressBar: ProgressBar = null;
+    progressBar: ProgressBar = null;
     protected onLoad(): void {
     protected onLoad(): void {
-        this._progressBar = this.node.getChildByName("ProgressBar").getComponent(ProgressBar);
+        this.progressBar = this.node.getChildByName("ProgressBar").getComponent(ProgressBar);
     }
     }
     start() {
     start() {
-        this._progressBar.progress = this._curHp / this._totalHp;
+        this.progressBar.progress = this._curHp / this._totalHp;
     }
     }
     updateProgressBar(hp: number) {
     updateProgressBar(hp: number) {
         this._curHp = hp;
         this._curHp = hp;
-        this._progressBar.progress = this._curHp / this._totalHp;
+        this.progressBar.progress = this._curHp / this._totalHp;
         if (hp <= 0) {
         if (hp <= 0) {
             // this._role.playAnimation(RoleState.Die);
             // this._role.playAnimation(RoleState.Die);
             this._curHp = 0;
             this._curHp = 0;
-            this._progressBar.progress = 0;
+            this.progressBar.progress = 0;
         }
         }
     }
     }
 }
 }

+ 6 - 1
assets/Script/Game/MyApp/GameScene/MyTower.ts

@@ -1,4 +1,4 @@
-import { _decorator, Label, PhysicsGroup} from 'cc';
+import { _decorator, director, Label, PhysicsGroup} from 'cc';
 import { Role } from '../Role';
 import { Role } from '../Role';
 import { LifeBar } from './LifeBar';
 import { LifeBar } from './LifeBar';
 import { Enemy } from './Enemy';
 import { Enemy } from './Enemy';
@@ -16,6 +16,9 @@ export class MyTower extends Role {
         this._strMyHp = this.node.getChildByPath("ProgressBar/Label").getComponent(Label);
         this._strMyHp = this.node.getChildByPath("ProgressBar/Label").getComponent(Label);
     }
     }
     start() {
     start() {
+        this.initData();
+    }
+    initData(){
         this.hp = GameInfo.Instance.getMyTowerHp();
         this.hp = GameInfo.Instance.getMyTowerHp();
         this._initLifeBar();
         this._initLifeBar();
     }
     }
@@ -24,6 +27,7 @@ export class MyTower extends Role {
     private _initLifeBar() {
     private _initLifeBar() {
         this._lifeBar._curHp = GameInfo.Instance.getMyTowerHp();
         this._lifeBar._curHp = GameInfo.Instance.getMyTowerHp();
         this._lifeBar._totalHp = GameInfo.Instance.getMyTowerHp();
         this._lifeBar._totalHp = GameInfo.Instance.getMyTowerHp();
+        this._lifeBar.progressBar.progress = 1;
     }
     }
 
 
     update(deltaTime: number) {
     update(deltaTime: number) {
@@ -46,6 +50,7 @@ export class MyTower extends Role {
         GameInfo.Instance.setOverWin(false);
         GameInfo.Instance.setOverWin(false);
         GameInfo.Instance.setLifePecent(0);
         GameInfo.Instance.setLifePecent(0);
         GameMgr.Instance.getModuler(GameOver).show();
         GameMgr.Instance.getModuler(GameOver).show();
+        director.pause();
     }
     }
 
 
     //必须实现抽象方法
     //必须实现抽象方法

+ 13 - 7
assets/Script/Game/MyApp/GameScene/Pause.ts

@@ -1,5 +1,6 @@
-import { _decorator, director } from 'cc';
+import { _decorator, director, PhysicsSystem2D } from 'cc';
 import { ModulerBase } from '../../GameFrameWork/ModulerBase';
 import { ModulerBase } from '../../GameFrameWork/ModulerBase';
+import { GameInfo } from '../../../GameInfo';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('Pause')
 @ccclass('Pause')
@@ -9,20 +10,25 @@ export class Pause extends ModulerBase {
         this.onBtnClick("_continue", this._onContinue, this);
         this.onBtnClick("_continue", this._onContinue, this);
         this.onBtnClick("_btnPause", this._onPause, this)
         this.onBtnClick("_btnPause", this._onPause, this)
     }
     }
-
-    private _onPause(){
+    //暂停
+    private _onPause() {
+        GameInfo.Instance.setIsGameOver(true);
         director.pause();
         director.pause();
         this.getNode("_pause").active = true;
         this.getNode("_pause").active = true;
     }
     }
+    //返回开始场景
     private _onBtnBack() {
     private _onBtnBack() {
-        director.resume();
         this.getNode("_pause").active = false;
         this.getNode("_pause").active = false;
-        director.preloadScene("StartScene");
-        director.loadScene("StartScene");
+        director.loadScene("StartScene", () => {
+            director.resume();
+            GameInfo.Instance.setIsGameOver(false);
+        });
     }
     }
-    private _onContinue(){
+    //继续游戏
+    private _onContinue() {
         this.getNode("_pause").active = false;
         this.getNode("_pause").active = false;
         director.resume();
         director.resume();
+        GameInfo.Instance.setIsGameOver(false)
     }
     }
 }
 }
 
 

+ 1 - 1
assets/Script/Game/MyApp/GameScene/TouchSkill.ts

@@ -1,4 +1,4 @@
-import { _decorator, animation, Animation, Component, EventTouch, instantiate, Label, Node, Sprite, UITransform, Vec2, Vec3 } from 'cc';
+import { _decorator, Animation, Component, EventTouch, instantiate, Label, Node, Sprite, UITransform, Vec2, Vec3 } from 'cc';
 import { GameInfo } from '../../../GameInfo';
 import { GameInfo } from '../../../GameInfo';
 import { resMgr } from '../../../Frames/ResourcesMgr';
 import { resMgr } from '../../../Frames/ResourcesMgr';
 import { LifeBar } from './LifeBar';
 import { LifeBar } from './LifeBar';

+ 8 - 23
assets/Script/Game/MyApp/Role.ts

@@ -1,4 +1,4 @@
-import { _decorator, Animation, AnimationClip, BoxCollider2D, Component, find, Node, PhysicsSystem2D, SpriteFrame, Vec2, Vec3 } from 'cc';
+import { _decorator, Animation, AnimationClip, Component, find, Node, PhysicsSystem2D, SpriteFrame, Vec2, Vec3 } from 'cc';
 import { RoleData } from '../../DataItem/ItemData';
 import { RoleData } from '../../DataItem/ItemData';
 import { resMgr } from '../../Frames/ResourcesMgr';
 import { resMgr } from '../../Frames/ResourcesMgr';
 import { Bullet } from './GameScene/Bullet';
 import { Bullet } from './GameScene/Bullet';
@@ -98,7 +98,6 @@ export class Role extends Component {
         this.node.setWorldPosition(pos);
         this.node.setWorldPosition(pos);
         this.bulletLayer = find("Canvas/GameRoot/BulletLayer");
         this.bulletLayer = find("Canvas/GameRoot/BulletLayer");
 
 
-        //this._setupPhysics();
     }
     }
 
 
     private _setRoleData(roleData: RoleData) {
     private _setRoleData(roleData: RoleData) {
@@ -108,13 +107,6 @@ export class Role extends Component {
         this.moveSpeed = roleData.moveSpeed;
         this.moveSpeed = roleData.moveSpeed;
     }
     }
 
 
-    // _setupPhysics() {
-    //     //确保有碰撞组件
-    //     const collider2D = this.getComponent(BoxCollider2D) || this.addComponent(BoxCollider2D);
-    //     collider2D.group = this._getCollisionGroup();
-    //     collider2D.apply();
-    // }
-
     //获取精灵帧组 
     //获取精灵帧组 
     /*
     /*
     count -> 精灵帧的数量 
     count -> 精灵帧的数量 
@@ -135,9 +127,12 @@ export class Role extends Component {
     update(deltaTime: number) {
     update(deltaTime: number) {
         
         
         if (this._state === RoleState.Die) return;
         if (this._state === RoleState.Die) return;
-
+        //只有游戏结束才能执行后续操作
+        if(GameInfo.Instance.getIsGameOver()) return;
+        
         if (!this.currentTarget) {
         if (!this.currentTarget) {
             this._handleMovement(deltaTime);
             this._handleMovement(deltaTime);
+            
             this._detectEnemies();
             this._detectEnemies();
         } else {
         } else {
             this._handleAttack(deltaTime);
             this._handleAttack(deltaTime);
@@ -158,7 +153,9 @@ export class Role extends Component {
 
 
     //寻敌
     //寻敌
     private _detectEnemies() {
     private _detectEnemies() {
+        //节点不可用,不寻敌
         if (!this.node.isValid) return;
         if (!this.node.isValid) return;
+        //游戏结束,不寻敌
         if(GameInfo.Instance.getIsGameOver()) return;
         if(GameInfo.Instance.getIsGameOver()) return;
         //const startPos = new Vec2(this.node.position.x, this.node.position.y);
         //const startPos = new Vec2(this.node.position.x, this.node.position.y);
         const startPos = this.node.position.clone();
         const startPos = this.node.position.clone();
@@ -242,18 +239,6 @@ export class Role extends Component {
 
 
     //将各个动画存储起来
     //将各个动画存储起来
     private _collectAni() {
     private _collectAni() {
-        // const moveAni: Animation = Tools.createAnimation(this._moveFrames, 8, this.node, AnimationClip.WrapMode.Loop)
-        // this._animations.set(RoleState.Move, moveAni);
-
-        // const atkAni: Animation = Tools.createAnimation(this._atkFrames, 8, this.node, AnimationClip.WrapMode.Loop)
-        // this._animations.set(RoleState.Attack, atkAni);
-
-        // const idleAni: Animation = Tools.createAnimation(this._idleFrames, 8, this.node, AnimationClip.WrapMode.Loop)
-        // this._animations.set(RoleState.Idle, idleAni);
-
-        // const dieAni: Animation = Tools.createAnimation(this._dieFrames, 8, this.node, AnimationClip.WrapMode.Normal)
-        // this._animations.set(RoleState.Die, dieAni);
-
         this._createClip(RoleState.Move, this._moveFrames, 8);
         this._createClip(RoleState.Move, this._moveFrames, 8);
         this._createClip(RoleState.Attack, this._atkFrames, 6);
         this._createClip(RoleState.Attack, this._atkFrames, 6);
         this._createClip(RoleState.Idle, this._idleFrames, 8);
         this._createClip(RoleState.Idle, this._idleFrames, 8);
@@ -299,7 +284,7 @@ export class Role extends Component {
 
 
     private _switchState(state: RoleState, clipName: string) {
     private _switchState(state: RoleState, clipName: string) {
         this._state = state;
         this._state = state;
-        this._animation.stop();
+        //this._animation.stop();
         this._animation.play(clipName);
         this._animation.play(clipName);
 
 
         if (state === RoleState.Die) {
         if (state === RoleState.Die) {

+ 1 - 4
assets/Script/Game/MyApp/SelectTroopsBottom.ts

@@ -1,8 +1,5 @@
-import { _decorator, Button, Component, director, find, Node, resources, Sprite, SpriteFrame } from 'cc';
+import { _decorator, Button, Component, director, Node,  Sprite, SpriteFrame } from 'cc';
 import { GameInfo } from '../../GameInfo';
 import { GameInfo } from '../../GameInfo';
-import { UIMgr } from '../../Frames/UIManager';
-import { GameMgr } from '../GameFrameWork/GameMgr';
-import { BattleSceneTop } from '../UI/BattleSceneTop';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('SelectTroopsBottom')
 @ccclass('SelectTroopsBottom')

+ 4 - 4
assets/Script/Game/UI/BattleSceneLeft.ts

@@ -16,7 +16,7 @@ export class BattleSceneLeft extends ModulerBase {
         this.editBox = this.getComponentInChildren(EditBox);
         this.editBox = this.getComponentInChildren(EditBox);
         this._setEdit();
         this._setEdit();
         
         
-        this._curLv(GameInfo.Instance.getCurlv());
+        this._curLv(Number(GameInfo.Instance.getCurlv()));
         this.onBtnClick("_btnLevel", this._btnLevel);
         this.onBtnClick("_btnLevel", this._btnLevel);
         if(GameInfo.Instance.getOverWin() && GameInfo.Instance.getGameOverReward().size != 0){
         if(GameInfo.Instance.getOverWin() && GameInfo.Instance.getGameOverReward().size != 0){
             this._curLv(GameInfo.Instance.getGameOverReward().get("CurLv"));
             this._curLv(GameInfo.Instance.getGameOverReward().get("CurLv"));
@@ -36,12 +36,12 @@ export class BattleSceneLeft extends ModulerBase {
 
 
     //保存名字
     //保存名字
     private _onEdit(editbox: EditBox){
     private _onEdit(editbox: EditBox){
-        localDt.savePlayerName(editbox.string);
+        localDt.saveData("PlayerName",editbox.string);
     }
     }
 
 
     private _setEdit(){
     private _setEdit(){
-        if(localDt.getPlayerName()){
-            this.editBox.string = localDt.getPlayerName();
+        if(localDt.getData("PlayerName")){
+            this.editBox.string = String(localDt.getData("PlayerName"));
         }
         }
     }
     }
 }
 }

+ 3 - 1
assets/Script/Game/UI/BattleSceneTop.ts

@@ -5,6 +5,7 @@ import { ModulerBase } from '../GameFrameWork/ModulerBase';
 import { GameMgr } from '../GameFrameWork/GameMgr';
 import { GameMgr } from '../GameFrameWork/GameMgr';
 import { SelectTroops } from './SelectTroops';
 import { SelectTroops } from './SelectTroops';
 import { messageMgr } from '../../Frames/MessageMgr';
 import { messageMgr } from '../../Frames/MessageMgr';
+import { localDt } from '../../Frames/LocalDt';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('BattleSceneTop')
 @ccclass('BattleSceneTop')
@@ -12,7 +13,8 @@ export class BattleSceneTop extends ModulerBase {
 
 
     protected onStart() {
     protected onStart() {
         this.onBtnClick("_btnReturn", this._btnReturn);
         this.onBtnClick("_btnReturn", this._btnReturn);
-        this._gold(GameInfo.Instance.getGold());
+        //this._gold(GameInfo.Instance.getGold());
+        this._gold(Number(localDt.getData("Gold")));
         this._diamond(GameInfo.Instance.getDiamond());
         this._diamond(GameInfo.Instance.getDiamond());
         this.battleMode("战斗模式");
         this.battleMode("战斗模式");
         messageMgr.addEvent("reduceGold", this._gold, this);
         messageMgr.addEvent("reduceGold", this._gold, this);

+ 1 - 1
assets/Script/Game/UI/LoadingUI.ts

@@ -45,7 +45,7 @@ export class LoadingUI extends Component {
     }
     }
     public updateWhichRes(which: number){
     public updateWhichRes(which: number){
         if(this.whichRes){
         if(this.whichRes){
-            this.whichRes.string = `${which}/2`;
+            this.whichRes.string = `${which}/3`;
         }
         }
     }
     }
 }
 }

+ 7 - 5
assets/Script/Game/UI/PopupUI.ts

@@ -5,9 +5,9 @@ import { PopupUIDataConfig } from '../MyApp/GameScene/Data/PopupUIDataConfig';
 import { UIMgr } from '../../Frames/UIManager';
 import { UIMgr } from '../../Frames/UIManager';
 import { GameInfo } from '../../GameInfo';
 import { GameInfo } from '../../GameInfo';
 import { Tip } from './Tip';
 import { Tip } from './Tip';
-import { messageMgr } from '../../Frames/MessageMgr';
 import { GameMgr } from '../GameFrameWork/GameMgr';
 import { GameMgr } from '../GameFrameWork/GameMgr';
 import { BattleSceneTop } from './BattleSceneTop';
 import { BattleSceneTop } from './BattleSceneTop';
+import { localDt } from '../../Frames/LocalDt';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('PopupUI')
 @ccclass('PopupUI')
@@ -77,7 +77,8 @@ export class PopupUI extends UIBase {
         // }
         // }
         const resourceMap = {
         const resourceMap = {
             "Gold": {
             "Gold": {
-                getAmount: GameInfo.Instance.getGold(),
+                //getAmount: GameInfo.Instance.getGold(),
+                getAmount: localDt.getData("Gold"),
                 message: "金币不足!",
                 message: "金币不足!",
             },
             },
             "Diamond": {
             "Diamond": {
@@ -90,8 +91,8 @@ export class PopupUI extends UIBase {
         //消耗
         //消耗
         const consume: number = Number(this._consume);
         const consume: number = Number(this._consume);
         //总共
         //总共
-        const totalGold: number = GameInfo.Instance.getGold();
-        
+        //const totalGold: number = GameInfo.Instance.getGold();
+        const totalGold: number = Number(localDt.getData("Gold"));
         if (resource && Number(this._consume) > resource.getAmount) {
         if (resource && Number(this._consume) > resource.getAmount) {
             const tip: Node = instantiate(resMgr.getPrefab("Tip"));
             const tip: Node = instantiate(resMgr.getPrefab("Tip"));
             tip.getComponent(Tip).setContent(resource.message);
             tip.getComponent(Tip).setContent(resource.message);
@@ -100,7 +101,8 @@ export class PopupUI extends UIBase {
         }
         }
         GameMgr.Instance.getModuler(BattleSceneTop)._gold((totalGold - consume));
         GameMgr.Instance.getModuler(BattleSceneTop)._gold((totalGold - consume));
         //messageMgr.dispatch("reduceGold", (totalGold - consume));
         //messageMgr.dispatch("reduceGold", (totalGold - consume));
-        GameInfo.Instance.setGold((totalGold - consume));
+        //GameInfo.Instance.setGold((totalGold - consume));
+        localDt.saveData("Gold", Number(totalGold - consume));
         (PopupUIDataConfig.Instance.getFunction())();
         (PopupUIDataConfig.Instance.getFunction())();
         UIMgr.closeUI("PopupUI", true);
         UIMgr.closeUI("PopupUI", true);
         PopupUIDataConfig.Instance.clearDt();
         PopupUIDataConfig.Instance.clearDt();

+ 1 - 1
assets/Script/Game/UI/SelectTroops.ts

@@ -6,7 +6,7 @@ const { ccclass, property } = _decorator;
 @ccclass('SelectTroops')
 @ccclass('SelectTroops')
 export class SelectTroops extends ModulerBase {
 export class SelectTroops extends ModulerBase {
     protected onStart() {
     protected onStart() {
-        this._setLvNumber(GameInfo.Instance.getCurlv());
+        this._setLvNumber(Number(GameInfo.Instance.getCurlv()));
         this._setOreGrade(GameInfo.Instance.getOreGrade());
         this._setOreGrade(GameInfo.Instance.getOreGrade());
         this._setOreSpeed(GameInfo.Instance.getOreSpeed());
         this._setOreSpeed(GameInfo.Instance.getOreSpeed());
     }
     }

+ 9 - 2
assets/Script/Game/UI/Start.ts

@@ -1,13 +1,15 @@
 import { _decorator } from 'cc';
 import { _decorator } from 'cc';
 import { UIBase } from '../GameFrameWork/UIBase';
 import { UIBase } from '../GameFrameWork/UIBase';
 import { UIMgr } from '../../Frames/UIManager';
 import { UIMgr } from '../../Frames/UIManager';
+import { localDt } from '../../Frames/LocalDt';
 const { ccclass, property } = _decorator;
 const { ccclass, property } = _decorator;
 
 
 @ccclass('Start')
 @ccclass('Start')
 export class Start extends UIBase {
 export class Start extends UIBase {
     protected onStart() {
     protected onStart() {
-        this.onBtnClick("_btnStart", this._btnStart);
-        this.onBtnClick("_btnMusic", this._btnMusic);
+        this.onBtnClick("_btnStart", this._btnStart, this);
+        this.onBtnClick("_btnMusic", this._btnMusic, this);
+        this.onBtnClick("_clearData", this._btnClearDt, this)
     }
     }
 
 
     private _btnStart() {
     private _btnStart() {
@@ -17,6 +19,11 @@ export class Start extends UIBase {
     private _btnMusic() {
     private _btnMusic() {
 
 
     }
     }
+
+    //清除本地数据
+    private _btnClearDt(){
+        localDt.clearAll();
+    }
 }
 }
 
 
 
 

+ 6 - 4
assets/Script/GameInfo.ts

@@ -1,3 +1,5 @@
+import { localDt } from "./Frames/LocalDt";
+
 export class GameInfo {
 export class GameInfo {
 
 
     private static _instance: GameInfo = null;
     private static _instance: GameInfo = null;
@@ -58,8 +60,8 @@ export class GameInfo {
     }
     }
 
 
     //关卡
     //关卡
-    getCurlv(): number { return this._curlv };
-    setCurLv(lv: number) { this._curlv = lv };
+    getCurlv(): number { return Number(localDt.getData("curLv")) };
+    setCurLv(lv: number) { localDt.saveData("curLv",lv) };
 
 
     //获胜场数
     //获胜场数
     getWin(): number { return this._winNumber };
     getWin(): number { return this._winNumber };
@@ -74,8 +76,8 @@ export class GameInfo {
     setGold(gold: number) { this._goldAmount = gold };
     setGold(gold: number) { this._goldAmount = gold };
 
 
     //钻石数量
     //钻石数量
-    getDiamond(): number { return this._diamondAmout };
-    setDiamond(diamond: number) { this._diamondAmout = diamond };
+    getDiamond(): number { return Number(localDt.getData("Diamond")) };
+    setDiamond(diamond: number) { localDt.saveData("Diamond",diamond) };
 
 
     //玩家账号等级
     //玩家账号等级
     getGrade(): number { return this._grade };
     getGrade(): number { return this._grade };

+ 449 - 12
assets/resources/UI/Start.prefab

@@ -23,25 +23,28 @@
       },
       },
       {
       {
         "__id__": 12
         "__id__": 12
+      },
+      {
+        "__id__": 22
       }
       }
     ],
     ],
     "_active": true,
     "_active": true,
     "_components": [
     "_components": [
       {
       {
-        "__id__": 22
+        "__id__": 40
       },
       },
       {
       {
-        "__id__": 24
+        "__id__": 42
       },
       },
       {
       {
-        "__id__": 26
+        "__id__": 44
       },
       },
       {
       {
-        "__id__": 28
+        "__id__": 46
       }
       }
     ],
     ],
     "_prefab": {
     "_prefab": {
-      "__id__": 30
+      "__id__": 48
     },
     },
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
@@ -102,7 +105,7 @@
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
       "x": 390,
       "x": 390,
-      "y": 300,
+      "y": 300.08492569002124,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -344,7 +347,7 @@
     "_lpos": {
     "_lpos": {
       "__type__": "cc.Vec3",
       "__type__": "cc.Vec3",
       "x": 0,
       "x": 0,
-      "y": -140,
+      "y": -140.08492569002124,
       "z": 0
       "z": 0
     },
     },
     "_lrot": {
     "_lrot": {
@@ -553,22 +556,456 @@
     "targetOverrides": null,
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
     "nestedPrefabInstanceRoots": null
   },
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "_clearData",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [
+      {
+        "__id__": 23
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 31
+      },
+      {
+        "__id__": 33
+      },
+      {
+        "__id__": 35
+      },
+      {
+        "__id__": 37
+      }
+    ],
+    "_prefab": {
+      "__id__": 39
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 500.0585,
+      "y": 300.88492569002125,
+      "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": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Label",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 22
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 24
+      },
+      {
+        "__id__": 26
+      },
+      {
+        "__id__": 28
+      }
+    ],
+    "_prefab": {
+      "__id__": 30
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "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": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
   {
   {
     "__type__": "cc.UITransform",
     "__type__": "cc.UITransform",
     "_name": "",
     "_name": "",
     "_objFlags": 0,
     "_objFlags": 0,
     "__editorExtras__": {},
     "__editorExtras__": {},
     "node": {
     "node": {
-      "__id__": 1
+      "__id__": 23
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 25
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 80,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "91bx98BWFLx7OFs+y+Daf/"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 23
     },
     },
     "_enabled": true,
     "_enabled": true,
     "__prefab": {
     "__prefab": {
+      "__id__": 27
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_string": "清除数据",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 20,
+    "_fontSize": 20,
+    "_fontFamily": "Arial",
+    "_lineHeight": 40,
+    "_overflow": 0,
+    "_enableWrapText": true,
+    "_font": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_isItalic": false,
+    "_isBold": false,
+    "_isUnderline": false,
+    "_underlineHeight": 2,
+    "_cacheMode": 0,
+    "_enableOutline": false,
+    "_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": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "95CZos6npFLZzerZdM6XMb"
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
       "__id__": 23
       "__id__": 23
     },
     },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 29
+    },
+    "_alignFlags": 45,
+    "_target": null,
+    "_left": 20,
+    "_right": 20,
+    "_top": -6,
+    "_bottom": -6,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": true,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 42.255859375,
+    "_originalHeight": 50.4,
+    "_alignMode": 2,
+    "_lockFlags": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "1cY3pIpzFLNbDiJNilR9FC"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "22kqxw34tLeqAUBQjg0msb",
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 22
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 32
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 120,
+      "height": 38.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "e5JcZ9mWRHObVC0lfEvNLp"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 22
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 34
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "1440ddfa-68c4-4328-bf37-600cd18f4812@afe4a",
+      "__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": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "14ze42OFJNEJj2b57MCV4g"
+  },
+  {
+    "__type__": "cc.Button",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 22
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 36
+    },
+    "clickEvents": [],
+    "_interactable": true,
+    "_transition": 3,
+    "_normalColor": {
+      "__type__": "cc.Color",
+      "r": 214,
+      "g": 214,
+      "b": 214,
+      "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": {
+      "__id__": 22
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "a6efazfSNDHLg12L+q4x44"
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 22
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 38
+    },
+    "_alignFlags": 33,
+    "_target": null,
+    "_left": 0,
+    "_right": 79.94150000000002,
+    "_top": 40,
+    "_bottom": 0,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_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": "98/92TGGVJBq+PofiSrReP"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "30mXoUqN5MUZk6iAqSPXpV",
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 41
+    },
     "_contentSize": {
     "_contentSize": {
       "__type__": "cc.Size",
       "__type__": "cc.Size",
       "width": 1280,
       "width": 1280,
-      "height": 720
+      "height": 720.1698513800425
     },
     },
     "_anchorPoint": {
     "_anchorPoint": {
       "__type__": "cc.Vec2",
       "__type__": "cc.Vec2",
@@ -591,7 +1028,7 @@
     },
     },
     "_enabled": true,
     "_enabled": true,
     "__prefab": {
     "__prefab": {
-      "__id__": 25
+      "__id__": 43
     },
     },
     "_customMaterial": null,
     "_customMaterial": null,
     "_srcBlendFactor": 2,
     "_srcBlendFactor": 2,
@@ -636,7 +1073,7 @@
     },
     },
     "_enabled": true,
     "_enabled": true,
     "__prefab": {
     "__prefab": {
-      "__id__": 27
+      "__id__": 45
     },
     },
     "_alignFlags": 45,
     "_alignFlags": 45,
     "_target": null,
     "_target": null,
@@ -672,7 +1109,7 @@
     },
     },
     "_enabled": true,
     "_enabled": true,
     "__prefab": {
     "__prefab": {
-      "__id__": 29
+      "__id__": 47
     },
     },
     "_id": ""
     "_id": ""
   },
   },

+ 0 - 3
build-templates/templates-version.json

@@ -1,3 +0,0 @@
-{
-    "wechatgame": "1.0.0"
-}

+ 0 - 80
build-templates/wechatgame/game.ejs

@@ -1,80 +0,0 @@
-function __initApp () {  // init app
-globalThis.__wxRequire = require;  // FIX: require cannot work in separate engine 
-require('./web-adapter');
-const firstScreen = require('./first-screen');
-
-<%- include(cocosTemplate, {}) %>
-
-// Adapt for IOS, swap if opposite
-const info = wx.getSystemInfoSync();
-if (canvas){
-    var _w = canvas.width;
-    var _h = canvas.height;
-    if (info.screenWidth < info.screenHeight) {
-        if (canvas.width > canvas.height) {
-            _w = canvas.height;
-            _h = canvas.width;
-        }
-    } else {
-        if (canvas.width < canvas.height) {
-            _w = canvas.height;
-            _h = canvas.width;
-        }
-    }
-    canvas.width = _w;
-    canvas.height = _h;
-}
-// Adjust initial canvas size
-if (canvas && window.devicePixelRatio >= 2) {canvas.width *= info.devicePixelRatio; canvas.height *= info.devicePixelRatio;}
-
-const importMap = require("<%= importMapFile%>").default;
-System.warmup({
-    importMap,
-    importMapUrl: '<%= importMapFile%>',
-    defaultHandler: (urlNoSchema) => {
-        require('.' + urlNoSchema);
-    },
-    handlers: {
-        'plugin:': (urlNoSchema) => {
-            requirePlugin(urlNoSchema);
-        },
-        'project:': (urlNoSchema) => {
-            require(urlNoSchema);
-        },
-    },
-});
-
-firstScreen.start('<%= alpha %>', '<%= antialias %>', '<%= useWebgl2 %>').then(() => {
-    return System.import('<%= applicationJs %>');
-}).then((module) => {
-    return firstScreen.setProgress(0.2).then(() => Promise.resolve(module));
-}).then(({ Application }) => {
-    return new Application();
-}).then((application) => {
-    return firstScreen.setProgress(0.4).then(() => Promise.resolve(application));
-}).then((application) => {
-    return onApplicationCreated(application);
-}).catch((err) => {
-    console.error(err);
-});
-
-function onApplicationCreated(application) {
-    return System.import('cc').then((module) => {
-        return firstScreen.setProgress(0.6).then(() => Promise.resolve(module));
-    }).then((cc) => {
-        require('./engine-adapter');
-        return application.init(cc);
-    }).then(() => {
-        return firstScreen.end().then(() => application.start());
-    });
-}
-
-}  // init app
-
-// NOTE: on WeChat Android end, we can only get the correct screen size at the second tick of game.
-var sysInfo = wx.getSystemInfoSync();
-if (sysInfo.platform.toLocaleLowerCase() === 'android') {
-    GameGlobal.requestAnimationFrame (__initApp);
-} else {
-    __initApp();
-}

+ 0 - 10
build-templates/wechatgame/game.json

@@ -1,10 +0,0 @@
-{
-  "deviceOrientation": "portrait",
-  "openDataContext": "",
-  "networkTimeout": {
-    "request": 5000,
-    "connectSocket": 5000,
-    "uploadFile": 5000,
-    "downloadFile": 500000
-  }
-}

+ 0 - 35
build-templates/wechatgame/project.config.json

@@ -1,35 +0,0 @@
-{
-    "description": "项目配置文件。",
-    "miniprogramRoot": "./",
-    "setting": {
-        "urlCheck": true,
-        "postcss": true,
-        "minified": true,
-        "newFeature": false,
-        "enhance": true,
-        "useIsolateContext": true
-    },
-    "compileType": "game",
-    "libVersion": "game",
-    "appid": "",
-    "projectname": "",
-    "condition": {
-        "search": {
-            "current": -1,
-            "list": []
-        },
-        "conversation": {
-            "current": -1,
-            "list": []
-        },
-        "game": {
-            "currentL": -1,
-            "list": [],
-            "current": -1
-        },
-        "miniprogram": {
-            "current": -1,
-            "list": []
-        }
-    }
-}