39 lines
1013 B
TypeScript
39 lines
1013 B
TypeScript
import { Logger } from "../../../../core_tgx/base/utils/Logger";
|
|
import { IMonsterCfg } from "../../../../module_basic/shared/configs/interface/IMonsterCfg";
|
|
|
|
export default class MonsterDataManager {
|
|
private _data: Array<IMonsterCfg> | undefined;
|
|
init(data: any): void {
|
|
this._data = data;
|
|
Logger.info(`配置数据(IMonsterCfg)加载完毕...`);
|
|
}
|
|
|
|
|
|
getData(id: number): IMonsterCfg {
|
|
if (this._data) {
|
|
return this._data.find(p => p.id == id);
|
|
}
|
|
console.log("配置数据(IMonsterCfg)不存在" + id);
|
|
return null;
|
|
}
|
|
|
|
getAllData() {
|
|
return this._data;
|
|
}
|
|
|
|
findMonsterIdsByWaveNumber(waveNumber: number): number | null {
|
|
const matchingIds: number[] = [];
|
|
|
|
if (this._data) {
|
|
for (const config of this._data) {
|
|
if (config.showWave.indexOf(waveNumber) != -1) {
|
|
return config.id;
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|