Refactored and optimized messages
Now, when a user moves, only his/her position is sent back to the other users. The position of all users is not sent each time. The messages sent to the browser are now: - the list of all users as a return to the join_room event (you can send responses to events in socket.io) - a "join_room" event sent when a new user joins the room - a "user_moved" event when a user moved - a "user_left" event when a user left the room The GameScene tracks all these events and reacts accordingly. Also, I made a number of refactoring in the classes and removed the GameSceneInterface that was useless (it was implemented by the LogincScene for no reason at all)
This commit is contained in:
parent
1e6f9bb8d9
commit
125a4d11af
12 changed files with 238 additions and 101 deletions
|
@ -2,12 +2,11 @@ import {gameManager} from "../Game/GameManager";
|
|||
import {TextField} from "../Components/TextField";
|
||||
import {TextInput} from "../Components/TextInput";
|
||||
import {ClickButton} from "../Components/ClickButton";
|
||||
import {GameScene, GameSceneInterface} from "../Game/GameScene";
|
||||
import Image = Phaser.GameObjects.Image;
|
||||
import Rectangle = Phaser.GameObjects.Rectangle;
|
||||
import {PLAYER_RESOURCES} from "../Entity/PlayableCaracter";
|
||||
import {cypressAsserter} from "../../Cypress/CypressAsserter";
|
||||
import {GroupCreatedUpdatedMessageInterface, MessageUserPositionInterface} from "../../Connexion";
|
||||
import {GroupCreatedUpdatedMessageInterface, MessageUserJoined, MessageUserPositionInterface} from "../../Connexion";
|
||||
|
||||
export function getMapKeyByUrl(mapUrlStart: string){
|
||||
// FIXME: the key should be computed from the full URL of the map.
|
||||
|
@ -28,7 +27,7 @@ enum LoginTextures {
|
|||
mainFont = "main_font"
|
||||
}
|
||||
|
||||
export class LogincScene extends Phaser.Scene implements GameSceneInterface {
|
||||
export class LogincScene extends Phaser.Scene {
|
||||
private nameInput: TextInput;
|
||||
private textField: TextField;
|
||||
private playButton: ClickButton;
|
||||
|
@ -168,20 +167,4 @@ export class LogincScene extends Phaser.Scene implements GameSceneInterface {
|
|||
this.selectedPlayer = this.players[0];
|
||||
this.selectedPlayer.play(PLAYER_RESOURCES[0].name);
|
||||
}
|
||||
|
||||
shareUserPosition(UsersPosition: import("../../Connexion").MessageUserPositionInterface[]): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
deleteGroup(groupId: string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
shareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
updateOrCreateMapPlayer(UsersPosition: Array<MessageUserPositionInterface>): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue