Browse Source

【修改】商场背包协议

陈文超 2 years ago
parent
commit
a3fc619fa9

File diff suppressed because it is too large
+ 1 - 1
assets/resources/res_text/proto/socket_c2s.txt


File diff suppressed because it is too large
+ 1 - 1
assets/resources/res_text/proto/socket_s2c.txt


+ 9 - 0
assets/script/app/model/utils/ItemDataUtils.js.meta

@@ -0,0 +1,9 @@
1
+{
2
+  "ver": "1.0.8",
3
+  "uuid": "10b828ae-d44a-4d28-a9eb-a41879e5fa73",
4
+  "isPlugin": false,
5
+  "loadPluginInWeb": true,
6
+  "loadPluginInNative": true,
7
+  "loadPluginInEditor": false,
8
+  "subMetas": {}
9
+}

+ 31 - 8
assets/script/app/view/shop/ShopMain.js

@@ -1,5 +1,4 @@
1
 const TagType = {
1
 const TagType = {
2
-    OTHER: -1,
3
     HOT: 0,
2
     HOT: 0,
4
     KINIFE: 100,               // 匕首
3
     KINIFE: 100,               // 匕首
5
     HANDGUN: 200,              // 手枪
4
     HANDGUN: 200,              // 手枪
@@ -8,6 +7,7 @@ const TagType = {
8
     PRINTING: 500,             // 印花
7
     PRINTING: 500,             // 印花
9
     LSTA: 600,                 // 轻机枪
8
     LSTA: 600,                 // 轻机枪
10
     GLOVE: 700,                // 手套
9
     GLOVE: 700,                // 手套
10
+    OTHER: 99999,
11
 };
11
 };
12
 
12
 
13
 cc.Class({
13
 cc.Class({
@@ -21,13 +21,14 @@ cc.Class({
21
         goldNumText: cc.Label,
21
         goldNumText: cc.Label,
22
     },
22
     },
23
 
23
 
24
-    onLoad () {
24
+    onLoad() {
25
+        this.initData();
25
         this.initUI();
26
         this.initUI();
26
     },
27
     },
27
 
28
 
28
-    initData () {
29
+    initData() {
29
         this.goods = {};
30
         this.goods = {};
30
-        let goodConfig = G.CfgMgr.GoodsConfig.table;
31
+        let goodConfig = G.CfgMgr.goodsConfig.table;
31
         for (let config of goodConfig) {
32
         for (let config of goodConfig) {
32
             if (!config.inShop) {
33
             if (!config.inShop) {
33
                 continue;
34
                 continue;
@@ -38,17 +39,39 @@ cc.Class({
38
             }
39
             }
39
 
40
 
40
             let item = config.items[0];
41
             let item = config.items[0];
41
-            
42
-        } 
42
+            let itemConfig = G.CfgMgr.resItemConfig.getByMainKey(item.id);
43
+
44
+            if (!itemConfig) {
45
+                continue;
46
+            }
47
+
48
+            let name = itemConfig.name;
49
+            let cost = 0;
50
+            // if (config.price)
51
+
52
+            let tagType = TagType.OTHER;
53
+            for (var temp in TagType) {
54
+                if (TagType[temp] == itemConfig.type) {
55
+                    tagType = TagType[temp];
56
+                    break;
57
+                }
58
+            }
59
+
60
+            if (!this.goods[tagType]) {
61
+                this.goods[tagType] = [];
62
+            }
63
+
64
+            this.goods[tagType].push(config);
65
+        }
43
     },
66
     },
44
 
67
 
45
     initUI() {
68
     initUI() {
46
         let goldNum = G.BagMgr.getItemNumById(JMC.ITEM_ID.SPECIAL_GOLD);
69
         let goldNum = G.BagMgr.getItemNumById(JMC.ITEM_ID.SPECIAL_GOLD);
47
-        
70
+
48
     },
71
     },
49
 
72
 
50
     typeChooseToggleOnClicked(toggleData, eventKey) {
73
     typeChooseToggleOnClicked(toggleData, eventKey) {
51
-        
74
+
52
     }
75
     }
53
 
76
 
54
 
77
 

+ 29 - 8
assets/script/core/model/bag/BagMgr.js

@@ -10,18 +10,40 @@ let BagMgr = {
10
     // }
10
     // }
11
     _items: [], // 背包基础信息
11
     _items: [], // 背包基础信息
12
 
12
 
13
-    init () {
13
+    init() {
14
         if (CC_EDITOR) {
14
         if (CC_EDITOR) {
15
             return;
15
             return;
16
         }
16
         }
17
 
17
 
18
         this._items = [];
18
         this._items = [];
19
 
19
 
20
-        // 推送消息
21
-        cc.game.on('on_user_items', this._onUserItems, this);
20
+        this._initEventListener();
21
+        this._initPublishListener();
22
     },
22
     },
23
 
23
 
24
-    _addItemData (data) {
24
+    _initEventListener() {
25
+        // 通用消息
26
+        G.PublicMgr.on(JMC.PUBLIC_MSG.SWITCH_ACCOUNT, JMC.PUBLIC_MSG_ORDER.BAG, this.handleDidSwitchAccount, this);
27
+        G.PublicMgr.on(JMC.PUBLIC_MSG.LOGIN_SUCCESS, JMC.PUBLIC_MSG_ORDER.BAG, this.handleDidLoginSuccess, this);
28
+        G.PublicMgr.on(JMC.PUBLIC_MSG.DISCONNECTED, JMC.PUBLIC_MSG_ORDER.BAG, this.handleDidDisconnected, this);
29
+    },
30
+
31
+    _initPublishListener() {
32
+        cc.game.on('on_user_items', this.handleUpdateItems, this);
33
+    },
34
+
35
+    handleDidLoginSuccess() {
36
+        this.requestInfo();
37
+    },
38
+
39
+    handleDidDisconnected() {
40
+    },
41
+
42
+    handleDidSwitchAccount() {
43
+        this._items = [];
44
+    },
45
+
46
+    _addItemData(data) {
25
         let isUpdate = false;
47
         let isUpdate = false;
26
         for (let [idx, itemData] of Object.entries(this._items)) {
48
         for (let [idx, itemData] of Object.entries(this._items)) {
27
             if (itemData.id == data.id) {
49
             if (itemData.id == data.id) {
@@ -67,11 +89,11 @@ let BagMgr = {
67
 
89
 
68
     //* ************* 客户端请求/响应 ************* *//
90
     //* ************* 客户端请求/响应 ************* *//
69
 
91
 
70
-    requestInfo () {
92
+    requestInfo() {
71
         G.NetworkMgr.sendSocketRequest('bag_get_info', {}, this._responseBagGetInfo.bind(this));
93
         G.NetworkMgr.sendSocketRequest('bag_get_info', {}, this._responseBagGetInfo.bind(this));
72
     },
94
     },
73
 
95
 
74
-    _responseBagGetInfo (data) {
96
+    _responseBagGetInfo(data) {
75
         let responseInfo = data.responseInfo;
97
         let responseInfo = data.responseInfo;
76
         if (responseInfo.code === 200) {
98
         if (responseInfo.code === 200) {
77
             // 玩家基础信息
99
             // 玩家基础信息
@@ -86,8 +108,7 @@ let BagMgr = {
86
 
108
 
87
     _onUserItems(data) {
109
     _onUserItems(data) {
88
         if (!data || !data.items || data.items.length == 0) return;
110
         if (!data || !data.items || data.items.length == 0) return;
89
-        for (const item of data.items) 
90
-        {
111
+        for (const item of data.items) {
91
             this._addItemData(item);
112
             this._addItemData(item);
92
         }
113
         }
93
     }
114
     }