player following the path wip

This commit is contained in:
Hanusiak Piotr 2022-01-17 14:36:00 +01:00
parent 77ee39110f
commit e557e8ea72
5 changed files with 108 additions and 41 deletions

View file

@ -130,6 +130,14 @@ export class GameMap {
return grid;
}
public getTileDimensions(): { width: number; height: number } {
return { width: this.map.tilewidth, height: this.map.tileheight };
}
public getTileIndexAt(x: number, y: number): { x: number; y: number } {
return { x: Math.floor(x / this.map.tilewidth), y: Math.floor(y / this.map.tileheight) };
}
private getLayersByKey(key: number): Array<ITiledMapLayer> {
return this.flatLayers.filter((flatLayer) => flatLayer.type === "tilelayer" && flatLayer.data[key] !== 0);
}

View file

@ -570,7 +570,6 @@ export class GameScene extends DirtyScene {
);
this.pathfindingManager = new PathfindingManager(this, this.gameMap.getCollisionsGrid());
this.pathfindingManager.findPath({ x: 1, y: 3 }, { x: 29, y: 3 });
biggestAvailableAreaStore.recompute();
this.cameraManager.startFollowPlayer(this.CurrentPlayer);
@ -2174,4 +2173,16 @@ ${escapedMessage}
this.scene.stop(this.scene.key);
this.scene.remove(this.scene.key);
}
public getGameMap(): GameMap {
return this.gameMap;
}
public getCameraManager(): CameraManager {
return this.cameraManager;
}
public getPathfindingManager(): PathfindingManager {
return this.pathfindingManager;
}
}