Sfoglia il codice sorgente

【修改】新增调试工具

DESKTOP-VHLO35R\Administrator 1 anno fa
parent
commit
6789c442ad

+ 7 - 0
assets/resources/edt_prefab/Debug.meta

@@ -0,0 +1,7 @@
1
+{
2
+  "ver": "1.0.1",
3
+  "uuid": "c24e7d10-9ff0-4441-97d8-f28177603f10",
4
+  "isSubpackage": false,
5
+  "subpackageName": "",
6
+  "subMetas": {}
7
+}

File diff suppressed because it is too large
+ 2400 - 0
assets/resources/edt_prefab/Debug/debug_alert.prefab


+ 8 - 0
assets/resources/edt_prefab/Debug/debug_alert.prefab.meta

@@ -0,0 +1,8 @@
1
+{
2
+  "ver": "1.2.6",
3
+  "uuid": "d5d7f67a-189d-45bc-94b1-336d432402a8",
4
+  "optimizationPolicy": "AUTO",
5
+  "asyncLoadAssets": false,
6
+  "readonly": false,
7
+  "subMetas": {}
8
+}

+ 462 - 0
assets/resources/edt_prefab/Debug/debug_enter.prefab

@@ -0,0 +1,462 @@
1
+[
2
+  {
3
+    "__type__": "cc.Prefab",
4
+    "_name": "",
5
+    "_objFlags": 0,
6
+    "_native": "",
7
+    "data": {
8
+      "__id__": 1
9
+    },
10
+    "optimizationPolicy": 0,
11
+    "asyncLoadAssets": false,
12
+    "readonly": false
13
+  },
14
+  {
15
+    "__type__": "cc.Node",
16
+    "_name": "debug_enter",
17
+    "_objFlags": 0,
18
+    "_parent": null,
19
+    "_children": [
20
+      {
21
+        "__id__": 2
22
+      }
23
+    ],
24
+    "_active": true,
25
+    "_components": [
26
+      {
27
+        "__id__": 11
28
+      },
29
+      {
30
+        "__id__": 12
31
+      }
32
+    ],
33
+    "_prefab": {
34
+      "__id__": 13
35
+    },
36
+    "_opacity": 255,
37
+    "_color": {
38
+      "__type__": "cc.Color",
39
+      "r": 255,
40
+      "g": 255,
41
+      "b": 255,
42
+      "a": 255
43
+    },
44
+    "_contentSize": {
45
+      "__type__": "cc.Size",
46
+      "width": 810,
47
+      "height": 1440
48
+    },
49
+    "_anchorPoint": {
50
+      "__type__": "cc.Vec2",
51
+      "x": 0,
52
+      "y": 0
53
+    },
54
+    "_trs": {
55
+      "__type__": "TypedArray",
56
+      "ctor": "Float64Array",
57
+      "array": [
58
+        0,
59
+        0,
60
+        0,
61
+        0,
62
+        0,
63
+        0,
64
+        1,
65
+        1,
66
+        1,
67
+        1
68
+      ]
69
+    },
70
+    "_eulerAngles": {
71
+      "__type__": "cc.Vec3",
72
+      "x": 0,
73
+      "y": 0,
74
+      "z": 0
75
+    },
76
+    "_skewX": 0,
77
+    "_skewY": 0,
78
+    "_is3DNode": false,
79
+    "_groupIndex": 0,
80
+    "groupIndex": 0,
81
+    "_id": ""
82
+  },
83
+  {
84
+    "__type__": "cc.Node",
85
+    "_name": "btn",
86
+    "_objFlags": 0,
87
+    "_parent": {
88
+      "__id__": 1
89
+    },
90
+    "_children": [
91
+      {
92
+        "__id__": 3
93
+      },
94
+      {
95
+        "__id__": 6
96
+      }
97
+    ],
98
+    "_active": true,
99
+    "_components": [
100
+      {
101
+        "__id__": 9
102
+      }
103
+    ],
104
+    "_prefab": {
105
+      "__id__": 10
106
+    },
107
+    "_opacity": 169,
108
+    "_color": {
109
+      "__type__": "cc.Color",
110
+      "r": 255,
111
+      "g": 255,
112
+      "b": 255,
113
+      "a": 255
114
+    },
115
+    "_contentSize": {
116
+      "__type__": "cc.Size",
117
+      "width": 132,
118
+      "height": 66
119
+    },
120
+    "_anchorPoint": {
121
+      "__type__": "cc.Vec2",
122
+      "x": 0.5,
123
+      "y": 0.5
124
+    },
125
+    "_trs": {
126
+      "__type__": "TypedArray",
127
+      "ctor": "Float64Array",
128
+      "array": [
129
+        405,
130
+        1418,
131
+        0,
132
+        0,
133
+        0,
134
+        0,
135
+        1,
136
+        1,
137
+        1,
138
+        1
139
+      ]
140
+    },
141
+    "_eulerAngles": {
142
+      "__type__": "cc.Vec3",
143
+      "x": 0,
144
+      "y": 0,
145
+      "z": 0
146
+    },
147
+    "_skewX": 0,
148
+    "_skewY": 0,
149
+    "_is3DNode": false,
150
+    "_groupIndex": 0,
151
+    "groupIndex": 0,
152
+    "_id": ""
153
+  },
154
+  {
155
+    "__type__": "cc.Node",
156
+    "_name": "bg",
157
+    "_objFlags": 0,
158
+    "_parent": {
159
+      "__id__": 2
160
+    },
161
+    "_children": [],
162
+    "_active": true,
163
+    "_components": [
164
+      {
165
+        "__id__": 4
166
+      }
167
+    ],
168
+    "_prefab": {
169
+      "__id__": 5
170
+    },
171
+    "_opacity": 255,
172
+    "_color": {
173
+      "__type__": "cc.Color",
174
+      "r": 255,
175
+      "g": 255,
176
+      "b": 255,
177
+      "a": 255
178
+    },
179
+    "_contentSize": {
180
+      "__type__": "cc.Size",
181
+      "width": 132,
182
+      "height": 66
183
+    },
184
+    "_anchorPoint": {
185
+      "__type__": "cc.Vec2",
186
+      "x": 0.5,
187
+      "y": 0.5
188
+    },
189
+    "_trs": {
190
+      "__type__": "TypedArray",
191
+      "ctor": "Float64Array",
192
+      "array": [
193
+        0,
194
+        0,
195
+        0,
196
+        0,
197
+        0,
198
+        0,
199
+        1,
200
+        1,
201
+        1,
202
+        1
203
+      ]
204
+    },
205
+    "_eulerAngles": {
206
+      "__type__": "cc.Vec3",
207
+      "x": 0,
208
+      "y": 0,
209
+      "z": 0
210
+    },
211
+    "_skewX": 0,
212
+    "_skewY": 0,
213
+    "_is3DNode": false,
214
+    "_groupIndex": 0,
215
+    "groupIndex": 0,
216
+    "_id": ""
217
+  },
218
+  {
219
+    "__type__": "cc.Sprite",
220
+    "_name": "",
221
+    "_objFlags": 0,
222
+    "node": {
223
+      "__id__": 3
224
+    },
225
+    "_enabled": true,
226
+    "_materials": [
227
+      {
228
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
229
+      }
230
+    ],
231
+    "_srcBlendFactor": 770,
232
+    "_dstBlendFactor": 771,
233
+    "_spriteFrame": {
234
+      "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
235
+    },
236
+    "_type": 0,
237
+    "_sizeMode": 0,
238
+    "_fillType": 0,
239
+    "_fillCenter": {
240
+      "__type__": "cc.Vec2",
241
+      "x": 0,
242
+      "y": 0
243
+    },
244
+    "_fillStart": 0,
245
+    "_fillRange": 0,
246
+    "_isTrimmedMode": true,
247
+    "_atlas": null,
248
+    "_id": ""
249
+  },
250
+  {
251
+    "__type__": "cc.PrefabInfo",
252
+    "root": {
253
+      "__id__": 1
254
+    },
255
+    "asset": {
256
+      "__uuid__": "005f289d-dd76-447f-864e-215f62b43e8e"
257
+    },
258
+    "fileId": "c3hx4mnllGKbPIwGt8xk4n",
259
+    "sync": false
260
+  },
261
+  {
262
+    "__type__": "cc.Node",
263
+    "_name": "label",
264
+    "_objFlags": 0,
265
+    "_parent": {
266
+      "__id__": 2
267
+    },
268
+    "_children": [],
269
+    "_active": true,
270
+    "_components": [
271
+      {
272
+        "__id__": 7
273
+      }
274
+    ],
275
+    "_prefab": {
276
+      "__id__": 8
277
+    },
278
+    "_opacity": 255,
279
+    "_color": {
280
+      "__type__": "cc.Color",
281
+      "r": 155,
282
+      "g": 155,
283
+      "b": 155,
284
+      "a": 255
285
+    },
286
+    "_contentSize": {
287
+      "__type__": "cc.Size",
288
+      "width": 90,
289
+      "height": 83.16
290
+    },
291
+    "_anchorPoint": {
292
+      "__type__": "cc.Vec2",
293
+      "x": 0.5,
294
+      "y": 0.5
295
+    },
296
+    "_trs": {
297
+      "__type__": "TypedArray",
298
+      "ctor": "Float64Array",
299
+      "array": [
300
+        0,
301
+        0,
302
+        0,
303
+        0,
304
+        0,
305
+        0,
306
+        1,
307
+        1,
308
+        1,
309
+        1
310
+      ]
311
+    },
312
+    "_eulerAngles": {
313
+      "__type__": "cc.Vec3",
314
+      "x": 0,
315
+      "y": 0,
316
+      "z": 0
317
+    },
318
+    "_skewX": 0,
319
+    "_skewY": 0,
320
+    "_is3DNode": false,
321
+    "_groupIndex": 0,
322
+    "groupIndex": 0,
323
+    "_id": ""
324
+  },
325
+  {
326
+    "__type__": "cc.Label",
327
+    "_name": "",
328
+    "_objFlags": 0,
329
+    "node": {
330
+      "__id__": 6
331
+    },
332
+    "_enabled": true,
333
+    "_materials": [
334
+      {
335
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
336
+      }
337
+    ],
338
+    "_useOriginalSize": false,
339
+    "_string": "调 试",
340
+    "_N$string": "调 试",
341
+    "_fontSize": 40,
342
+    "_lineHeight": 66,
343
+    "_enableWrapText": true,
344
+    "_N$file": {
345
+      "__uuid__": "6e82bca4-2312-41ba-bf07-3e4065619cf9"
346
+    },
347
+    "_isSystemFontUsed": false,
348
+    "_spacingX": 0,
349
+    "_batchAsBitmap": false,
350
+    "_styleFlags": 0,
351
+    "_underlineHeight": 0,
352
+    "_N$horizontalAlign": 1,
353
+    "_N$verticalAlign": 1,
354
+    "_N$fontFamily": "Arial",
355
+    "_N$overflow": 0,
356
+    "_N$cacheMode": 0,
357
+    "_id": ""
358
+  },
359
+  {
360
+    "__type__": "cc.PrefabInfo",
361
+    "root": {
362
+      "__id__": 1
363
+    },
364
+    "asset": {
365
+      "__uuid__": "005f289d-dd76-447f-864e-215f62b43e8e"
366
+    },
367
+    "fileId": "4arNlESoBEN7SIS83nZ0HF",
368
+    "sync": false
369
+  },
370
+  {
371
+    "__type__": "cc.Widget",
372
+    "_name": "",
373
+    "_objFlags": 0,
374
+    "node": {
375
+      "__id__": 2
376
+    },
377
+    "_enabled": true,
378
+    "alignMode": 1,
379
+    "_target": null,
380
+    "_alignFlags": 17,
381
+    "_left": 0,
382
+    "_right": 0,
383
+    "_top": -11,
384
+    "_bottom": 0,
385
+    "_verticalCenter": 0,
386
+    "_horizontalCenter": 0,
387
+    "_isAbsLeft": true,
388
+    "_isAbsRight": true,
389
+    "_isAbsTop": true,
390
+    "_isAbsBottom": true,
391
+    "_isAbsHorizontalCenter": true,
392
+    "_isAbsVerticalCenter": true,
393
+    "_originalWidth": 0,
394
+    "_originalHeight": 0,
395
+    "_id": ""
396
+  },
397
+  {
398
+    "__type__": "cc.PrefabInfo",
399
+    "root": {
400
+      "__id__": 1
401
+    },
402
+    "asset": {
403
+      "__uuid__": "005f289d-dd76-447f-864e-215f62b43e8e"
404
+    },
405
+    "fileId": "7euFiA3eJPT48Ozv0DFO1q",
406
+    "sync": false
407
+  },
408
+  {
409
+    "__type__": "cc.Widget",
410
+    "_name": "",
411
+    "_objFlags": 0,
412
+    "node": {
413
+      "__id__": 1
414
+    },
415
+    "_enabled": true,
416
+    "alignMode": 1,
417
+    "_target": null,
418
+    "_alignFlags": 45,
419
+    "_left": 0,
420
+    "_right": 0,
421
+    "_top": 0,
422
+    "_bottom": 0,
423
+    "_verticalCenter": 0,
424
+    "_horizontalCenter": 0,
425
+    "_isAbsLeft": true,
426
+    "_isAbsRight": true,
427
+    "_isAbsTop": true,
428
+    "_isAbsBottom": true,
429
+    "_isAbsHorizontalCenter": true,
430
+    "_isAbsVerticalCenter": true,
431
+    "_originalWidth": 0,
432
+    "_originalHeight": 0,
433
+    "_id": ""
434
+  },
435
+  {
436
+    "__type__": "43dfc+9iBZL1oHff40fr4/F",
437
+    "_name": "",
438
+    "_objFlags": 0,
439
+    "node": {
440
+      "__id__": 1
441
+    },
442
+    "_enabled": true,
443
+    "btnNode": {
444
+      "__id__": 2
445
+    },
446
+    "_prevX": 0,
447
+    "_prevY": 0,
448
+    "_didMove": false,
449
+    "_id": ""
450
+  },
451
+  {
452
+    "__type__": "cc.PrefabInfo",
453
+    "root": {
454
+      "__id__": 1
455
+    },
456
+    "asset": {
457
+      "__uuid__": "005f289d-dd76-447f-864e-215f62b43e8e"
458
+    },
459
+    "fileId": "9bGqJtPppHR6bzL78mEBWd",
460
+    "sync": false
461
+  }
462
+]

+ 8 - 0
assets/resources/edt_prefab/Debug/debug_enter.prefab.meta

@@ -0,0 +1,8 @@
1
+{
2
+  "ver": "1.2.6",
3
+  "uuid": "005f289d-dd76-447f-864e-215f62b43e8e",
4
+  "optimizationPolicy": "AUTO",
5
+  "asyncLoadAssets": false,
6
+  "readonly": false,
7
+  "subMetas": {}
8
+}

+ 0 - 37
assets/resources/res_json/Sheet1.json

@@ -1,37 +0,0 @@
1
-[
2
-  {
3
-    "id": 1,
4
-    "colour": "白",
5
-    "listCost": 0
6
-  },
7
-  {
8
-    "id": 2,
9
-    "colour": "绿",
10
-    "listCost": 200
11
-  },
12
-  {
13
-    "id": 3,
14
-    "colour": "蓝",
15
-    "listCost": 500
16
-  },
17
-  {
18
-    "id": 4,
19
-    "colour": "紫",
20
-    "listCost": 1000
21
-  },
22
-  {
23
-    "id": 5,
24
-    "colour": "粉",
25
-    "listCost": 2000
26
-  },
27
-  {
28
-    "id": 6,
29
-    "colour": "红",
30
-    "listCost": 5000
31
-  },
32
-  {
33
-    "id": 7,
34
-    "colour": "金",
35
-    "listCost": 10000
36
-  }
37
-]

+ 0 - 5
assets/resources/res_json/Sheet1.json.meta

@@ -1,5 +0,0 @@
1
-{
2
-  "ver": "1.0.0",
3
-  "uuid": "e7749024-46e7-43b4-a4d7-aa4c8e5b59e6",
4
-  "subMetas": {}
5
-}

+ 1 - 0
assets/script/app/constants/AppConstants.js

@@ -19,6 +19,7 @@ window.JMC.Proxy = cc.Enum({
19 19
 // 弹框 Id 枚举声明
20 20
 window.JMC.ALERT_ID = cc.Enum({
21 21
     DEFAULT: 0,                             // 默认
22
+    DEBUG: 999,                             // 测试
22 23
 });
23 24
 
24 25
 // 物品类型枚举声明

+ 1 - 1
assets/script/core/ctrl/SceneCtrlBase.js

@@ -55,7 +55,7 @@ cc.Class({
55 55
         }
56 56
 
57 57
         if (!CC_EDITOR && G.OPEN_DEBUG) {
58
-            cc.loader.loadRes('debug/prefab/public/debug_debug_enter', cc.Prefab, (err, prefab) => {
58
+            cc.loader.loadRes('edt_prefab/Debug/debug_enter', cc.Prefab, (err, prefab) => {
59 59
                 if (err) {
60 60
                     G.LogUtils.log('err:', err);
61 61
                     return;

+ 7 - 0
assets/script/core/debug.meta

@@ -0,0 +1,7 @@
1
+{
2
+  "ver": "1.0.1",
3
+  "uuid": "4e9053d5-e56a-48d1-b78c-9d1ac2df1924",
4
+  "isSubpackage": false,
5
+  "subpackageName": "",
6
+  "subMetas": {}
7
+}

+ 85 - 0
assets/script/core/debug/DebugCtrl.js

@@ -0,0 +1,85 @@
1
+cc.Class({
2
+    extends: cc.Component,
3
+
4
+    editor: {
5
+        menu: 'Debug/DebugCtrl'
6
+    },
7
+
8
+    properties: {
9
+        btnNode: cc.Node,
10
+
11
+        _prevX: 0,
12
+        _prevY: 0,
13
+        _didMove: false
14
+    },
15
+
16
+    onEnable () {
17
+        this.btnNode.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
18
+        this.btnNode.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
19
+        this.btnNode.on(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
20
+        this.btnNode.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchEnd, this);
21
+        cc.tween(this.btnNode)
22
+            .delay(1)
23
+            .to(1, {opacity: 0})
24
+            .start();
25
+    },
26
+
27
+    onDisable () {
28
+        this.btnNode.off(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
29
+        this.btnNode.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
30
+        this.btnNode.off(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
31
+        this.btnNode.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchEnd, this);
32
+    },
33
+    onClicked () {
34
+        G.AppUtils.getSceneCtrl().showAlert('edt_prefab/Debug/debug_alert', undefined);
35
+    },
36
+
37
+    _onTouchStart (event) {
38
+        let location = event.getLocation();
39
+
40
+        this._didMove = false;
41
+
42
+        this.btnNode.stopAllActions();
43
+        this.btnNode.opacity = 255;
44
+        this._prevX = location.x;
45
+        this._prevY = location.y;
46
+    },
47
+
48
+    _onTouchMove (event) {
49
+        let location = event.getLocation();
50
+
51
+        let posX = this.btnNode.x;
52
+        let posY = this.btnNode.y;
53
+        if (!this._didMove) {
54
+            let deltaV2 = cc.v2(posX, posY).sub(cc.v2(location.x, location.y));
55
+            let dist = deltaV2.mag();
56
+            if (dist > 44) {
57
+                this._didMove = true;
58
+            }
59
+        }
60
+
61
+        if (this._didMove) {
62
+            this.btnNode.x = posX + (location.x - this._prevX);
63
+            this.btnNode.y = posY + (location.y - this._prevY);
64
+
65
+            this._prevX = location.x;
66
+            this._prevY = location.y;
67
+        }
68
+    },
69
+
70
+    _onTouchEnd (event) {
71
+        if (!this._didMove) {
72
+            this.onClicked();
73
+        }
74
+
75
+        this._didMove = false;
76
+
77
+        this._prevX = 0;
78
+        this._prevY = 0;
79
+
80
+        cc.tween(this.btnNode)
81
+            .delay(1)
82
+            .to(1, {opacity: 0})
83
+            .start();
84
+    }
85
+});

+ 9 - 0
assets/script/core/debug/DebugCtrl.js.meta

@@ -0,0 +1,9 @@
1
+{
2
+  "ver": "1.0.8",
3
+  "uuid": "43dfcfbd-8816-4bd6-81df-7f8d1faf8fc5",
4
+  "isPlugin": false,
5
+  "loadPluginInWeb": true,
6
+  "loadPluginInNative": true,
7
+  "loadPluginInEditor": false,
8
+  "subMetas": {}
9
+}

+ 75 - 0
assets/script/core/debug/DebuguAlert.js

@@ -0,0 +1,75 @@
1
+const JMAlertBase = require('JMAlertBase');
2
+
3
+cc.Class({
4
+    editor: {
5
+        menu: 'Debug/DebugAlert'
6
+    },
7
+
8
+    extends: JMAlertBase ,
9
+
10
+    properties: {
11
+        itemIdEB: cc.EditBox,
12
+        itemNumEB: cc.EditBox,
13
+    },
14
+
15
+    onLoad () {
16
+        this._super();
17
+
18
+    },
19
+
20
+    onEnable () {
21
+        this._super();
22
+
23
+    },
24
+
25
+    onDisable () {
26
+        cc.game.targetOff(this);
27
+
28
+        this._super();
29
+    },
30
+
31
+    reloadData (data, cb) {
32
+    },
33
+    
34
+    debuguItemAddOnClicked() {
35
+        if (this.itemIdEB.String.length == 0) {
36
+            return;
37
+        }
38
+
39
+        let itemid = parseInt(this.itemIdEB.String);
40
+        let num = this.itemNumEB.String.length == 0 ? 1 : parseInt(this.itemNumEB.String);
41
+
42
+        this.requestAddItems([
43
+            {
44
+                id: itemid,
45
+                count: num
46
+            }
47
+        ]);
48
+    },
49
+
50
+    requestAddItems (items) {
51
+        let uid = G.UserMgr.getUid();
52
+        if (!uid) return;
53
+
54
+        let info = {
55
+            uid: uid,
56
+            items: items
57
+        };
58
+        G.NetworkMgr.sendSocketRequest('test_add_items', info, this.responseAddItems.bind(this));
59
+    },
60
+
61
+    responseAddItems (data) {
62
+        let requestInfo = data.requestInfo;
63
+        let responseInfo = data.responseInfo;
64
+        if (responseInfo.code === 200) {
65
+            for (const item of requestInfo.items) {
66
+                if (item.count > 0) {
67
+                    G.AppUtils.getSceneCtrl().addToast('获得: ' + item.id + "&&数量:" + item.count);
68
+                }
69
+                if (item.count < 0) {
70
+                    G.AppUtils.getSceneCtrl().addToast('删除: ' + item.id + "&&数量:" + Math.abs(item.count));
71
+                }
72
+            }
73
+        }
74
+    },
75
+});

+ 9 - 0
assets/script/core/debug/DebuguAlert.js.meta

@@ -0,0 +1,9 @@
1
+{
2
+  "ver": "1.0.8",
3
+  "uuid": "115bcb91-ebb6-40d0-8566-52ee359670c9",
4
+  "isPlugin": false,
5
+  "loadPluginInWeb": true,
6
+  "loadPluginInNative": true,
7
+  "loadPluginInEditor": false,
8
+  "subMetas": {}
9
+}

+ 5 - 3
assets/script/core/model/user/UserMgr.js

@@ -41,10 +41,12 @@ let UserMgr = {
41 41
     },
42 42
 
43 43
     //* ************* 用户信息获取 ************* *//
44
+    getUid() {
45
+        if (!this._playerInfo) return undefined;
46
+        
47
+        return this._playerInfo.uid;
48
+    },
44 49
 
45
-
46
-
47
-    
48 50
     /**
49 51
      * 设置玩家系统信息
50 52
      *