The "frame" variable actually contains a string pointing to the character selected.
It has nothing to do with a frame which is usually a particular image in an animation.
I'm renaming the variable accross the application to avoid confusion.
socket.roomId = message.roomId;
socket.userId = message.userId;
socket.name = message.name;
- socket.frame = message.frame;
+ socket.character = message.character;
}
refreshUserPosition() {
webRtcRoomId: string;
userId: string;
name: string;
- frame: string;
+ character: string;
position: PointInterface;
-}
\ No newline at end of file
+}
roomId: socket.roomId,
position: socket.position,
name: socket.name,
- frame: socket.frame,
+ character: socket.character,
};
let dataArray = <any>[];
if (mapPositionUserByRoom.get(data.roomId)) {
export {
RefreshUserPositionFunction
-}
\ No newline at end of file
+}
userId: string;
roomId: string;
name: string;
- frame: string;
+ character: string;
constructor(data: any) {
if (!data.userId || !data.roomId) {
this.userId = data.userId;
this.roomId = data.roomId;
this.name = data.name;
- this.frame = data.frame;
+ this.character = data.character;
}
toJson() {
userId: this.userId,
roomId: this.roomId,
name: this.name,
- frame: this.frame
+ character: this.character
}
}
-}
\ No newline at end of file
+}
expect(messageObject.userId).toBe("test1");
expect(messageObject.roomId).toBe("test2");
expect(messageObject.name).toBe("foo");
- expect(messageObject.frame).toBe("user");
+ expect(messageObject.character).toBe("user");
})
it("should expose a toJson method", () => {
let messageObject = new Message(message);
}).toThrow(new Error("userId or roomId cannot be null"));
});
-})
\ No newline at end of file
+})
userId: string;
roomId: string;
name: string;
- frame: string;
+ character: string;
- constructor(userId : string, roomId : string, name: string, frame: string) {
+ constructor(userId : string, roomId : string, name: string, character: string) {
this.userId = userId;
this.roomId = roomId;
this.name = name;
- this.frame = frame;
+ this.character = character;
}
toJson() {
userId: this.userId,
roomId: this.roomId,
name: this.name,
- frame: this.frame
+ character: this.character
}
}
}
userId: string;
roomId: string;
name: string;
- frame: string;
+ character: string;
position: PointInterface;
}
class MessageUserPosition extends Message implements MessageUserPositionInterface{
position: PointInterface;
- constructor(userId : string, roomId : string, point : Point, name: string, frame: string) {
- super(userId, roomId, name, frame);
+ constructor(userId : string, roomId : string, point : Point, name: string, character: string) {
+ super(userId, roomId, name, character);
this.position = point;
}
userPosition.position.direction
),
userPosition.name,
- userPosition.frame
+ userPosition.character
));
});
}
userId: string;
startedRoom: string;
- createConnexion(frameSelected: string): Promise<any>;
+ createConnexion(characterSelected: string): Promise<any>;
- joinARoom(roomId: string, frame: string): void;
+ joinARoom(roomId: string, character: string): void;
- sharePosition(x: number, y: number, direction: string, frame: string): void;
+ sharePosition(x: number, y: number, direction: string, character: string): void;
positionOfAllUser(): void;
this.GameManager = GameManager;
}
- createConnexion(frameSelected: string): Promise<ConnexionInterface> {
+ createConnexion(characterSelected: string): Promise<ConnexionInterface> {
return Axios.post(`${API_URL}/login`, {email: this.email})
.then((res) => {
this.token = res.data.token;
});
//join the room
- this.joinARoom(this.startedRoom, frameSelected);
+ this.joinARoom(this.startedRoom, characterSelected);
//share your first position
- this.sharePosition(0, 0, frameSelected);
+ this.sharePosition(0, 0, characterSelected);
this.positionOfAllUser();
/**
*
* @param roomId
- * @param frame
+ * @param character
*/
- joinARoom(roomId: string, frame: string): void {
+ joinARoom(roomId: string, character: string): void {
let messageUserPosition = new MessageUserPosition(
this.userId,
this.startedRoom,
new Point(0, 0),
this.email,
- frame
+ character
);
this.socket.emit(EventMessage.JOIN_ROOM, messageUserPosition.toString());
}
*
* @param x
* @param y
- * @param frame
+ * @param character
* @param direction
*/
- sharePosition(x : number, y : number, frame : string, direction : string = "none") : void{
+ sharePosition(x : number, y : number, character : string, direction : string = "none") : void{
if(!this.socket){
return;
}
ROOM[0],
new Point(x, y, direction),
this.email,
- frame
+ character
);
this.socket.emit(EventMessage.USER_POSITION, messageUserPosition.toString());
}
disconnectMessage(callback: Function): void {
this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback);
}
-}
\ No newline at end of file
+}
direction: string;
x: number;
y: number;
- frame: string;
+ character: string;
}
export class GameManager {
private currentGameScene: GameScene;
private playerName: string;
SimplePeer : SimplePeerInterface;
- private frameUserSelected: string;
+ private characterUserSelected: string;
constructor() {
this.status = StatusGameManagerEnum.IN_PROGRESS;
}
- connect(name: string, frameUserSelected : string) {
+ connect(name: string, characterUserSelected : string) {
this.playerName = name;
- this.frameUserSelected = frameUserSelected;
+ this.characterUserSelected = characterUserSelected;
this.ConnexionInstance = new Connexion(name, this);
- return this.ConnexionInstance.createConnexion(frameUserSelected).then(() => {
+ return this.ConnexionInstance.createConnexion(characterUserSelected).then(() => {
this.SimplePeer = new SimplePeer(this.ConnexionInstance);
});
}
return this.playerName;
}
- getFrameSelected(): string {
- return this.frameUserSelected;
+ getCharacterSelected(): string {
+ return this.characterUserSelected;
}
pushPlayerPosition(event: HasMovedEvent) {
- this.ConnexionInstance.sharePosition(event.x, event.y, event.frame, event.direction);
+ this.ConnexionInstance.sharePosition(event.x, event.y, event.character, event.direction);
}
}
this.startX,
this.startY,
this.GameManager.getPlayerName(),
- this.GameManager.getFrameSelected()
+ this.GameManager.getCharacterSelected()
);
this.CurrentPlayer.initAnimation();
MessageUserPosition.position.x,
MessageUserPosition.position.y,
MessageUserPosition.name,
- MessageUserPosition.frame
+ MessageUserPosition.character
);
player.initAnimation();
this.MapPlayers.add(player);
player.updatePosition(MessageUserPosition);
- //init colision
- this.physics.add.collider(this.CurrentPlayer, player, (CurrentPlayer: CurrentGamerInterface, MapPlayer: GamerInterface) => {
+ //init collision
+ /*this.physics.add.collider(this.CurrentPlayer, player, (CurrentPlayer: CurrentGamerInterface, MapPlayer: GamerInterface) => {
CurrentPlayer.say("Hello, how are you ? ");
- });
+ });*/
}
}
}
if (x !== 0 || y !== 0) {
this.move(x, y);
- this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, frame: this.PlayerTexture});
+ this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, character: this.PlayerTexture});
} else {
if (this.previousMove !== PlayerAnimationNames.None) {
direction = PlayerAnimationNames.None;
this.stop();
- this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, frame: this.PlayerTexture});
+ this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, character: this.PlayerTexture});
}
}