nukes spawn from missile silos

This commit is contained in:
Evan
2024-11-16 13:48:33 -08:00
parent e26230275b
commit 05a3bed093
10 changed files with 81 additions and 22 deletions
+14
View File
@@ -80,6 +80,8 @@ export class UnitLayer implements Layer {
break;
case UnitType.TradeShip:
this.handleTradeShipEvent(event)
case UnitType.Nuke:
this.handleNuke(event)
}
}
@@ -93,6 +95,17 @@ export class UnitLayer implements Layer {
.forEach(t => this.paintCell(t.cell(), this.theme.territoryColor(event.unit.owner().info()), 180));
}
private handleNuke(event: UnitEvent) {
bfs(event.oldTile, euclDist(event.oldTile, 2)).forEach(t => {
this.clearCell(t.cell());
});
if (event.unit.isActive()) {
bfs(event.unit.tile(), euclDist(event.unit.tile(), 2))
.forEach(t => this.paintCell(t.cell(), this.theme.borderColor(event.unit.owner().info()), 255));
}
}
private handleTradeShipEvent(event: UnitEvent) {
bfs(event.oldTile, euclDist(event.oldTile, 1)).forEach(t => {
this.clearCell(t.cell());
@@ -130,6 +143,7 @@ export class UnitLayer implements Layer {
}
}
paintCell(cell: Cell, color: Colord, alpha: number) {
const index = (cell.y * this.game.width()) + cell.x;
const offset = index * 4;