Merge branch 'walking-shortest-path' into feature-move-character-api

This commit is contained in:
Hanusiak Piotr 2022-01-19 10:54:19 +01:00
commit f96eac4737
6 changed files with 34 additions and 9571 deletions

1
front/.gitignore vendored
View File

@ -6,6 +6,7 @@
/dist/main.*.css.map
/dist/tests/
/yarn-error.log
/package-lock.json
/dist/webpack.config.js
/dist/webpack.config.js.map
/dist/src

9550
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,5 +7,6 @@ export interface UserInputHandlerInterface {
deltaZ: number
) => void;
handlePointerUpEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => void;
handlePointerDownEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => void;
handleSpaceKeyUpEvent: (event: Event) => Event;
}

View File

@ -40,30 +40,22 @@ export class MobileJoystick extends VirtualJoystick {
this.visible = false;
this.enable = false;
this.scene.input.on("pointerdown", (pointer: Phaser.Input.Pointer) => {
if (!pointer.wasTouch) {
return;
}
// Let's only display the joystick if there is one finger on the screen
if ((pointer.event as TouchEvent).touches.length === 1) {
this.x = pointer.x;
this.y = pointer.y;
this.visible = true;
this.enable = true;
} else {
this.visible = false;
this.enable = false;
}
});
this.scene.input.on("pointerup", () => {
this.visible = false;
this.enable = false;
});
this.resizeCallback = this.resize.bind(this);
this.scene.scale.on(Phaser.Scale.Events.RESIZE, this.resizeCallback);
}
public showAt(x: number, y: number): void {
this.x = x;
this.y = y;
this.visible = true;
this.enable = true;
}
public hide(): void {
this.visible = false;
this.enable = false;
}
public resize() {
this.base.setDisplaySize(this.getDisplaySizeByElement(baseSize), this.getDisplaySizeByElement(baseSize));
this.thumb.setDisplaySize(this.getDisplaySizeByElement(thumbSize), this.getDisplaySizeByElement(thumbSize));

View File

@ -19,7 +19,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
}
public handlePointerUpEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {
if (pointer.rightButtonReleased()) {
if (pointer.rightButtonReleased() || pointer.getDuration() > 250) {
return;
}
const camera = this.gameScene.getCameraManager().getCamera();
@ -49,6 +49,8 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
});
}
public handlePointerDownEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {}
public handleSpaceKeyUpEvent(event: Event): Event {
this.gameScene.activateOutlinedItem();
return event;

View File

@ -253,10 +253,27 @@ export class UserInputManager {
this.scene.input.on(
Phaser.Input.Events.POINTER_UP,
(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => {
this.joystick.hide();
this.userInputHandler.handlePointerUpEvent(pointer, gameObjects);
}
);
this.scene.input.on(
Phaser.Input.Events.POINTER_DOWN,
(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => {
if (!pointer.wasTouch) {
return;
}
this.userInputHandler.handlePointerDownEvent(pointer, gameObjects);
// Let's only display the joystick if there is one finger on the screen
if ((pointer.event as TouchEvent).touches.length === 1) {
this.joystick.showAt(pointer.x, pointer.y);
} else {
this.joystick.hide();
}
}
);
this.scene.input.keyboard.on("keyup-SPACE", (event: Event) => {
this.userInputHandler.handleSpaceKeyUpEvent(event);
});