add companion to remote player
This commit is contained in:
parent
80a5d2e30e
commit
5a91e15580
4 changed files with 46 additions and 37 deletions
|
@ -4,6 +4,7 @@ import BitmapText = Phaser.GameObjects.BitmapText;
|
|||
import Container = Phaser.GameObjects.Container;
|
||||
import Sprite = Phaser.GameObjects.Sprite;
|
||||
import {TextureError} from "../../Exception/TextureError";
|
||||
import {Companion} from "../Companion/Companion";
|
||||
|
||||
interface AnimationData {
|
||||
key: string;
|
||||
|
@ -21,6 +22,7 @@ export abstract class Character extends Container {
|
|||
private lastDirection: PlayerAnimationDirections = PlayerAnimationDirections.Down;
|
||||
//private teleportation: Sprite;
|
||||
private invisible: boolean;
|
||||
public companion?: Companion;
|
||||
|
||||
constructor(scene: Phaser.Scene,
|
||||
x: number,
|
||||
|
@ -67,6 +69,12 @@ export abstract class Character extends Container {
|
|||
this.setDepth(-1);
|
||||
|
||||
this.playAnimation(direction, moving);
|
||||
|
||||
this.addCompanion();
|
||||
}
|
||||
|
||||
private addCompanion(): void {
|
||||
this.companion = new Companion(this.scene, this.x, this.y);
|
||||
}
|
||||
|
||||
public addTextures(textures: string[], frame?: string | number): void {
|
||||
|
@ -189,6 +197,10 @@ export abstract class Character extends Container {
|
|||
}
|
||||
|
||||
this.setDepth(this.y);
|
||||
|
||||
if (this.companion) {
|
||||
this.companion.setTarget(this.x, this.y, this.lastDirection);
|
||||
}
|
||||
}
|
||||
|
||||
stop(){
|
||||
|
@ -215,5 +227,9 @@ export abstract class Character extends Container {
|
|||
}
|
||||
super.destroy();
|
||||
this.playerName.destroy();
|
||||
|
||||
if (this.companion) {
|
||||
this.companion.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,5 +31,9 @@ export class RemotePlayer extends Character {
|
|||
this.setY(position.y);
|
||||
|
||||
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).
|
||||
|
||||
if (this.companion) {
|
||||
this.companion.setTarget(position.x, position.y, position.direction as PlayerAnimationDirections);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue