Cleanup: renaming "frame" to "character"
The "frame" variable actually contains a string pointing to the character selected. It has nothing to do with a frame which is usually a particular image in an animation. I'm renaming the variable accross the application to avoid confusion.
This commit is contained in:
parent
ddbd4f4c06
commit
492196b333
9 changed files with 47 additions and 47 deletions
|
@ -13,7 +13,7 @@ export interface HasMovedEvent {
|
|||
direction: string;
|
||||
x: number;
|
||||
y: number;
|
||||
frame: string;
|
||||
character: string;
|
||||
}
|
||||
|
||||
export class GameManager {
|
||||
|
@ -22,17 +22,17 @@ export class GameManager {
|
|||
private currentGameScene: GameScene;
|
||||
private playerName: string;
|
||||
SimplePeer : SimplePeerInterface;
|
||||
private frameUserSelected: string;
|
||||
private characterUserSelected: string;
|
||||
|
||||
constructor() {
|
||||
this.status = StatusGameManagerEnum.IN_PROGRESS;
|
||||
}
|
||||
|
||||
connect(name: string, frameUserSelected : string) {
|
||||
connect(name: string, characterUserSelected : string) {
|
||||
this.playerName = name;
|
||||
this.frameUserSelected = frameUserSelected;
|
||||
this.characterUserSelected = characterUserSelected;
|
||||
this.ConnexionInstance = new Connexion(name, this);
|
||||
return this.ConnexionInstance.createConnexion(frameUserSelected).then(() => {
|
||||
return this.ConnexionInstance.createConnexion(characterUserSelected).then(() => {
|
||||
this.SimplePeer = new SimplePeer(this.ConnexionInstance);
|
||||
});
|
||||
}
|
||||
|
@ -70,12 +70,12 @@ export class GameManager {
|
|||
return this.playerName;
|
||||
}
|
||||
|
||||
getFrameSelected(): string {
|
||||
return this.frameUserSelected;
|
||||
getCharacterSelected(): string {
|
||||
return this.characterUserSelected;
|
||||
}
|
||||
|
||||
pushPlayerPosition(event: HasMovedEvent) {
|
||||
this.ConnexionInstance.sharePosition(event.x, event.y, event.frame, event.direction);
|
||||
this.ConnexionInstance.sharePosition(event.x, event.y, event.character, event.direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||
this.startX,
|
||||
this.startY,
|
||||
this.GameManager.getPlayerName(),
|
||||
this.GameManager.getFrameSelected()
|
||||
this.GameManager.getCharacterSelected()
|
||||
);
|
||||
this.CurrentPlayer.initAnimation();
|
||||
|
||||
|
@ -261,15 +261,15 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||
MessageUserPosition.position.x,
|
||||
MessageUserPosition.position.y,
|
||||
MessageUserPosition.name,
|
||||
MessageUserPosition.frame
|
||||
MessageUserPosition.character
|
||||
);
|
||||
player.initAnimation();
|
||||
this.MapPlayers.add(player);
|
||||
player.updatePosition(MessageUserPosition);
|
||||
|
||||
//init colision
|
||||
this.physics.add.collider(this.CurrentPlayer, player, (CurrentPlayer: CurrentGamerInterface, MapPlayer: GamerInterface) => {
|
||||
//init collision
|
||||
/*this.physics.add.collider(this.CurrentPlayer, player, (CurrentPlayer: CurrentGamerInterface, MapPlayer: GamerInterface) => {
|
||||
CurrentPlayer.say("Hello, how are you ? ");
|
||||
});
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,12 +83,12 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
}
|
||||
if (x !== 0 || y !== 0) {
|
||||
this.move(x, y);
|
||||
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, frame: this.PlayerTexture});
|
||||
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, character: this.PlayerTexture});
|
||||
} else {
|
||||
if (this.previousMove !== PlayerAnimationNames.None) {
|
||||
direction = PlayerAnimationNames.None;
|
||||
this.stop();
|
||||
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, frame: this.PlayerTexture});
|
||||
this.emit(hasMovedEventName, {direction, x: this.x, y: this.y, character: this.PlayerTexture});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue