Adding the display of a circle around the group
This PR adds the display of a circle around groups. This is useful to view where you need to go to speak to someone but also to debug. Note: implementation is suboptimal, relying on a "graphics" object that is known to be slow. In the future, we need to use a circle as a sprite instead.
This commit is contained in:
parent
05fbcad252
commit
02e6b50b16
7 changed files with 153 additions and 12 deletions
|
@ -11,7 +11,9 @@ enum EventMessage{
|
|||
JOIN_ROOM = "join-room",
|
||||
USER_POSITION = "user-position",
|
||||
MESSAGE_ERROR = "message-error",
|
||||
WEBRTC_DISCONNECT = "webrtc-disconect"
|
||||
WEBRTC_DISCONNECT = "webrtc-disconect",
|
||||
GROUP_CREATE_UPDATE = "group-create-update",
|
||||
GROUP_DELETE = "group-delete",
|
||||
}
|
||||
|
||||
class Message {
|
||||
|
@ -122,6 +124,16 @@ class ListMessageUserPosition {
|
|||
}
|
||||
}
|
||||
|
||||
export interface PositionInterface {
|
||||
x: number,
|
||||
y: number
|
||||
}
|
||||
|
||||
export interface GroupCreatedUpdatedMessageInterface {
|
||||
position: PositionInterface,
|
||||
groupId: string
|
||||
}
|
||||
|
||||
export interface ConnexionInterface {
|
||||
socket: any;
|
||||
token: string;
|
||||
|
@ -184,6 +196,9 @@ export class Connexion implements ConnexionInterface {
|
|||
|
||||
this.errorMessage();
|
||||
|
||||
this.groupUpdatedOrCreated();
|
||||
this.groupDeleted();
|
||||
|
||||
return this;
|
||||
})
|
||||
.catch((err) => {
|
||||
|
@ -254,6 +269,19 @@ export class Connexion implements ConnexionInterface {
|
|||
});
|
||||
}
|
||||
|
||||
private groupUpdatedOrCreated(): void {
|
||||
this.socket.on(EventMessage.GROUP_CREATE_UPDATE, (groupCreateUpdateMessage: GroupCreatedUpdatedMessageInterface) => {
|
||||
//console.log('Group ', groupCreateUpdateMessage.groupId, " position :", groupCreateUpdateMessage.position.x, groupCreateUpdateMessage.position.y)
|
||||
this.GameManager.shareGroupPosition(groupCreateUpdateMessage);
|
||||
})
|
||||
}
|
||||
|
||||
private groupDeleted(): void {
|
||||
this.socket.on(EventMessage.GROUP_DELETE, (groupId: string) => {
|
||||
this.GameManager.deleteGroup(groupId);
|
||||
})
|
||||
}
|
||||
|
||||
sendWebrtcSignal(signal: any, roomId: string, userId? : string, receiverId? : string) {
|
||||
return this.socket.emit(EventMessage.WEBRTC_SIGNAL, JSON.stringify({
|
||||
userId: userId ? userId : this.userId,
|
||||
|
@ -280,4 +308,4 @@ export class Connexion implements ConnexionInterface {
|
|||
disconnectMessage(callback: Function): void {
|
||||
this.socket.on(EventMessage.WEBRTC_DISCONNECT, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue