added isActivatable() method to implement through interface
This commit is contained in:
parent
2322f5f76d
commit
989897cb01
8 changed files with 32 additions and 247 deletions
|
@ -37,6 +37,7 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||
protected lastDirection: PlayerAnimationDirections = PlayerAnimationDirections.Down;
|
||||
//private teleportation: Sprite;
|
||||
private invisible: boolean;
|
||||
private clickable: boolean;
|
||||
public companion?: Companion;
|
||||
private emote: Phaser.GameObjects.DOMElement | null = null;
|
||||
private emoteTween: Phaser.Tweens.Tween | null = null;
|
||||
|
@ -62,6 +63,7 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||
this.scene = scene;
|
||||
this.playerName = name;
|
||||
this.invisible = true;
|
||||
this.clickable = false;
|
||||
|
||||
this.sprites = new Map<string, Sprite>();
|
||||
this._pictureStore = writable(undefined);
|
||||
|
@ -98,13 +100,7 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||
this.playerNameText.setOrigin(0.5).setDepth(DEPTH_INGAME_TEXT_INDEX);
|
||||
this.add(this.playerNameText);
|
||||
|
||||
if (isClickable) {
|
||||
this.setInteractive({
|
||||
hitArea: new Phaser.Geom.Circle(0, 0, interactiveRadius),
|
||||
hitAreaCallback: Phaser.Geom.Circle.Contains, //eslint-disable-line @typescript-eslint/unbound-method
|
||||
useHandCursor: true,
|
||||
});
|
||||
}
|
||||
this.setClickable(isClickable);
|
||||
|
||||
this.outlineColorStoreUnsubscribe = this.outlineColorStore.subscribe((color) => {
|
||||
if (color === undefined) {
|
||||
|
@ -135,6 +131,10 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||
}
|
||||
|
||||
public setClickable(clickable: boolean = true): void {
|
||||
if (this.clickable === clickable) {
|
||||
return;
|
||||
}
|
||||
this.clickable = clickable;
|
||||
if (clickable) {
|
||||
this.setInteractive({
|
||||
hitArea: new Phaser.Geom.Circle(0, 0, interactiveRadius),
|
||||
|
@ -146,6 +146,10 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||
this.disableInteractive();
|
||||
}
|
||||
|
||||
public isClickable() {
|
||||
return this.clickable;
|
||||
}
|
||||
|
||||
public getPosition(): { x: number, y: number } {
|
||||
return { x: this.x, y: this.y };
|
||||
}
|
||||
|
|
|
@ -61,6 +61,13 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||
});
|
||||
|
||||
this.bindEventHandlers();
|
||||
|
||||
this.registerActionsMenuAction({
|
||||
actionName: "ddd",
|
||||
callback: () => {
|
||||
console.log('ddd');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public updatePosition(position: PointInterface): void {
|
||||
|
@ -98,6 +105,10 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||
super.destroy();
|
||||
}
|
||||
|
||||
public isActivatable(): boolean {
|
||||
return this.isClickable();
|
||||
}
|
||||
|
||||
private updateIsClickable(): void {
|
||||
this.setClickable(this.registeredActions.length > 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue