From 4157a12f5d08167a3e33275cfd2d61ad8d21a540 Mon Sep 17 00:00:00 2001 From: gparant Date: Sat, 9 May 2020 16:47:55 +0200 Subject: [PATCH] Update name map - Change name in game scene and login scene --- front/src/Phaser/Game/GameScene.ts | 26 +++++++++++++++----------- front/src/Phaser/Login/LogincScene.ts | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 877e878f..26ce32c2 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -11,17 +11,23 @@ import Graphics = Phaser.GameObjects.Graphics; import Texture = Phaser.Textures.Texture; import Sprite = Phaser.GameObjects.Sprite; import CanvasTexture = Phaser.Textures.CanvasTexture; +import {Floor1Name} from "./GameSceneFloor1"; -export const GameSceneName = "GameScene"; export enum Textures { - Player = 'male1', - Map = 'map' + Player = "male1", + Map = 'floor0', + MapUrl = 'maps/floor0.json' } +export const Floor0Name = "Floor0"; + export interface GameSceneInterface extends Phaser.Scene { Map: Phaser.Tilemaps.Tilemap; createCurrentPlayer(UserId : string) : void; shareUserPosition(UsersPosition : Array): void; + shareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface): void; + updateOrCreateMapPlayer(UsersPosition : Array): void; + deleteGroup(groupId: string): void; } export class GameScene extends Phaser.Scene implements GameSceneInterface{ GameManager : GameManager; @@ -39,7 +45,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ constructor() { super({ - key: GameSceneName + key: Floor0Name }); this.GameManager = gameManager; this.Terrains = []; @@ -49,7 +55,6 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ //hook preload scene preload(): void { this.GameManager.setCurrentGameScene(this); - let mapUrl = 'maps/map.json'; this.load.on('filecomplete-tilemapJSON-'+Textures.Map, (key: string, type: string, data: any) => { // Triggered when the map is loaded // Load tiles attached to the map recursively @@ -59,11 +64,11 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ console.warn("Don't know how to handle tileset ", tileset) return; } - let path = mapUrl.substr(0, mapUrl.lastIndexOf('/')); + let path = Textures.MapUrl.substr(0, Textures.MapUrl.lastIndexOf('/')); this.load.image(tileset.name, path + '/' + tileset.image); }) }); - this.load.tilemapTiledJSON(Textures.Map, mapUrl); + this.load.tilemapTiledJSON(Textures.Map, Textures.MapUrl); //add player png PLAYER_RESOURCES.forEach((playerResource: any) => { @@ -78,13 +83,12 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ } //hook initialisation - init() { - } + init() {} //hook create scene create(): void { //initalise map - this.Map = this.add.tilemap("map"); + this.Map = this.add.tilemap(Textures.Map); this.map.tilesets.forEach((tileset: ITiledTileSet) => { this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.name)); }); @@ -274,7 +278,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{ * Create new player * @param MessageUserPosition */ - addPlayer(MessageUserPosition : MessageUserPositionInterface){ + addPlayer(MessageUserPosition : MessageUserPositionInterface) : void{ //initialise player let player = new Player( MessageUserPosition.userId, diff --git a/front/src/Phaser/Login/LogincScene.ts b/front/src/Phaser/Login/LogincScene.ts index 7aadfbc5..c3aaa056 100644 --- a/front/src/Phaser/Login/LogincScene.ts +++ b/front/src/Phaser/Login/LogincScene.ts @@ -2,13 +2,14 @@ import {gameManager} from "../Game/GameManager"; import {TextField} from "../Components/TextField"; import {TextInput} from "../Components/TextInput"; import {ClickButton} from "../Components/ClickButton"; -import {GameSceneInterface, GameSceneName, Textures} from "../Game/GameScene"; +import {GameSceneInterface, Floor0Name, Textures} from "../Game/GameScene"; import Image = Phaser.GameObjects.Image; import {Player} from "../Player/Player"; import {getPlayerAnimations, PlayerAnimationNames} from "../Player/Animation"; import Rectangle = Phaser.GameObjects.Rectangle; import {PLAYER_RESOURCES} from "../Entity/PlayableCaracter"; import {cypressAsserter} from "../../Cypress/CypressAsserter"; +import {GroupCreatedUpdatedMessageInterface, MessageUserPositionInterface} from "../../Connexion"; //todo: put this constants in a dedicated file export const LoginSceneName = "LoginScene"; @@ -94,7 +95,7 @@ export class LogincScene extends Phaser.Scene implements GameSceneInterface { private async login(name: string) { gameManager.connect(name, this.selectedPlayer.texture.key).then(() => { - this.scene.start(GameSceneName); + this.scene.start(Floor0Name); }); } @@ -132,4 +133,16 @@ export class LogincScene extends Phaser.Scene implements GameSceneInterface { shareUserPosition(UsersPosition: import("../../Connexion").MessageUserPositionInterface[]): void { throw new Error("Method not implemented."); } + + deleteGroup(groupId: string): void { + throw new Error("Method not implemented."); + } + + shareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface): void { + throw new Error("Method not implemented."); + } + + updateOrCreateMapPlayer(UsersPosition: Array): void { + throw new Error("Method not implemented."); + } }