workadventure/back/src/Controller/MapController.ts
gparant 27c6034661 Manage multi scene
- Create position and check if user is in position to switch in the next scene.
 - When scene is load, we load all scene in the layer of name "exit".
 - Layer "exit" of map.json have a parametter "exitSceneKey" to identify next scene.
 - Add layer "start", the player could start in the scene on the object present in the layer of name "start".
2020-05-09 21:28:50 +02:00

31 lines
889 B
TypeScript

import express from "express";
import path from "path";
import {Application, Request, Response} from "express";
import {OK} from "http-status-codes";
export class MapController {
App: Application;
constructor(App: Application) {
this.App = App;
this.getMpas();
this.assetMaps();
}
assetMaps() {
this.App.use('/map/files', express.static('src/Assets/Maps'));
}
//permit to login on application. Return token to connect on Websocket IO.
getMpas() {
this.App.get("/maps", (req: Request, res: Response) => {
return res.status(OK).send({
mapStart: {key: "floor0", url: "/map/files/Floor0"},
maps: [
{key: "floor0", url: "/map/files/Floor0"},
{key: "floor1", url: "/map/files/Floor1"},
]
});
});
}
}