call activate() method on space key up
This commit is contained in:
parent
3af6461c01
commit
f42c7564b9
@ -1679,12 +1679,12 @@ ${escapedMessage}
|
|||||||
private handleCurrentPlayerHasMovedEvent(event: HasPlayerMovedEvent): void {
|
private handleCurrentPlayerHasMovedEvent(event: HasPlayerMovedEvent): void {
|
||||||
//listen event to share position of user
|
//listen event to share position of user
|
||||||
this.pushPlayerPosition(event);
|
this.pushPlayerPosition(event);
|
||||||
this.nearestActivatableObject = this.getNearestActivatableObject();
|
this.nearestActivatableObject = this.findNearestActivatableObject();
|
||||||
this.outlineItem(event);
|
this.outlineItem(event);
|
||||||
this.gameMap.setPosition(event.x, event.y);
|
this.gameMap.setPosition(event.x, event.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNearestActivatableObject(): ActivatableInterface | undefined {
|
private findNearestActivatableObject(): ActivatableInterface | undefined {
|
||||||
let shortestDistance: number = Infinity;
|
let shortestDistance: number = Infinity;
|
||||||
let closestObject: ActivatableInterface | undefined = undefined;
|
let closestObject: ActivatableInterface | undefined = undefined;
|
||||||
const currentPlayerPos = this.CurrentPlayer.getPosition();
|
const currentPlayerPos = this.CurrentPlayer.getPosition();
|
||||||
@ -2225,4 +2225,8 @@ ${escapedMessage}
|
|||||||
public getPathfindingManager(): PathfindingManager {
|
public getPathfindingManager(): PathfindingManager {
|
||||||
return this.pathfindingManager;
|
return this.pathfindingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNearestActivatableObject(): ActivatableInterface | undefined {
|
||||||
|
return this.nearestActivatableObject
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
|
|||||||
|
|
||||||
public handleSpaceKeyUpEvent(event: Event): Event {
|
public handleSpaceKeyUpEvent(event: Event): Event {
|
||||||
this.gameScene.activateOutlinedItem();
|
this.gameScene.activateOutlinedItem();
|
||||||
|
this.gameScene.getNearestActivatableObject()?.activate();
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user