Explorar o código

【修改】 修改背包

Hua hai 1 ano
pai
achega
ff319067f4

+ 20 - 7
assets/resources/edt_prefab/Bag/BagMain.prefab

@@ -37,10 +37,13 @@
37 37
       },
38 38
       {
39 39
         "__id__": 131
40
+      },
41
+      {
42
+        "__id__": 132
40 43
       }
41 44
     ],
42 45
     "_prefab": {
43
-      "__id__": 132
46
+      "__id__": 133
44 47
     },
45 48
     "_opacity": 255,
46 49
     "_color": {
@@ -3762,8 +3765,8 @@
3762 3765
     },
3763 3766
     "_contentSize": {
3764 3767
       "__type__": "cc.Size",
3765
-      "width": 100,
3766
-      "height": 40
3768
+      "width": 124,
3769
+      "height": 50.4
3767 3770
     },
3768 3771
     "_anchorPoint": {
3769 3772
       "__type__": "cc.Vec2",
@@ -3827,7 +3830,7 @@
3827 3830
     "_N$horizontalAlign": 1,
3828 3831
     "_N$verticalAlign": 1,
3829 3832
     "_N$fontFamily": "Arial",
3830
-    "_N$overflow": 1,
3833
+    "_N$overflow": 0,
3831 3834
     "_N$cacheMode": 1,
3832 3835
     "_id": ""
3833 3836
   },
@@ -4143,8 +4146,8 @@
4143 4146
     },
4144 4147
     "_contentSize": {
4145 4148
       "__type__": "cc.Size",
4146
-      "width": 100,
4147
-      "height": 40
4149
+      "width": 62,
4150
+      "height": 50.4
4148 4151
     },
4149 4152
     "_anchorPoint": {
4150 4153
       "__type__": "cc.Vec2",
@@ -4208,7 +4211,7 @@
4208 4211
     "_N$horizontalAlign": 1,
4209 4212
     "_N$verticalAlign": 1,
4210 4213
     "_N$fontFamily": "Arial",
4211
-    "_N$overflow": 1,
4214
+    "_N$overflow": 0,
4212 4215
     "_N$cacheMode": 1,
4213 4216
     "_id": ""
4214 4217
   },
@@ -5021,6 +5024,16 @@
5021 5024
     "_id": ""
5022 5025
   },
5023 5026
   {
5027
+    "__type__": "29ca00MGlVO67hGD7Ld03o/",
5028
+    "_name": "",
5029
+    "_objFlags": 0,
5030
+    "node": {
5031
+      "__id__": 1
5032
+    },
5033
+    "_enabled": true,
5034
+    "_id": ""
5035
+  },
5036
+  {
5024 5037
     "__type__": "cc.PrefabInfo",
5025 5038
     "root": {
5026 5039
       "__id__": 1

+ 7 - 4
assets/script/app/AppInit.js

@@ -24,6 +24,10 @@ module.exports = {
24 24
         ns.AlertMgr = require('AlertMgr');
25 25
         ns.AlertMgr.init();
26 26
 
27
+        // ui管理器
28
+        ns.UIMgr = require('UIMgr')
29
+        ns.UIMgr.init();
30
+
27 31
         // 时间工具
28 32
         ns.TimeUtils = require('TimeUtils');
29 33
 
@@ -36,10 +40,9 @@ module.exports = {
36 40
         ns.LoginMgr.init();
37 41
 
38 42
         // 玩家数据管理器
39
-        ns.UserMgr = require('UserMgr');
40
-        ns.UserMgr.init();
43
+        ns.BagMgr = require('BagMgr');
44
+        ns.BagMgr.init();
41 45
 
42
-        ns.UIMgr = require('UIMgr')
43
-        ns.UIMgr.init();
46
+        // 背包数据管理器
44 47
     }
45 48
 };

+ 12 - 6
assets/script/app/constants/AppConstants.js

@@ -8,6 +8,14 @@ if (!window.JMC) {
8 8
     window.JMC = {};
9 9
 }
10 10
 
11
+// UI类型
12
+window.JMC.Proxy = cc.Enum({
13
+    Main: 0,
14
+    Navigation:1,
15
+    Toast:2,
16
+    UI:3,
17
+});
18
+
11 19
 // 弹框 Id 枚举声明
12 20
 window.JMC.ALERT_ID = cc.Enum({
13 21
     DEFAULT: 0,                             // 默认
@@ -48,10 +56,8 @@ window.JMC.ORDER_STATUS = cc.Enum({
48 56
     SUBMIT_ORDER_UNKOWN: 6    // 提交订单未知结果
49 57
 });
50 58
 
51
-// 订单状态
52
-window.JMC.Proxy = cc.Enum({
53
-    Main: 0,
54
-    Navigation:1,
55
-    Toast:2,
56
-    UI:3,
59
+
60
+// 背包事件
61
+window.JMC.BAG = cc.Enum({
62
+    INFO: "JMC.BAG.INFO",             // 基本信息
57 63
 });

+ 7 - 0
assets/script/app/view/bag.meta

@@ -0,0 +1,7 @@
1
+{
2
+  "ver": "1.0.1",
3
+  "uuid": "bad62ae0-b557-44ff-9040-8f16a595e9d4",
4
+  "isSubpackage": false,
5
+  "subpackageName": "",
6
+  "subMetas": {}
7
+}

+ 23 - 0
assets/script/app/view/bag/BagMain.js

@@ -0,0 +1,23 @@
1
+// Learn cc.Class:
2
+//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
3
+// Learn Attribute:
4
+//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
5
+// Learn life-cycle callbacks:
6
+//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
7
+let ButtonSelect2 = require('ButtonSelect2')
8
+cc.Class({
9
+    extends: cc.Component,
10
+
11
+    properties: {
12
+        
13
+    },
14
+
15
+    onLoad () {
16
+        G.BagMgr.requestInfo();
17
+    },
18
+    
19
+    start () {
20
+
21
+    },
22
+    // update (dt) {},
23
+});

+ 9 - 0
assets/script/app/view/bag/BagMain.js.meta

@@ -0,0 +1,9 @@
1
+{
2
+  "ver": "1.0.8",
3
+  "uuid": "29ca0d0c-1a55-4eeb-b846-0fb2ddd37a3f",
4
+  "isPlugin": false,
5
+  "loadPluginInWeb": true,
6
+  "loadPluginInNative": true,
7
+  "loadPluginInEditor": false,
8
+  "subMetas": {}
9
+}

+ 1 - 0
assets/script/app/view/navigation/NavigationMain.js

@@ -75,6 +75,7 @@ cc.Class({
75 75
             JMC.UIEnum.BagMain,
76 76
             JMC.UIEnum.DreamMain,
77 77
         ];
78
+        this.onClickNavigation(null, "1")
78 79
     },
79 80
 
80 81
     start () {

+ 7 - 0
assets/script/core/model/bag.meta

@@ -0,0 +1,7 @@
1
+{
2
+  "ver": "1.0.1",
3
+  "uuid": "8b0af8dd-6f11-4023-b5af-e05a61e3a896",
4
+  "isSubpackage": false,
5
+  "subpackageName": "",
6
+  "subMetas": {}
7
+}

+ 38 - 0
assets/script/core/model/bag/BagMgr.js

@@ -0,0 +1,38 @@
1
+/**
2
+ * 背包数据管理
3
+ */
4
+let BagMgr = {
5
+    // # 物品背包属性
6
+    // .DataItemBag {
7
+    //     id 0: integer                   # 物品ID
8
+    //     count 1: integer                # 物品数量
9
+    //     endTime 2: integer              # 到期时间戳
10
+    // }
11
+    _items: {}, // 背包基础信息
12
+
13
+    init () {
14
+        if (CC_EDITOR) {
15
+            return;
16
+        }
17
+    },
18
+
19
+    requestInfo () {
20
+        G.NetworkMgr.sendSocketRequest('bag_get_info', {}, this._responseBagGetInfo.bind(this));
21
+    },
22
+
23
+    _responseBagGetInfo (data) {
24
+        let responseInfo = data.responseInfo;
25
+        if (responseInfo.code === 200) {
26
+            // 玩家基础信息
27
+            this._items = responseInfo.items;
28
+            G.PublicMgr.emit(JMC.BAG.INFO);
29
+        } else {
30
+            // 断开网络并且弹出重连窗口
31
+            G.NetworkMgr.closeSocket();
32
+            G.AppUtils.getSceneCtrl().showOfflineAlert();
33
+        }
34
+    },
35
+}
36
+
37
+
38
+module.exports = BagMgr;

+ 9 - 0
assets/script/core/model/bag/BagMgr.js.meta

@@ -0,0 +1,9 @@
1
+{
2
+  "ver": "1.0.8",
3
+  "uuid": "17cafe22-76ee-4121-862a-94ff4542d604",
4
+  "isPlugin": false,
5
+  "loadPluginInWeb": true,
6
+  "loadPluginInNative": true,
7
+  "loadPluginInEditor": false,
8
+  "subMetas": {}
9
+}