2020-04-07 19:23:21 +02:00
|
|
|
import {MapManagerInterface, MapManager} from "./MapManager";
|
2020-04-07 20:41:35 +02:00
|
|
|
import {GameManagerInterface} from "./GameManager";
|
2020-04-07 19:23:21 +02:00
|
|
|
|
2020-04-07 20:41:35 +02:00
|
|
|
export interface GameSceneInterface extends Phaser.Scene {
|
|
|
|
RoomId : string;
|
|
|
|
sharedUserPosition(data : []): void;
|
|
|
|
}
|
|
|
|
export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
2020-04-07 19:23:21 +02:00
|
|
|
private MapManager : MapManagerInterface;
|
2020-04-07 20:41:35 +02:00
|
|
|
RoomId : string;
|
2020-04-07 19:23:21 +02:00
|
|
|
|
2020-04-07 20:41:35 +02:00
|
|
|
constructor(RoomId : string, GameManager : GameManagerInterface) {
|
2020-04-07 19:23:21 +02:00
|
|
|
super({
|
|
|
|
key: "GameScene"
|
|
|
|
});
|
2020-04-07 20:41:35 +02:00
|
|
|
this.RoomId = RoomId;
|
2020-04-07 19:23:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//hook preload scene
|
|
|
|
preload(): void {
|
|
|
|
this.load.image('tiles', 'maps/tiles.png');
|
|
|
|
this.load.tilemapTiledJSON('map', 'maps/map2.json');
|
|
|
|
this.load.spritesheet('player',
|
|
|
|
'resources/characters/pipoya/Male 01-1.png',
|
|
|
|
{ frameWidth: 32, frameHeight: 32 }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//hook initialisation
|
2020-04-07 20:46:30 +02:00
|
|
|
init(){}
|
2020-04-07 19:23:21 +02:00
|
|
|
|
|
|
|
//hook create scene
|
|
|
|
create(): void {
|
|
|
|
//create map manager
|
|
|
|
this.MapManager = new MapManager(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//hook update
|
|
|
|
update(dt: number): void {
|
|
|
|
this.MapManager.update();
|
|
|
|
}
|
2020-04-07 20:41:35 +02:00
|
|
|
|
|
|
|
sharedUserPosition(data: []): void {
|
|
|
|
//TODO share position of all user
|
|
|
|
//console.log("sharedUserPosition", data);
|
|
|
|
}
|
2020-04-07 19:23:21 +02:00
|
|
|
}
|