socket.position = message.position;
socket.roomId = message.roomId;
socket.userId = message.userId;
+ socket.name = message.name;
}
refreshUserPosition() {
roomId: string;
webRtcRoomId: string;
userId: string;
+ name: string;
position: PointInterface;
}
\ No newline at end of file
[room: string]: SocketIO.Room;
}
-let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server){
+let RefreshUserPositionFunction = function(rooms : ExtRooms, Io: socketIO.Server) {
let clients = Io.clients();
let socketsKey = Object.keys(Io.clients().sockets);
//create mapping with all users in all rooms
let mapPositionUserByRoom = new Map();
- for(let i = 0; i < socketsKey.length; i++){
+ for (let i = 0; i < socketsKey.length; i++) {
let socket = clients.sockets[socketsKey[i]] as ExSocketInterface;
- if(!socket.position){
+ if (!socket.position) {
continue;
}
let data = {
- userId : socket.userId,
- roomId : socket.roomId,
- position : socket.position,
+ userId: socket.userId,
+ roomId: socket.roomId,
+ position: socket.position,
+ name: socket.name,
};
let dataArray = <any>[];
- if(mapPositionUserByRoom.get(data.roomId)){
+ if (mapPositionUserByRoom.get(data.roomId)) {
dataArray = mapPositionUserByRoom.get(data.roomId);
dataArray.push(data);
- }else{
+ } else {
dataArray = [data];
}
mapPositionUserByRoom.set(data.roomId, dataArray);
export class Message {
userId: string;
roomId: string;
+ name: string;
constructor(data: any) {
if (!data.userId || !data.roomId) {
}
this.userId = data.userId;
this.roomId = data.roomId;
+ this.name = data.name;
}
toJson() {
return {
userId: this.userId,
- roomId: this.roomId
+ roomId: this.roomId,
+ name: this.name
}
}
}
\ No newline at end of file
cursor: pointer;
position: absolute;
border: solid 0px black;
- width: 64px;
- height: 64px;
+ width: 44px;
+ height: 44px;
background: #666;
box-shadow: 2px 2px 24px #444;
border-radius: 48px;
}
.btn-micro{
transition: all .3s;
- right: 10px;
+ right: 44px;
}
.btn-video{
transition: all .2s;
- right: 114px;
+ right: 134px;
}
/*.btn-call{
transition: all .1s;
left: 0px;
}*/
.btn-cam-action div img{
- height: 32px;
- width: 40px;
- top: calc(48px - 32px);
- left: calc(48px - 35px);
+ height: 22px;
+ width: 30px;
+ top: calc(48px - 37px);
+ left: calc(48px - 41px);
position: relative;
}
\ No newline at end of file
class Message {
userId: string;
roomId: string;
+ name: string;
- constructor(userId : string, roomId : string) {
+ constructor(userId : string, roomId : string, name: string) {
this.userId = userId;
this.roomId = roomId;
+ this.name = name;
}
toJson() {
return {
userId: this.userId,
roomId: this.roomId,
+ name: this.name
}
}
}
export interface MessageUserPositionInterface {
userId: string;
roomId: string;
+ name: string;
position: PointInterface;
}
class MessageUserPosition extends Message implements MessageUserPositionInterface{
position: PointInterface;
- constructor(userId : string, roomId : string, point : Point) {
- super(userId, roomId);
+ constructor(userId : string, roomId : string, point : Point, name: string) {
+ super(userId, roomId, name);
this.position = point;
}
userPosition.position.x,
userPosition.position.y,
userPosition.position.direction
- )
+ ),
+ userPosition.name
));
});
}
* @param roomId
*/
joinARoom(roomId: string): void {
- let messageUserPosition = new MessageUserPosition(this.userId, this.startedRoom, new Point(0, 0));
+ let messageUserPosition = new MessageUserPosition(this.userId, this.startedRoom, new Point(0, 0), this.email);
this.socket.emit(EventMessage.JOIN_ROOM, messageUserPosition.toString());
}
if(!this.socket){
return;
}
- let messageUserPosition = new MessageUserPosition(this.userId, ROOM[0], new Point(x, y, direction));
+ let messageUserPosition = new MessageUserPosition(this.userId, ROOM[0], new Point(x, y, direction), this.email);
this.socket.emit(EventMessage.USER_POSITION, messageUserPosition.toString());
}
if(this.bubble) {
this.bubble.moveBubble(this.x, this.y);
}
- this.playerName.setPosition(this.x, this.y - 25);
+ this.updatePlayerNamePosition(this.x, this.y);
+ }
+
+ updatePlayerNamePosition(x: number, y: number){
+ this.playerName.setPosition(x, y - 25);
}
stop(){
this.bubble = null;
}, 3000)
}
+
+ destroy(fromScene?: boolean): void {
+ super.destroy(fromScene);
+ this.playerName.destroy();
+ }
}
this,
MessageUserPosition.position.x,
MessageUserPosition.position.y,
- 'Foo'
+ MessageUserPosition.name
);
player.initAnimation();
this.MapPlayers.add(player);
+++ /dev/null
-import {PlayableCaracter} from "../Entity/PlayableCaracter";
-import {Textures} from "../Game/GameScene";
-import {UserInputEvent} from "../UserInput/UserInputManager";
-import {Player} from "../Player/Player";
-import {MessageUserPositionInterface} from "../../Connexion";
-import {playAnimation} from "../Player/Animation";
-
-export class NonPlayer extends PlayableCaracter {
-
- isFleeing: boolean = false;
- fleeingDirection:any = null //todo create a vector class
-
- constructor(scene: Phaser.Scene, x: number, y: number, name: string) {
- super(scene, x, y, Textures.Player, name, 1);
- this.setSize(32, 32); //edit the hitbox to better match the character model
- }
-
-
- updatePosition(MessageUserPosition : MessageUserPositionInterface){
- playAnimation(this, MessageUserPosition.position.direction);
- this.setX(MessageUserPosition.position.x);
- this.setY(MessageUserPosition.position.y);
- }
-
- fleeFrom(player:Player) {
- if (this.isFleeing) return;
- this.say("Don't touch me!");
- this.isFleeing = true;
-
- setTimeout(() => {
- this.say("Feww, I escaped.");
- this.isFleeing = false
- this.fleeingDirection = null
- }, 3000);
-
- let vectorX = this.x - player.x;
- let vectorY = this.y - player.y;
- this.fleeingDirection = {x: vectorX, y: vectorY}
- }
-}
playAnimation(this, MessageUserPosition.position.direction);
this.setX(MessageUserPosition.position.x);
this.setY(MessageUserPosition.position.y);
+ this.updatePlayerNamePosition(MessageUserPosition.position.x, MessageUserPosition.position.y);
}
}