Files
tower/ts/layered_tile_factory.ts

26 lines
635 B
TypeScript
Raw Normal View History

2021-05-11 02:57:17 +00:00
import { LayeredTile } from './layered_tile.js';
import { TileFactory } from './tile_factory.js';
2021-05-10 05:20:29 +00:00
2021-05-11 02:21:23 +00:00
export class LayeredTileFactory extends TileFactory {
2021-05-11 02:57:17 +00:00
tile_factories: TileFactory[];
2021-05-10 05:20:29 +00:00
2021-05-11 02:57:17 +00:00
constructor(tile_factories: TileFactory[]) {
super(
tile_factories[0].layer_name,
tile_factories[0].width,
tile_factories[0].height,
);
2021-05-11 02:57:17 +00:00
this.tile_factories = tile_factories;
2021-05-10 05:20:29 +00:00
}
2021-05-11 02:57:17 +00:00
build(tileset: string): LayeredTile {
const tiles = [];
2021-05-10 05:20:29 +00:00
2021-05-11 02:57:17 +00:00
for (const tile_factory of this.tile_factories) {
tiles.push(tile_factory.build(tileset));
2021-05-10 05:20:29 +00:00
}
2021-05-11 02:57:17 +00:00
return new LayeredTile(this.width, this.height, tiles);
2021-05-10 05:20:29 +00:00
}
}