9f42ba43-18bb-4b35-8e2b-e3268c38dfe7.js
6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
"use strict";
cc._RF.push(module, '9f42bpDGLtLNY4r4yaMON/n', 'UnlockItemModelManager');
// script/game/model/UnlockItemModelManager.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnlockItemModelManager = void 0;
const simba_config_manager_1 = require("simba-config-manager");
const AVG_1 = require("../../avg/AVG");
const ItemTbl_1 = require("../../config/ItemTbl");
class UnlockItemModelManager1 {
constructor() {
/**存档Key */
this.UnlockItems = 'UnlockItems';
/**存档Key */
this.ClickedItems = 'ClickedItems';
/**存档Key */
this.UnlockedIntroductionItems = 'UnlockedIntroductionItems';
/**解锁的物品ids */
this.items = [];
/**点击过的物品ids */
this.clickedItem = [];
/**已经解锁简介的物品ids */
this.unlockedIntroductionItem = [];
/**配置掉落物品的剧情id和午评id的映射表 */
this._unlockPlotIds = [];
}
/**获取配置掉落物品的剧情id和午评id的映射表 */
get unlockPlotIds() {
if (this._unlockPlotIds.length == 0)
this.analysisItemCfg();
return this._unlockPlotIds;
}
get unlockItems() {
let items = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.UnlockItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
items.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
return items;
}
get clickedItems() {
this.clickedItem = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.ClickedItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
this.clickedItem.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
return this.clickedItem;
}
get unlockedIntroductionItems() {
this.unlockedIntroductionItem = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.UnlockedIntroductionItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
this.unlockedIntroductionItem.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
return this.unlockedIntroductionItem;
}
/**
* 保存解锁了简介的物品id到存档
* @param id 点击过的物品id
*/
saveUnlockedIntroductionItemIdToGameRecord(id) {
this.unlockedIntroductionItem = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.UnlockedIntroductionItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
this.unlockedIntroductionItem.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
if (this.unlockedIntroductionItem.indexOf(id) == -1) {
this.unlockedIntroductionItem.push(id);
AVG_1.GameRecord.globalVariables[this.UnlockedIntroductionItems] = this.unlockedIntroductionItem.toString();
AVG_1.GameRecord.saveRecord();
return true;
}
return false;
}
/**
* 保存点击过的物品id到存档
* @param id 点击过的物品id
*/
saveClickedItemIdToGameRecord(id) {
this.clickedItem = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.ClickedItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
this.clickedItem.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
if (this.clickedItem.indexOf(id) == -1) {
this.clickedItem.push(id);
AVG_1.GameRecord.globalVariables[this.ClickedItems] = this.clickedItem.toString();
AVG_1.GameRecord.saveRecord();
return true;
}
return false;
}
/**
* 保存解锁的物品id到存档
* @param id 解锁的物品id
*/
saveItemIdToGameRecord(id) {
this.items = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.UnlockItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
this.items.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
if (this.items.indexOf(id) == -1) {
this.items.push(id);
AVG_1.GameRecord.globalVariables[this.UnlockItems] = this.items.toString();
// GameRecord.autoSave();
return true;
}
return false;
}
/**
* 登录初始化已经解锁的items
*/
loginInitUnlockItems() {
//获取已经存在的items
this.items = [];
let itemsStr = AVG_1.GameRecord.globalVariables[this.UnlockItems];
if (itemsStr) {
let itemsIdStr = itemsStr.split(',');
itemsIdStr.forEach(id => {
try {
this.items.push(Number(id));
}
catch (error) {
console.error(error);
}
});
}
//当前剧情应该解锁的所有物品
let itemcfg = this.unlockPlotIds;
//获取当前的剧情id
let record = AVG_1.GameRecord.getPlotsInfo();
for (let i = 0; i < itemcfg.length; i++) {
let ele = itemcfg[i];
if (ele) {
if (record[`${ele.plotId}`] && record[`${ele.plotId}`].cnt >= 1) {
if (this.items.indexOf(ele.itemId) == -1) {
this.items.push(ele.itemId);
}
}
}
}
AVG_1.GameRecord.globalVariables[this.UnlockItems] = this.items.toString();
// GameRecord.autoSave();
}
/**
* 解析item表结果
*/
analysisItemCfg() {
let ret = [];
let cfg = simba_config_manager_1.ConfigManager.getAllConfig(ItemTbl_1.itemTbl);
for (let id in cfg) {
ret.push({ itemId: Number(id), plotId: cfg[id].plot });
}
this._unlockPlotIds = ret;
}
}
exports.UnlockItemModelManager = new UnlockItemModelManager1();
cc._RF.pop();