Update name map

- Change name in game scene and login scene
This commit is contained in:
gparant 2020-05-09 16:47:55 +02:00
parent b983fff076
commit 4157a12f5d
2 changed files with 30 additions and 13 deletions

View File

@ -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<MessageUserPositionInterface>): void;
shareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface): void;
updateOrCreateMapPlayer(UsersPosition : Array<MessageUserPositionInterface>): 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,

View File

@ -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<MessageUserPositionInterface>): void {
throw new Error("Method not implemented.");
}
}