2021-08-16 11:43:29 +02:00
|
|
|
import { SelectCharacterSceneName } from "./SelectCharacterScene";
|
|
|
|
import { ResizableScene } from "./ResizableScene";
|
2021-09-05 18:17:49 +02:00
|
|
|
import { loginSceneVisibleIframeStore, loginSceneVisibleStore } from "../../Stores/LoginSceneStore";
|
|
|
|
import { localUserStore } from "../../Connexion/LocalUserStore";
|
|
|
|
import { connectionManager } from "../../Connexion/ConnectionManager";
|
|
|
|
import { gameManager } from "../Game/GameManager";
|
2020-04-26 17:54:56 +02:00
|
|
|
|
|
|
|
export const LoginSceneName = "LoginScene";
|
2021-04-20 18:49:42 +02:00
|
|
|
|
2020-10-07 18:03:34 +02:00
|
|
|
export class LoginScene extends ResizableScene {
|
2021-08-16 11:43:29 +02:00
|
|
|
private name: string = "";
|
2020-04-29 00:01:37 +02:00
|
|
|
|
2020-04-26 17:54:56 +02:00
|
|
|
constructor() {
|
|
|
|
super({
|
2021-08-16 11:43:29 +02:00
|
|
|
key: LoginSceneName,
|
2020-04-26 17:54:56 +02:00
|
|
|
});
|
2021-08-16 11:43:29 +02:00
|
|
|
this.name = gameManager.getPlayerName() || "";
|
2020-04-26 17:54:56 +02:00
|
|
|
}
|
2020-04-29 00:01:37 +02:00
|
|
|
|
2021-08-16 11:43:29 +02:00
|
|
|
preload() {}
|
2020-04-29 00:01:37 +02:00
|
|
|
|
2020-04-26 17:54:56 +02:00
|
|
|
create() {
|
2021-09-05 18:17:49 +02:00
|
|
|
loginSceneVisibleIframeStore.set(false);
|
|
|
|
//If authentication is mandatory, push authentication iframe
|
|
|
|
if (
|
|
|
|
localUserStore.getAuthToken() == undefined &&
|
|
|
|
gameManager.currentStartedRoom &&
|
|
|
|
gameManager.currentStartedRoom?.authenticationMandatory
|
|
|
|
) {
|
|
|
|
connectionManager.loadOpenIDScreen();
|
|
|
|
loginSceneVisibleIframeStore.set(true);
|
|
|
|
}
|
2021-05-31 17:03:29 +02:00
|
|
|
loginSceneVisibleStore.set(true);
|
2020-04-26 17:54:56 +02:00
|
|
|
}
|
2020-04-29 00:01:37 +02:00
|
|
|
|
2021-05-31 17:03:29 +02:00
|
|
|
public login(name: string): void {
|
|
|
|
name = name.trim();
|
|
|
|
gameManager.setPlayerName(name);
|
2020-07-28 15:53:44 +02:00
|
|
|
|
2021-08-16 11:43:29 +02:00
|
|
|
this.scene.stop(LoginSceneName);
|
|
|
|
gameManager.tryResumingGame(SelectCharacterSceneName);
|
2021-05-31 17:03:29 +02:00
|
|
|
this.scene.remove(LoginSceneName);
|
|
|
|
loginSceneVisibleStore.set(false);
|
2020-05-04 01:48:14 +02:00
|
|
|
}
|
2020-10-07 18:03:34 +02:00
|
|
|
|
2021-08-16 11:43:29 +02:00
|
|
|
update(time: number, delta: number): void {}
|
2020-10-07 18:03:34 +02:00
|
|
|
|
2021-08-16 11:43:29 +02:00
|
|
|
public onResize(): void {}
|
2020-05-01 22:23:41 +02:00
|
|
|
}
|