2021-07-19 17:05:23 +02:00
|
|
|
import { gameManager } from "../Game/GameManager";
|
|
|
|
import { Scene } from "phaser";
|
2021-08-15 08:51:35 +02:00
|
|
|
import { ErrorScene, ErrorSceneName } from "../Reconnecting/ErrorScene";
|
2021-07-19 17:05:23 +02:00
|
|
|
import { WAError } from "../Reconnecting/WAError";
|
|
|
|
import { waScaleManager } from "../Services/WaScaleManager";
|
2021-12-03 09:28:30 +01:00
|
|
|
import { ReconnectingTextures } from "../Reconnecting/ReconnectingScene";
|
2021-12-08 01:34:50 +01:00
|
|
|
import { translator } from "../../Translator/Translator";
|
2020-10-12 18:59:49 +02:00
|
|
|
|
|
|
|
export const EntrySceneName = "EntryScene";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The EntryScene is not a real scene. It is the first scene loaded and is only used to initialize the gameManager
|
|
|
|
* and to route to the next correct scene.
|
|
|
|
*/
|
|
|
|
export class EntryScene extends Scene {
|
2021-12-08 01:34:50 +01:00
|
|
|
|
2020-10-12 18:59:49 +02:00
|
|
|
constructor() {
|
|
|
|
super({
|
2021-07-19 17:05:23 +02:00
|
|
|
key: EntrySceneName,
|
2020-10-12 18:59:49 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 09:28:30 +01:00
|
|
|
// From the very start, let's preload images used in the ReconnectingScene.
|
|
|
|
preload() {
|
|
|
|
this.load.image(ReconnectingTextures.icon, "static/images/favicons/favicon-32x32.png");
|
|
|
|
// Note: arcade.png from the Phaser 3 examples at: https://github.com/photonstorm/phaser3-examples/tree/master/public/assets/fonts/bitmap
|
|
|
|
this.load.bitmapFont(ReconnectingTextures.mainFont, "resources/fonts/arcade.png", "resources/fonts/arcade.xml");
|
|
|
|
this.load.spritesheet("cat", "resources/characters/pipoya/Cat 01-1.png", { frameWidth: 32, frameHeight: 32 });
|
2021-12-08 01:34:50 +01:00
|
|
|
translator.loadCurrentLanguageFile(this.load);
|
2021-12-03 09:28:30 +01:00
|
|
|
}
|
|
|
|
|
2020-10-12 18:59:49 +02:00
|
|
|
create() {
|
2021-12-08 01:34:50 +01:00
|
|
|
translator
|
|
|
|
.loadCurrentLanguageObject(this.cache)
|
|
|
|
.catch((e: unknown) => {
|
|
|
|
console.error("Error during language loading!", e);
|
2021-07-19 17:05:23 +02:00
|
|
|
})
|
2021-12-08 01:34:50 +01:00
|
|
|
.finally(() => {
|
|
|
|
gameManager
|
|
|
|
.init(this.scene)
|
|
|
|
.then((nextSceneName) => {
|
|
|
|
// Let's rescale before starting the game
|
|
|
|
// We can do it at this stage.
|
|
|
|
waScaleManager.applyNewSize();
|
|
|
|
this.scene.start(nextSceneName);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
if (err.response && err.response.status == 404) {
|
|
|
|
ErrorScene.showError(
|
|
|
|
new WAError(
|
|
|
|
"Access link incorrect",
|
|
|
|
"Could not find map. Please check your access link.",
|
|
|
|
"If you want more information, you may contact administrator or contact us at: hello@workadventu.re"
|
|
|
|
),
|
|
|
|
this.scene
|
|
|
|
);
|
|
|
|
} else if (err.response && err.response.status == 403) {
|
|
|
|
ErrorScene.showError(
|
|
|
|
new WAError(
|
|
|
|
"Connection rejected",
|
|
|
|
"You cannot join the World. Try again later" +
|
|
|
|
(err.response.data ? ". \n\r \n\r" + `${err.response.data}` : "") +
|
|
|
|
".",
|
|
|
|
"If you want more information, you may contact administrator or contact us at: hello@workadventu.re"
|
|
|
|
),
|
|
|
|
this.scene
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
ErrorScene.showError(err, this.scene);
|
|
|
|
}
|
|
|
|
});
|
2021-07-19 17:05:23 +02:00
|
|
|
});
|
2020-10-12 18:59:49 +02:00
|
|
|
}
|
|
|
|
}
|