Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { BlockData } from './BlockData';
- import { BiomeData } from './BiomeData';
- import gameDataJSON from '../../data/gamedata.json';
- import blockDataJSON from '../../data/blockdata.json';
- import biomeDataJSON from '../../data/biomedata.json';
- export class GameData {
- public blockSize: number;
- public renderDistance: number;
- public chunkSize: {
- width: number,
- height: number
- }
- public blocks: {[key: string]: BlockData} = {};
- public biomes: {[key: string]: BiomeData} = {};
- private classes: any = {
- BlockData,
- BiomeData
- };
- constructor() {
- let gameData: any = (<any>gameDataJSON);
- this.blockSize = gameData.blockSize;
- this.renderDistance = gameData.renderDistance;
- this.chunkSize = gameData.chunkSize;
- this.setData(this.blocks, blockDataJSON, 'BlockData');
- this.setData(this.biomes, biomeDataJSON, 'BiomeData');
- }
- private setData = (array: any, json: any, className: string): void => {
- let data: any = (<any>json);
- for (let key in data) {
- array[key] = new this.classes[className](data[key]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement