2020-04-03 14:56:21 +02:00
|
|
|
import 'phaser';
|
|
|
|
import GameConfig = Phaser.Types.Core.GameConfig;
|
2020-08-31 12:18:00 +02:00
|
|
|
import {DEBUG_MODE, JITSI_URL, RESOLUTION} from "./Enum/EnvironmentVariable";
|
2020-04-14 20:04:55 +02:00
|
|
|
import {cypressAsserter} from "./Cypress/CypressAsserter";
|
2020-05-24 23:14:12 +02:00
|
|
|
import {LoginScene} from "./Phaser/Login/LoginScene";
|
2020-05-23 15:43:26 +02:00
|
|
|
import {ReconnectingScene} from "./Phaser/Reconnecting/ReconnectingScene";
|
2020-05-25 23:26:27 +02:00
|
|
|
import {SelectCharacterScene} from "./Phaser/Login/SelectCharacterScene";
|
2020-06-23 12:24:36 +02:00
|
|
|
import {EnableCameraScene} from "./Phaser/Login/EnableCameraScene";
|
2020-07-07 22:52:22 +02:00
|
|
|
import {FourOFourScene} from "./Phaser/Reconnecting/FourOFourScene";
|
2020-07-15 23:44:01 +02:00
|
|
|
import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer;
|
|
|
|
import {OutlinePipeline} from "./Phaser/Shaders/OutlinePipeline";
|
2020-07-28 11:06:08 +02:00
|
|
|
import {CustomizeScene} from "./Phaser/Login/CustomizeScene";
|
2020-08-13 18:21:48 +02:00
|
|
|
import {CoWebsiteManager} from "./WebRtc/CoWebsiteManager";
|
2020-10-12 16:23:07 +02:00
|
|
|
import {gameManager} from "./Phaser/Game/GameManager";
|
2020-10-07 18:03:34 +02:00
|
|
|
import {ResizableScene} from "./Phaser/Login/ResizableScene";
|
2020-10-12 18:59:49 +02:00
|
|
|
import {EntryScene} from "./Phaser/Login/EntryScene";
|
2020-08-13 18:21:48 +02:00
|
|
|
|
|
|
|
//CoWebsiteManager.loadCoWebsite('https://thecodingmachine.com');
|
|
|
|
|
2020-08-31 12:18:00 +02:00
|
|
|
// Load Jitsi if the environment variable is set.
|
|
|
|
if (JITSI_URL) {
|
|
|
|
const jitsiScript = document.createElement('script');
|
|
|
|
jitsiScript.src = 'https://' + JITSI_URL + '/external_api.js';
|
|
|
|
document.head.appendChild(jitsiScript);
|
|
|
|
}
|
|
|
|
|
2020-08-13 18:21:48 +02:00
|
|
|
const {width, height} = CoWebsiteManager.getGameSize();
|
2020-04-07 20:41:35 +02:00
|
|
|
|
2020-04-03 14:56:21 +02:00
|
|
|
const config: GameConfig = {
|
2020-08-11 22:32:55 +02:00
|
|
|
title: "WorkAdventure",
|
2020-08-13 18:21:48 +02:00
|
|
|
width: width / RESOLUTION,
|
|
|
|
height: height / RESOLUTION,
|
2020-04-03 14:56:21 +02:00
|
|
|
parent: "game",
|
2020-10-12 18:59:49 +02:00
|
|
|
scene: [EntryScene, LoginScene, SelectCharacterScene, EnableCameraScene, ReconnectingScene, FourOFourScene, CustomizeScene],
|
2020-04-06 22:55:09 +02:00
|
|
|
zoom: RESOLUTION,
|
2020-04-11 18:17:36 +02:00
|
|
|
physics: {
|
2020-04-12 16:12:08 +02:00
|
|
|
default: "arcade",
|
|
|
|
arcade: {
|
2020-04-13 19:40:10 +02:00
|
|
|
debug: DEBUG_MODE
|
2020-04-12 16:12:08 +02:00
|
|
|
}
|
2020-07-15 23:44:01 +02:00
|
|
|
},
|
|
|
|
callbacks: {
|
|
|
|
postBoot: game => {
|
|
|
|
// FIXME: we should fore WebGL in the config.
|
2020-07-23 18:47:28 +02:00
|
|
|
const renderer = game.renderer as WebGLRenderer;
|
2020-07-15 23:44:01 +02:00
|
|
|
renderer.addPipeline(OutlinePipeline.KEY, new OutlinePipeline(game));
|
|
|
|
}
|
2020-04-12 16:12:08 +02:00
|
|
|
}
|
2020-04-03 14:56:21 +02:00
|
|
|
};
|
|
|
|
|
2020-04-14 20:04:55 +02:00
|
|
|
cypressAsserter.gameStarted();
|
|
|
|
|
2020-06-09 23:13:26 +02:00
|
|
|
const game = new Phaser.Game(config);
|
2020-04-03 18:41:06 +02:00
|
|
|
|
2020-04-26 17:54:56 +02:00
|
|
|
window.addEventListener('resize', function (event) {
|
2020-08-13 18:21:48 +02:00
|
|
|
const {width, height} = CoWebsiteManager.getGameSize();
|
|
|
|
|
|
|
|
game.scale.resize(width / RESOLUTION, height / RESOLUTION);
|
2020-10-07 18:03:34 +02:00
|
|
|
|
|
|
|
// Let's trigger the onResize method of any active scene that is a ResizableScene
|
|
|
|
for (const scene of game.scene.getScenes(true)) {
|
|
|
|
if (scene instanceof ResizableScene) {
|
|
|
|
scene.onResize(event);
|
|
|
|
}
|
|
|
|
}
|
2020-08-13 18:21:48 +02:00
|
|
|
});
|
|
|
|
CoWebsiteManager.onStateChange(() => {
|
|
|
|
const {width, height} = CoWebsiteManager.getGameSize();
|
|
|
|
|
|
|
|
game.scale.resize(width / RESOLUTION, height / RESOLUTION);
|
2020-05-13 16:17:58 +02:00
|
|
|
});
|