Allowing ill defined initializers (because of the way Phaser 3 is designed)
This commit is contained in:
parent
7292bc3cab
commit
082a11b0cd
@ -30,15 +30,15 @@ export class GameScene extends Phaser.Scene {
|
|||||||
CurrentPlayer: CurrentGamerInterface;
|
CurrentPlayer: CurrentGamerInterface;
|
||||||
MapPlayers : Phaser.Physics.Arcade.Group;
|
MapPlayers : Phaser.Physics.Arcade.Group;
|
||||||
MapPlayersByKey : Map<string, GamerInterface> = new Map<string, GamerInterface>();
|
MapPlayersByKey : Map<string, GamerInterface> = new Map<string, GamerInterface>();
|
||||||
Map: Phaser.Tilemaps.Tilemap;
|
Map: Phaser.Tilemaps.Tilemap|null = null;
|
||||||
Layers : Array<Phaser.Tilemaps.StaticTilemapLayer>;
|
Layers : Array<Phaser.Tilemaps.StaticTilemapLayer>;
|
||||||
Objects : Array<Phaser.Physics.Arcade.Sprite>;
|
Objects : Array<Phaser.Physics.Arcade.Sprite>;
|
||||||
map: ITiledMap;
|
mapFile: ITiledMap|null;
|
||||||
groups: Map<string, Sprite>;
|
groups: Map<string, Sprite>;
|
||||||
startX = 704;// 22 case
|
startX = 704;// 22 case
|
||||||
startY = 32; // 1 case
|
startY = 32; // 1 case
|
||||||
circleTexture: CanvasTexture;
|
circleTexture: CanvasTexture;
|
||||||
initPosition: PositionInterface;
|
initPosition: PositionInterface|null = null;
|
||||||
private playersPositionInterpolator = new PlayersPositionInterpolator();
|
private playersPositionInterpolator = new PlayersPositionInterpolator();
|
||||||
|
|
||||||
MapKey: string;
|
MapKey: string;
|
||||||
@ -107,9 +107,9 @@ export class GameScene extends Phaser.Scene {
|
|||||||
private onMapLoad(data: any): void {
|
private onMapLoad(data: any): void {
|
||||||
// Triggered when the map is loaded
|
// Triggered when the map is loaded
|
||||||
// Load tiles attached to the map recursively
|
// Load tiles attached to the map recursively
|
||||||
this.map = data.data;
|
this.mapFile = data.data;
|
||||||
let url = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
|
let url = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
|
||||||
this.map.tilesets.forEach((tileset) => {
|
this.mapFile.tilesets.forEach((tileset) => {
|
||||||
if (typeof tileset.name === 'undefined' || typeof tileset.image === 'undefined') {
|
if (typeof tileset.name === 'undefined' || typeof tileset.image === 'undefined') {
|
||||||
console.warn("Don't know how to handle tileset ", tileset)
|
console.warn("Don't know how to handle tileset ", tileset)
|
||||||
return;
|
return;
|
||||||
@ -128,7 +128,7 @@ export class GameScene extends Phaser.Scene {
|
|||||||
create(): void {
|
create(): void {
|
||||||
//initalise map
|
//initalise map
|
||||||
this.Map = this.add.tilemap(this.MapKey);
|
this.Map = this.add.tilemap(this.MapKey);
|
||||||
this.map.tilesets.forEach((tileset: ITiledTileSet) => {
|
this.mapFile.tilesets.forEach((tileset: ITiledTileSet) => {
|
||||||
this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.name));
|
this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.name));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,12 +138,12 @@ export class GameScene extends Phaser.Scene {
|
|||||||
//add layer on map
|
//add layer on map
|
||||||
this.Layers = new Array<Phaser.Tilemaps.StaticTilemapLayer>();
|
this.Layers = new Array<Phaser.Tilemaps.StaticTilemapLayer>();
|
||||||
let depth = -2;
|
let depth = -2;
|
||||||
this.map.layers.forEach((layer : ITiledMapLayer) => {
|
this.mapFile.layers.forEach((layer : ITiledMapLayer) => {
|
||||||
if (layer.type === 'tilelayer') {
|
if (layer.type === 'tilelayer') {
|
||||||
this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth));
|
this.addLayer(this.Map.createStaticLayer(layer.name, this.Terrains, 0, 0).setDepth(depth));
|
||||||
}
|
}
|
||||||
if (layer.type === 'tilelayer' && this.getExitSceneUrl(layer) !== undefined) {
|
if (layer.type === 'tilelayer' && this.getExitSceneUrl(layer) !== undefined) {
|
||||||
this.loadNextGame(layer, this.map.width, this.map.tilewidth, this.map.tileheight);
|
this.loadNextGame(layer, this.mapFile.width, this.mapFile.tilewidth, this.mapFile.tileheight);
|
||||||
}
|
}
|
||||||
if (layer.type === 'tilelayer' && layer.name === "start") {
|
if (layer.type === 'tilelayer' && layer.name === "start") {
|
||||||
let startPosition = this.startUser(layer);
|
let startPosition = this.startUser(layer);
|
||||||
@ -265,7 +265,7 @@ export class GameScene extends Phaser.Scene {
|
|||||||
* @param layer
|
* @param layer
|
||||||
*/
|
*/
|
||||||
private startUser(layer: ITiledMapLayer): PositionInterface {
|
private startUser(layer: ITiledMapLayer): PositionInterface {
|
||||||
if (this.initPosition !== undefined) {
|
if (this.initPosition !== null) {
|
||||||
this.startX = this.initPosition.x;
|
this.startX = this.initPosition.x;
|
||||||
this.startY = this.initPosition.y;
|
this.startY = this.initPosition.y;
|
||||||
return {
|
return {
|
||||||
|
@ -8,8 +8,17 @@
|
|||||||
"target": "es5",
|
"target": "es5",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
|
||||||
|
"strict": false, /* Enable all strict type-checking options. */
|
||||||
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
"strictNullChecks": true, /* Enable strict null checks. */
|
||||||
|
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
"strictPropertyInitialization": false, /* Enable strict checking of property initialization in classes. */
|
||||||
|
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */
|
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user