Fix feadback @Kharhamel
This commit is contained in:
parent
48fe86634f
commit
2afe6b4b6e
4 changed files with 183 additions and 273 deletions
|
@ -5,11 +5,9 @@ import {CameraManagerInterface} from "../Game/CameraManager";
|
|||
import {MessageUserPositionInterface} from "../../Connexion";
|
||||
import {ActiveEventList, UserInputEvent, UserInputManager} from "../UserInput/UserInputManager";
|
||||
import {PlayableCaracter} from "../Entity/PlayableCaracter";
|
||||
import {MapManagerInterface} from "../Game/MapManager";
|
||||
|
||||
export interface CurrentGamerInterface extends PlayableCaracter{
|
||||
userId : string;
|
||||
MapManager : MapManagerInterface;
|
||||
PlayerValue : string;
|
||||
CameraManager: CameraManagerInterface;
|
||||
initAnimation() : void;
|
||||
|
@ -19,7 +17,6 @@ export interface CurrentGamerInterface extends PlayableCaracter{
|
|||
|
||||
export interface GamerInterface extends PlayableCaracter{
|
||||
userId : string;
|
||||
MapManager : MapManagerInterface;
|
||||
PlayerValue : string;
|
||||
CameraManager: CameraManagerInterface;
|
||||
initAnimation() : void;
|
||||
|
@ -27,21 +24,19 @@ export interface GamerInterface extends PlayableCaracter{
|
|||
say(text : string) : void;
|
||||
}
|
||||
|
||||
export class Player extends PlayableCaracter implements CurrentGamerInterface, GamerInterface{
|
||||
userId : string;
|
||||
MapManager : MapManagerInterface;
|
||||
PlayerValue : string;
|
||||
export class Player extends PlayableCaracter implements CurrentGamerInterface, GamerInterface {
|
||||
userId: string;
|
||||
PlayerValue: string;
|
||||
CameraManager: CameraManagerInterface;
|
||||
userInputManager: UserInputManager;
|
||||
|
||||
constructor(
|
||||
userId: string,
|
||||
Scene : GameSceneInterface,
|
||||
x : number,
|
||||
y : number,
|
||||
Scene: GameSceneInterface,
|
||||
x: number,
|
||||
y: number,
|
||||
CameraManager: CameraManagerInterface,
|
||||
MapManager: MapManagerInterface,
|
||||
PlayerValue : string = Textures.Player
|
||||
PlayerValue: string = Textures.Player
|
||||
) {
|
||||
super(Scene, x, y, PlayerValue, 1);
|
||||
|
||||
|
@ -51,7 +46,6 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
//set data
|
||||
this.userId = userId;
|
||||
this.PlayerValue = PlayerValue;
|
||||
this.MapManager = MapManager;
|
||||
this.CameraManager = CameraManager;
|
||||
|
||||
//the current player model should be push away by other players to prevent conflict
|
||||
|
@ -60,7 +54,7 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
this.setSize(32, 32);
|
||||
}
|
||||
|
||||
initAnimation() : void {
|
||||
initAnimation(): void {
|
||||
getPlayerAnimations().forEach(d => {
|
||||
this.scene.anims.create({
|
||||
key: d.key,
|
||||
|
@ -71,9 +65,8 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
})
|
||||
}
|
||||
|
||||
moveUser() : void {
|
||||
moveUser(): void {
|
||||
//if user client on shift, camera and player speed
|
||||
//let speedMultiplier = this.MapManager.keyShift.isDown ? 5 : 1;
|
||||
let haveMove = false;
|
||||
let direction = null;
|
||||
|
||||
|
@ -81,33 +74,21 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
let speedMultiplier = activeEvents.get(UserInputEvent.SpeedUp) ? 500 : 100;
|
||||
|
||||
if (activeEvents.get(UserInputEvent.MoveUp)) {
|
||||
if (!this.CanMoveUp()) {
|
||||
return;
|
||||
}
|
||||
this.move(0, -speedMultiplier);
|
||||
haveMove = true;
|
||||
direction = PlayerAnimationNames.WalkUp;
|
||||
}
|
||||
if (activeEvents.get(UserInputEvent.MoveLeft)) {
|
||||
if (!this.CanMoveLeft()) {
|
||||
return;
|
||||
}
|
||||
this.move(-speedMultiplier, 0);
|
||||
haveMove = true;
|
||||
direction = PlayerAnimationNames.WalkLeft;
|
||||
}
|
||||
if (activeEvents.get(UserInputEvent.MoveDown)) {
|
||||
if (!this.CanMoveDown()) {
|
||||
return;
|
||||
}
|
||||
this.move(0, speedMultiplier);
|
||||
haveMove = true;
|
||||
direction = PlayerAnimationNames.WalkDown;
|
||||
}
|
||||
if (activeEvents.get(UserInputEvent.MoveRight)) {
|
||||
if (!this.CanMoveRight()) {
|
||||
return;
|
||||
}
|
||||
this.move(speedMultiplier, 0);
|
||||
haveMove = true;
|
||||
direction = PlayerAnimationNames.WalkRight;
|
||||
|
@ -120,33 +101,13 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
this.CameraManager.moveCamera(this);
|
||||
}
|
||||
|
||||
private sharePosition(direction : string){
|
||||
if(ConnexionInstance) {
|
||||
private sharePosition(direction: string) {
|
||||
if (ConnexionInstance) {
|
||||
ConnexionInstance.sharePosition((this.scene as GameSceneInterface).RoomId, this.x, this.y, direction);
|
||||
}
|
||||
}
|
||||
|
||||
private CanMoveUp(){
|
||||
return this.y > 0;
|
||||
}
|
||||
|
||||
private CanMoveLeft(){
|
||||
return this.x > 0;
|
||||
}
|
||||
|
||||
private CanMoveDown(){
|
||||
return this.MapManager.Map.heightInPixels > this.y;
|
||||
}
|
||||
|
||||
private CanMoveRight() {
|
||||
return this.MapManager.Map.widthInPixels > this.x;
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.setVelocity(0, 0)
|
||||
}
|
||||
|
||||
updatePosition(MessageUserPosition : MessageUserPositionInterface){
|
||||
updatePosition(MessageUserPosition: MessageUserPositionInterface) {
|
||||
playAnimation(this, MessageUserPosition.position.direction);
|
||||
this.setX(MessageUserPosition.position.x);
|
||||
this.setY(MessageUserPosition.position.y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue