Boat attack event (#177)

Allow user to focus on outgoing boats

Partial #133 


https://github.com/user-attachments/assets/0e287bf5-71bb-4def-a3ca-f0b652ed6d69
This commit is contained in:
Maeght Loan
2025-03-08 19:44:27 +01:00
committed by GitHub
parent afe4f85919
commit e1ed8dbe36
3 changed files with 61 additions and 8 deletions
+11 -1
View File
@@ -6,7 +6,7 @@ import {
calculateBoundingBoxCenter,
} from "../../core/Util";
import { ZoomEvent, DragEvent, CenterCameraEvent } from "../InputHandler";
import { GoToPlayerEvent } from "./layers/Leaderboard";
import { GoToPlayerEvent, GoToUnitEvent } from "./layers/Leaderboard";
import { placeName } from "./NameBoxCalculator";
import { GameView } from "../../core/game/GameView";
@@ -27,6 +27,7 @@ export class TransformHandler {
this.eventBus.on(ZoomEvent, (e) => this.onZoom(e));
this.eventBus.on(DragEvent, (e) => this.onMove(e));
this.eventBus.on(GoToPlayerEvent, (e) => this.onGoToPlayer(e));
this.eventBus.on(GoToUnitEvent, (e) => this.onGoToUnit(e));
this.eventBus.on(CenterCameraEvent, () => this.centerCamera());
}
@@ -149,6 +150,15 @@ export class TransformHandler {
this.intervalID = setInterval(() => this.goTo(), 1);
}
onGoToUnit(event: GoToUnitEvent) {
this.clearTarget();
this.target = new Cell(
this.game.x(event.unit.lastTile()),
this.game.y(event.unit.lastTile()),
);
this.intervalID = setInterval(() => this.goTo(), 1);
}
centerCamera() {
this.clearTarget();
const player = this.game.myPlayer();