2021-05-12 09:13:25 +02:00
import type { GameScene } from "../Game/GameScene" ;
import type { PointInterface } from "../../Connexion/ConnexionModels" ;
2020-06-04 18:54:34 +02:00
import { Character } from "../Entity/Character" ;
2021-05-12 09:13:25 +02:00
import type { PlayerAnimationDirections } from "../Player/Animation" ;
2020-06-04 18:54:34 +02:00
/ * *
* 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 ,
2021-01-07 17:11:22 +01:00
texturesPromise : Promise < string [ ] > ,
2021-03-11 16:13:05 +01:00
direction : PlayerAnimationDirections ,
2021-04-02 21:21:11 +02:00
moving : boolean ,
2021-04-06 19:10:18 +02:00
companion : string | null ,
companionTexturePromise? : Promise < string >
2020-06-04 18:54:34 +02:00
) {
2021-05-10 17:10:41 +02:00
super ( Scene , x , y , texturesPromise , name , direction , moving , 1 , companion , companionTexturePromise ) ;
2020-06-04 18:54:34 +02:00
//set data
this . userId = userId ;
}
updatePosition ( position : PointInterface ) : void {
2021-03-11 16:13:05 +01:00
this . playAnimation ( position . direction as PlayerAnimationDirections , position . moving ) ;
2020-06-04 18:54:34 +02:00
this . setX ( position . x ) ;
this . setY ( position . y ) ;
2021-05-12 09:13:25 +02:00
2021-01-06 15:00:54 +01:00
this . setDepth ( position . y ) ; //this is to make sure the perspective (player models closer the bottom of the screen will appear in front of models nearer the top of the screen).
2021-05-12 09:13:25 +02:00
2021-04-01 18:51:51 +02:00
if ( this . companion ) {
this . companion . setTarget ( position . x , position . y , position . direction as PlayerAnimationDirections ) ;
}
2020-06-04 18:54:34 +02:00
}
2021-05-10 17:10:41 +02:00
isClickable ( ) : boolean {
return false ; //todo: make remote players clickable if they are logged in.
}
2020-06-04 18:54:34 +02:00
}