Code cleanup and removing exception in favor of console error
This commit is contained in:
parent
407c6db070
commit
a5514ce78a
3 changed files with 20 additions and 113 deletions
|
@ -1,19 +1,7 @@
|
|||
import {GameScene} from "./GameScene";
|
||||
import {
|
||||
Connection,
|
||||
GroupCreatedUpdatedMessageInterface,
|
||||
ListMessageUserPositionInterface,
|
||||
MessageUserJoined,
|
||||
MessageUserMovedInterface,
|
||||
MessageUserPositionInterface,
|
||||
Point,
|
||||
PointInterface, StartMapInterface
|
||||
StartMapInterface
|
||||
} from "../../Connection";
|
||||
import {SimplePeer} from "../../WebRtc/SimplePeer";
|
||||
import {AddPlayerInterface} from "./AddPlayerInterface";
|
||||
import {ReconnectingScene, ReconnectingSceneName} from "../Reconnecting/ReconnectingScene";
|
||||
import ScenePlugin = Phaser.Scenes.ScenePlugin;
|
||||
import {Scene} from "phaser";
|
||||
import Axios from "axios";
|
||||
import {API_URL} from "../../Enum/EnvironmentVariable";
|
||||
|
||||
|
@ -24,11 +12,6 @@ export interface HasMovedEvent {
|
|||
y: number;
|
||||
}
|
||||
|
||||
export interface MapObject {
|
||||
key: string,
|
||||
url: string
|
||||
}
|
||||
|
||||
export class GameManager {
|
||||
private playerName: string;
|
||||
private characterUserSelected: string;
|
||||
|
|
|
@ -647,7 +647,7 @@ export class GameScene extends Phaser.Scene {
|
|||
* Put all the players on the map on map load.
|
||||
*/
|
||||
private doInitUsersPosition(usersPosition: MessageUserPositionInterface[]): void {
|
||||
const currentPlayerId = this.connection.userId;
|
||||
const currentPlayerId = this.connection.getUserId();
|
||||
|
||||
// clean map
|
||||
this.MapPlayersByKey.forEach((player: RemotePlayer) => {
|
||||
|
@ -740,7 +740,9 @@ export class GameScene extends Phaser.Scene {
|
|||
private doUpdatePlayerPosition(message: MessageUserMovedInterface): void {
|
||||
const player : RemotePlayer | undefined = this.MapPlayersByKey.get(message.userId);
|
||||
if (player === undefined) {
|
||||
throw new Error('Cannot find player with ID "' + message.userId +'"');
|
||||
//throw new Error('Cannot find player with ID "' + message.userId +'"');
|
||||
console.error('Cannot update position of player with ID "' + message.userId +'": player not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// We do not update the player position directly (because it is sent only every 200ms).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue