|
@@ -0,0 +1,78 @@
|
|
1
|
+/**
|
|
2
|
+ * 配置表管理
|
|
3
|
+ */
|
|
4
|
+let ConfigBase = require('ConfigBase')
|
|
5
|
+
|
|
6
|
+let CfgMgr = {
|
|
7
|
+ init () {
|
|
8
|
+ if (CC_EDITOR) {
|
|
9
|
+ return;
|
|
10
|
+ }
|
|
11
|
+
|
|
12
|
+ this.loadFinishCb = null
|
|
13
|
+ this.updateLoadCb = null
|
|
14
|
+ this.configs = {
|
|
15
|
+ BattleBoxAwardConfig: new ConfigBase().initTable("BattleBoxAwardConfig", "", ["boxId", "itemId"]),
|
|
16
|
+ BattleBoxConfig: new ConfigBase().initTable("BattleBoxConfig", "boxId"),
|
|
17
|
+ BattleBoxTypeConfig: new ConfigBase().initTable("BattleBoxTypeConfig", "ty"),
|
|
18
|
+ BattleConstConfig: new ConfigBase().initTable("BattleConstConfig", "main_key"),
|
|
19
|
+ BlindBoxAwardConfig: new ConfigBase().initTable("BlindBoxAwardConfig", "", ["boxId", "itemId"]),
|
|
20
|
+ BlindBoxConfig: new ConfigBase().initTable("BlindBoxConfig", "boxId"),
|
|
21
|
+ BlindBoxConstConfig: new ConfigBase().initTable("BlindBoxConstConfig", "main_key"),
|
|
22
|
+ BlindBoxTypeConfig: new ConfigBase().initTable("BlindBoxTypeConfig", "ty"),
|
|
23
|
+ DreamBox: new ConfigBase().initTable("DreamBox", "dreamBoxId"),
|
|
24
|
+ DreamBoxAward: new ConfigBase().initTable("DreamBoxAward", "DreamBoxId", ["DreamBoxId"]),
|
|
25
|
+ DreamConstConfig: new ConfigBase().initTable("DreamConstConfig", "main_key"),
|
|
26
|
+ GoodsConfig: new ConfigBase().initTable("GoodsConfig", "id"),
|
|
27
|
+ ResItemConfig: new ConfigBase().initTable("ResItemConfig", "id"),
|
|
28
|
+ ResItemModelConfig: new ConfigBase().initTable("ResItemModelConfig", "id"),
|
|
29
|
+ ResItemModelTypeConfig: new ConfigBase().initTable("ResItemModelTypeConfig", "id"),
|
|
30
|
+ ResItemQualityConfig: new ConfigBase().initTable("ResItemQualityConfig", "id"),
|
|
31
|
+ ResItemQualityPrice: new ConfigBase().initTable("ResItemQualityPrice", "id"),
|
|
32
|
+ ResItemSurfaceConfig: new ConfigBase().initTable("ResItemSurfaceConfig", "id"),
|
|
33
|
+ ResItemTypeConfig: new ConfigBase().initTable("ResItemTypeConfig", "id"),
|
|
34
|
+ Sheet1: new ConfigBase().initTable("Sheet1", "id"),
|
|
35
|
+ };
|
|
36
|
+ this.curLoadingIndex = 0;
|
|
37
|
+ },
|
|
38
|
+
|
|
39
|
+ loadAllConfig() {
|
|
40
|
+ this.loadConfig();
|
|
41
|
+ },
|
|
42
|
+
|
|
43
|
+ loadConfig() {
|
|
44
|
+ for (const [key, config] of Object.entries(this.configs)) {
|
|
45
|
+ if (config.isLoadFinish) {
|
|
46
|
+ continue;
|
|
47
|
+ }
|
|
48
|
+ let self = this;
|
|
49
|
+ cc.loader.loadRes("res_json/" + config.tableName, function(err, jsonAsset) {
|
|
50
|
+ if (err) {
|
|
51
|
+ cc.error(err);
|
|
52
|
+ return;
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ config.setTable(jsonAsset.json)
|
|
56
|
+ config.isLoadFinish = true;
|
|
57
|
+ self.curLoadingIndex += 1;
|
|
58
|
+ if (self.updateLoadCb) {
|
|
59
|
+ self.updateLoadCb();
|
|
60
|
+ }
|
|
61
|
+ self.loadConfig()
|
|
62
|
+ });
|
|
63
|
+ break
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ if (this.curLoadingIndex < Object.keys(this.configs).length) {
|
|
67
|
+ return
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ if (this.loadFinishCb) {
|
|
71
|
+ this.loadFinishCb()
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ cc.game.emit('e_mgr_load_config_done');
|
|
75
|
+ },
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+module.exports = CfgMgr;
|