Feedback review MR

- Extend the ResizableScene instead.
- Remove ErrorScene
- Add git ignore
This commit is contained in:
Gregoire Parant 2020-11-04 12:39:28 +01:00
parent 00ce899a74
commit 1f7f94ea9c
3 changed files with 36 additions and 24 deletions

1
front/dist/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
tests/*

View file

@ -55,7 +55,7 @@ import {ResizableScene} from "../Login/ResizableScene";
import {Room} from "../../Connexion/Room"; import {Room} from "../../Connexion/Room";
import {jitsiFactory} from "../../WebRtc/JitsiFactory"; import {jitsiFactory} from "../../WebRtc/JitsiFactory";
import {MessageUI} from "../../Logger/MessageUI"; import {MessageUI} from "../../Logger/MessageUI";
import {WaitScene} from "../Reconnecting/WaitScene"; import {ErrorScene} from "../Reconnecting/ErrorScene";
export enum Textures { export enum Textures {
@ -610,9 +610,6 @@ export class GameScene extends ResizableScene implements CenterListener {
}); });
connection.onCloseMessage((status: number) => { connection.onCloseMessage((status: number) => {
console.log(`close message status : ${status}`);
//TODO show wait room
this.connection.closeConnection(); this.connection.closeConnection();
this.simplePeer.unregister(); this.simplePeer.unregister();
connection.closeConnection(); connection.closeConnection();
@ -620,7 +617,11 @@ export class GameScene extends ResizableScene implements CenterListener {
const waitGameSceneKey = 'somekey' + Math.round(Math.random() * 10000); const waitGameSceneKey = 'somekey' + Math.round(Math.random() * 10000);
//show wait scene //show wait scene
setTimeout(() => { setTimeout(() => {
const game: Phaser.Scene = new WaitScene(waitGameSceneKey, status); /**
* Note: the ErrorScene could then become a singleton. In the future,
* an error message could originate from the server directly.
* **/
const game: Phaser.Scene = new ErrorScene(waitGameSceneKey);
this.scene.add(waitGameSceneKey, game, true, { this.scene.add(waitGameSceneKey, game, true, {
initPosition: { initPosition: {
x: this.CurrentPlayer.x, x: this.CurrentPlayer.x,
@ -628,7 +629,16 @@ export class GameScene extends ResizableScene implements CenterListener {
} }
}); });
this.scene.stop(this.scene.key); this.scene.stop(this.scene.key);
this.scene.start(waitGameSceneKey); this.scene.start(waitGameSceneKey, {
status: status,
text : 'Oups! Work Adventure is too popular, ' +
'\n' +
'\n' +
'the maximum number of players has been reached!' +
'\n' +
'\n' +
`Reconnect in 30 secondes ...`
});
}, 500); }, 500);
//trying to reload map //trying to reload map

View file

@ -1,36 +1,28 @@
import {TextField} from "../Components/TextField"; import {TextField} from "../Components/TextField";
import Image = Phaser.GameObjects.Image; import Image = Phaser.GameObjects.Image;
import {ResizableScene} from "../Login/ResizableScene";
enum ReconnectingTextures { enum ReconnectingTextures {
icon = "icon", icon = "icon",
mainFont = "main_font" mainFont = "main_font"
} }
export class WaitScene extends Phaser.Scene { export class ErrorScene extends ResizableScene {
private reconnectingField!: TextField; private reconnectingField!: TextField;
private catImage!: Phaser.Physics.Arcade.Sprite;
private logo!: Image; private logo!: Image;
private text: string = ''; private text: string = '';
private status: number = 404;
constructor(key: string, private readonly status: number) { constructor(key: string) {
super({ super({
key: key key: key
}); });
this.initialiseText();
} }
initialiseText() { init(data: {status: number, text: string}){
this.text = `${this.status}` + '\n' + '\n'; this.text = data.text;
switch (this.status) { this .status = data.status;
case 302:
this.text += 'Aie ! Work Adventure est victime de son succes, ' +
'\n' +
'\n' +
'le nombre maximum de joueurs a ete atteint !' +
'\n' +
'\n' +
`Reconnexion dans 30 secondes ...`;
break;
}
} }
preload() { preload() {
@ -54,7 +46,7 @@ export class WaitScene extends Phaser.Scene {
this.game.renderer.height / 2, this.game.renderer.height / 2,
this.text); this.text);
const cat = this.physics.add.sprite( this.catImage = this.physics.add.sprite(
this.game.renderer.width / 2, this.game.renderer.width / 2,
this.game.renderer.height / 2 - 70, this.game.renderer.height / 2 - 70,
'cat'); 'cat');
@ -65,6 +57,15 @@ export class WaitScene extends Phaser.Scene {
frameRate: 10, frameRate: 10,
repeat: -1 repeat: -1
}); });
cat.play('right'); this.catImage.play('right');
}
onResize(){
this.reconnectingField.x = this.game.renderer.width / 2;
this.reconnectingField.y = this.game.renderer.height / 2;
this.catImage.x = this.game.renderer.width / 2;
this.catImage.y = this.game.renderer.height / 2 - 70;
this.logo.x = this.game.renderer.width - 30;
this.logo.y = this.game.renderer.height - 30;
} }
} }