Removing any in the front
This commit is contained in:
parent
8348d13bfe
commit
39928b46f9
5 changed files with 52 additions and 46 deletions
|
@ -1,6 +1,6 @@
|
|||
import {GameScene} from "./GameScene";
|
||||
import {
|
||||
Connection,
|
||||
Connection, ConnectionInterface,
|
||||
GroupCreatedUpdatedMessageInterface,
|
||||
ListMessageUserPositionInterface,
|
||||
MessageUserJoined,
|
||||
|
@ -44,11 +44,11 @@ export class GameManager {
|
|||
//this.status = StatusGameManagerEnum.IN_PROGRESS;
|
||||
}
|
||||
|
||||
connect(name: string, characterUserSelected : string) {
|
||||
public connect(name: string, characterUserSelected : string): Promise<ConnectionInterface> {
|
||||
this.playerName = name;
|
||||
this.characterUserSelected = characterUserSelected;
|
||||
this.ConnectionInstance = new Connection(this);
|
||||
return this.ConnectionInstance.createConnection(name, characterUserSelected).then((data : any) => {
|
||||
return this.ConnectionInstance.createConnection(name, characterUserSelected).then((data : ConnectionInterface) => {
|
||||
this.SimplePeer = new SimplePeer(this.ConnectionInstance);
|
||||
return data;
|
||||
}).catch((err) => {
|
||||
|
|
|
@ -58,7 +58,7 @@ export class GameScene extends Phaser.Scene {
|
|||
y: -1000
|
||||
}
|
||||
|
||||
PositionNextScene: Array<any> = new Array<any>();
|
||||
private PositionNextScene: Array<Array<{ key: string, hash: string }>> = new Array<Array<{ key: string, hash: string }>>();
|
||||
private startLayerName: string|undefined;
|
||||
|
||||
static createFromUrl(mapUrlFile: string, instance: string): GameScene {
|
||||
|
@ -295,15 +295,13 @@ export class GameScene extends Phaser.Scene {
|
|||
}
|
||||
|
||||
//push and save switching case
|
||||
// TODO: this is not efficient. We should refactor that to enable a search by key. For instance: this.PositionNextScene[y][x] = exitSceneKey
|
||||
this.PositionNextScene.push({
|
||||
xStart: (x * tileWidth),
|
||||
yStart: (y * tileWidth),
|
||||
xEnd: ((x +1) * tileHeight),
|
||||
yEnd: ((y + 1) * tileHeight),
|
||||
if (this.PositionNextScene[y] === undefined) {
|
||||
this.PositionNextScene[y] = new Array<{key: string, hash: string}>();
|
||||
}
|
||||
this.PositionNextScene[y][x] = {
|
||||
key: exitSceneKey,
|
||||
hash
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,14 +467,15 @@ export class GameScene extends Phaser.Scene {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
checkToExit(){
|
||||
if(this.PositionNextScene.length === 0){
|
||||
checkToExit(): {key: string, hash: string} | null {
|
||||
const x = Math.floor(this.CurrentPlayer.x / 32);
|
||||
const y = Math.floor(this.CurrentPlayer.y / 32);
|
||||
|
||||
if (this.PositionNextScene[y] !== undefined && this.PositionNextScene[y][x] !== undefined) {
|
||||
return this.PositionNextScene[y][x];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return this.PositionNextScene.find((position : any) => {
|
||||
return position.xStart <= this.CurrentPlayer.x && this.CurrentPlayer.x <= position.xEnd
|
||||
&& position.yStart <= this.CurrentPlayer.y && this.CurrentPlayer.y <= position.yEnd
|
||||
})
|
||||
}
|
||||
|
||||
public initUsersPosition(usersPosition: MessageUserPositionInterface[]): void {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import Map = Phaser.Structs.Map;
|
||||
import {GameScene} from "../Game/GameScene";
|
||||
|
||||
interface UserInputManagerDatum {
|
||||
|
@ -18,15 +17,13 @@ export enum UserInputEvent {
|
|||
|
||||
//we cannot the map structure so we have to create a replacment
|
||||
export class ActiveEventList {
|
||||
private KeysCode : any;
|
||||
constructor() {
|
||||
this.KeysCode = {};
|
||||
}
|
||||
private KeysCode : Map<UserInputEvent, boolean> = new Map<UserInputEvent, boolean>();
|
||||
|
||||
get(event: UserInputEvent): boolean {
|
||||
return this.KeysCode[event] || false;
|
||||
return this.KeysCode.get(event) || false;
|
||||
}
|
||||
set(event: UserInputEvent, value: boolean): boolean {
|
||||
return this.KeysCode[event] = true;
|
||||
set(event: UserInputEvent, value: boolean): void {
|
||||
this.KeysCode.set(event, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue