added random companion to player
This commit is contained in:
parent
512c370f3f
commit
80a5d2e30e
4 changed files with 256 additions and 1 deletions
|
@ -2,7 +2,7 @@ import {PlayerAnimationDirections} from "./Animation";
|
|||
import {GameScene} from "../Game/GameScene";
|
||||
import {UserInputEvent, UserInputManager} from "../UserInput/UserInputManager";
|
||||
import {Character} from "../Entity/Character";
|
||||
|
||||
import {Companion} from "../Companion/Companion";
|
||||
|
||||
export const hasMovedEventName = "hasMoved";
|
||||
export interface CurrentGamerInterface extends Character{
|
||||
|
@ -13,6 +13,7 @@ export interface CurrentGamerInterface extends Character{
|
|||
export class Player extends Character implements CurrentGamerInterface {
|
||||
private previousDirection: string = PlayerAnimationDirections.Down;
|
||||
private wasMoving: boolean = false;
|
||||
private companion?: Companion;
|
||||
|
||||
constructor(
|
||||
Scene: GameScene,
|
||||
|
@ -28,6 +29,20 @@ export class Player extends Character implements CurrentGamerInterface {
|
|||
|
||||
//the current player model should be push away by other players to prevent conflict
|
||||
this.getBody().setImmovable(false);
|
||||
|
||||
this.addCompanion();
|
||||
}
|
||||
|
||||
addCompanion(): void {
|
||||
this.companion = new Companion(this.scene, this.x, this.y);
|
||||
}
|
||||
|
||||
move(x: number, y: number) {
|
||||
super.move(x, y);
|
||||
|
||||
if (this.companion) {
|
||||
this.companion.setTarget(this.x, this.y);
|
||||
}
|
||||
}
|
||||
|
||||
moveUser(delta: number): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue