2020-06-04 18:54:34 +02:00
|
|
|
import {GameScene} from "../Game/GameScene";
|
|
|
|
import {PointInterface} from "../../Connection";
|
|
|
|
import {Character} from "../Entity/Character";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class representing the sprite of a remote player (a player that plays on another computer)
|
|
|
|
*/
|
|
|
|
export class RemotePlayer extends Character {
|
2020-09-18 13:57:38 +02:00
|
|
|
userId: number;
|
2020-06-04 18:54:34 +02:00
|
|
|
|
|
|
|
constructor(
|
2020-09-18 13:57:38 +02:00
|
|
|
userId: number,
|
2020-06-04 18:54:34 +02:00
|
|
|
Scene: GameScene,
|
|
|
|
x: number,
|
|
|
|
y: number,
|
|
|
|
name: string,
|
2020-07-28 17:43:33 +02:00
|
|
|
PlayerTextures: string[],
|
2020-06-04 18:54:34 +02:00
|
|
|
direction: string,
|
|
|
|
moving: boolean
|
|
|
|
) {
|
2020-07-28 17:43:33 +02:00
|
|
|
super(Scene, x, y, PlayerTextures, name, direction, moving, 1);
|
2020-06-04 18:54:34 +02:00
|
|
|
|
|
|
|
//set data
|
|
|
|
this.userId = userId;
|
|
|
|
|
|
|
|
//the current player model should be push away by other players to prevent conflict
|
|
|
|
//this.setImmovable(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
updatePosition(position: PointInterface): void {
|
|
|
|
this.playAnimation(position.direction, position.moving);
|
|
|
|
this.setX(position.x);
|
|
|
|
this.setY(position.y);
|
|
|
|
this.setDepth(position.y);
|
|
|
|
}
|
|
|
|
}
|