Name of map users
- Add name on user - Delete NonPlayer class not used
This commit is contained in:
parent
8355a89dc5
commit
b65e37c468
10 changed files with 46 additions and 65 deletions
|
@ -42,7 +42,11 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
|
|||
if(this.bubble) {
|
||||
this.bubble.moveBubble(this.x, this.y);
|
||||
}
|
||||
this.playerName.setPosition(this.x, this.y - 25);
|
||||
this.updatePlayerNamePosition(this.x, this.y);
|
||||
}
|
||||
|
||||
updatePlayerNamePosition(x: number, y: number){
|
||||
this.playerName.setPosition(x, y - 25);
|
||||
}
|
||||
|
||||
stop(){
|
||||
|
@ -59,4 +63,9 @@ export class PlayableCaracter extends Phaser.Physics.Arcade.Sprite {
|
|||
this.bubble = null;
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
destroy(fromScene?: boolean): void {
|
||||
super.destroy(fromScene);
|
||||
this.playerName.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ export class GameScene extends Phaser.Scene implements GameSceneInterface{
|
|||
this,
|
||||
MessageUserPosition.position.x,
|
||||
MessageUserPosition.position.y,
|
||||
'Foo'
|
||||
MessageUserPosition.name
|
||||
);
|
||||
player.initAnimation();
|
||||
this.MapPlayers.add(player);
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import {PlayableCaracter} from "../Entity/PlayableCaracter";
|
||||
import {Textures} from "../Game/GameScene";
|
||||
import {UserInputEvent} from "../UserInput/UserInputManager";
|
||||
import {Player} from "../Player/Player";
|
||||
import {MessageUserPositionInterface} from "../../Connexion";
|
||||
import {playAnimation} from "../Player/Animation";
|
||||
|
||||
export class NonPlayer extends PlayableCaracter {
|
||||
|
||||
isFleeing: boolean = false;
|
||||
fleeingDirection:any = null //todo create a vector class
|
||||
|
||||
constructor(scene: Phaser.Scene, x: number, y: number, name: string) {
|
||||
super(scene, x, y, Textures.Player, name, 1);
|
||||
this.setSize(32, 32); //edit the hitbox to better match the character model
|
||||
}
|
||||
|
||||
|
||||
updatePosition(MessageUserPosition : MessageUserPositionInterface){
|
||||
playAnimation(this, MessageUserPosition.position.direction);
|
||||
this.setX(MessageUserPosition.position.x);
|
||||
this.setY(MessageUserPosition.position.y);
|
||||
}
|
||||
|
||||
fleeFrom(player:Player) {
|
||||
if (this.isFleeing) return;
|
||||
this.say("Don't touch me!");
|
||||
this.isFleeing = true;
|
||||
|
||||
setTimeout(() => {
|
||||
this.say("Feww, I escaped.");
|
||||
this.isFleeing = false
|
||||
this.fleeingDirection = null
|
||||
}, 3000);
|
||||
|
||||
let vectorX = this.x - player.x;
|
||||
let vectorY = this.y - player.y;
|
||||
this.fleeingDirection = {x: vectorX, y: vectorY}
|
||||
}
|
||||
}
|
|
@ -100,5 +100,6 @@ export class Player extends PlayableCaracter implements CurrentGamerInterface, G
|
|||
playAnimation(this, MessageUserPosition.position.direction);
|
||||
this.setX(MessageUserPosition.position.x);
|
||||
this.setY(MessageUserPosition.position.y);
|
||||
this.updatePlayerNamePosition(MessageUserPosition.position.x, MessageUserPosition.position.y);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue