Merge pull request #507 from thecodingmachine/develop

Release 2020-12-18
This commit is contained in:
David Négrier 2021-01-04 14:35:17 +01:00 committed by GitHub
commit cc805f5086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 32 deletions

View file

@ -167,7 +167,7 @@ jobs:
- uses: rlespinasse/github-slug-action@3.1.0
- name: Deploy
uses: thecodingmachine/deeployer@master
uses: thecodingmachine/deeployer-action@master
env:
KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }}
ADMIN_API_TOKEN: ${{ secrets.ADMIN_API_TOKEN }}

View file

@ -0,0 +1 @@
export class TextureError extends Error{}

View file

@ -3,6 +3,7 @@ import {SpeechBubble} from "./SpeechBubble";
import BitmapText = Phaser.GameObjects.BitmapText;
import Container = Phaser.GameObjects.Container;
import Sprite = Phaser.GameObjects.Sprite;
import {TextureError} from "../../Exception/TextureError";
export interface PlayerResourceDescriptionInterface {
name: string,
@ -94,6 +95,9 @@ export abstract class Character extends Container {
public addTextures(textures: string[], frame?: string | number): void {
for (const texture of textures) {
if(!this.scene.textures.exists(texture)){
throw new TextureError('texture not found');
}
const sprite = new Sprite(this.scene, 0, 0, texture, frame);
sprite.setInteractive({useHandCursor: true});
this.add(sprite);
@ -106,7 +110,9 @@ export abstract class Character extends Container {
});
})
// Needed, otherwise, animations are not handled correctly.
this.scene.sys.updateList.add(sprite);
if(this.scene) {
this.scene.sys.updateList.add(sprite);
}
this.sprites.set(texture, sprite);
}
}
@ -152,10 +158,7 @@ export abstract class Character extends Container {
if (moving && (!sprite.anims.currentAnim || sprite.anims.currentAnim.key !== direction)) {
sprite.play(texture+'-'+direction, true);
} else if (!moving) {
/*if (this.anims.currentAnim) {
this.anims.stop();
}*/
sprite.play(texture+'-'+direction, true);
sprite.anims.play(texture + '-' + direction, true);
sprite.anims.stop();
}
}
@ -229,7 +232,9 @@ export abstract class Character extends Container {
this.scene.events.removeListener('postupdate', this.postupdate.bind(this));
}
for (const sprite of this.sprites.values()) {
this.scene.sys.updateList.remove(sprite);
if(this.scene) {
this.scene.sys.updateList.remove(sprite);
}
}
super.destroy(fromScene);
this.playerName.destroy();

View file

@ -63,6 +63,8 @@ import {urlManager} from "../../Url/UrlManager";
import {PresentationModeIcon} from "../Components/PresentationModeIcon";
import {ChatModeIcon} from "../Components/ChatModeIcon";
import {OpenChatIcon, openChatIconName} from "../Components/OpenChatIcon";
import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene";
import {TextureError} from "../../Exception/TextureError";
export interface GameSceneInitInterface {
initPosition: PointInterface|null,
@ -155,14 +157,14 @@ export class GameScene extends ResizableScene implements CenterListener {
private playerName!: string;
private characterLayers!: string[];
constructor(private room: Room, MapUrlFile: string) {
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
super({
key: room.id
key: customKey ?? room.id
});
this.Terrains = [];
this.groups = new Map<number, Sprite>();
this.instance = room.getInstance();
this.MapUrlFile = MapUrlFile;
this.RoomId = room.id;
@ -517,7 +519,7 @@ export class GameScene extends ResizableScene implements CenterListener {
this.simplePeer.unregister();
const gameSceneKey = 'somekey' + Math.round(Math.random() * 10000);
const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile);
const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile, gameSceneKey);
this.scene.add(gameSceneKey, game, true,
{
initPosition: {
@ -579,8 +581,8 @@ export class GameScene extends ResizableScene implements CenterListener {
this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection, this.userInputManager, this.connection.isAdmin());
this.scene.wake();
this.scene.sleep(ReconnectingSceneName);
this.scene.wake();
this.scene.stop(ReconnectingSceneName);
//init user position and play trigger to check layers properties
this.gameMap.setPosition(this.CurrentPlayer.x, this.CurrentPlayer.y);
@ -670,8 +672,12 @@ export class GameScene extends ResizableScene implements CenterListener {
public cleanupClosingScene(): void {
// We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map.
this.connection.closeConnection();
this.simplePeer.unregister();
if(this.connection) {
this.connection.closeConnection();
}
if(this.simplePeer) {
this.simplePeer.unregister();
}
}
private switchLayoutMode(): void {
@ -818,16 +824,23 @@ export class GameScene extends ResizableScene implements CenterListener {
createCurrentPlayer(){
//initialise player
//TODO create animation moving between exit and start
this.CurrentPlayer = new Player(
this,
this.startX,
this.startY,
this.playerName,
this.characterLayers,
PlayerAnimationNames.WalkDown,
false,
this.userInputManager
);
try {
this.CurrentPlayer = new Player(
this,
this.startX,
this.startY,
this.playerName,
this.characterLayers,
PlayerAnimationNames.WalkDown,
false,
this.userInputManager
);
}catch (err){
if(err instanceof TextureError) {
gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene());
}
throw err;
}
//create collision
this.createCollisionWithPlayer();
@ -1220,6 +1233,6 @@ export class GameScene extends ResizableScene implements CenterListener {
});
}))
}
}

View file

@ -126,10 +126,10 @@ export class CustomizeScene extends ResizableScene {
gameManager.tryResumingGame(this, EnableCameraSceneName);
});
this.input.keyboard.on('keydown-RIGHT', () => this.moveCursorHorizontally(1));
this.input.keyboard.on('keydown-LEFT', () => this.moveCursorHorizontally(-1));
this.input.keyboard.on('keydown-DOWN', () => this.moveCursorVertically(1));
this.input.keyboard.on('keydown-UP', () => this.moveCursorVertically(-1));
this.input.keyboard.on('keyup-RIGHT', () => this.moveCursorHorizontally(1));
this.input.keyboard.on('keyup-LEFT', () => this.moveCursorHorizontally(-1));
this.input.keyboard.on('keyup-DOWN', () => this.moveCursorVertically(1));
this.input.keyboard.on('keyup-UP', () => this.moveCursorVertically(-1));
const customCursorPosition = localUserStore.getCustomCursorPosition();
if (customCursorPosition) {

File diff suppressed because one or more lines are too long

View file

@ -109,6 +109,9 @@
<li>set a start position for the players</li>
<li>configure the &quot;floor layer&quot; (so that WorkAdventure can correctly display characters above the floor, but under the ceiling)</li>
<li>eventually, you can place exits that link to other maps</li>
<li>the "Tile Layer Format" must be set to CSV. If you started from the map starter kit as explained above,
you have nothing to do. However, if you start from scratch, please be sure to select "CSV" for the tile layer format
when creating the map. You can change this setting later in the map properties.</li>
</ul>
<h3 id="workadventure-maps-rules" class="pixel-title">WorkAdventure Map Rules</h3>