implement mirv

This commit is contained in:
Evan
2025-02-04 11:53:41 -08:00
parent e750afcd65
commit b643a6357b
10 changed files with 278 additions and 50 deletions
+22 -1
View File
@@ -81,7 +81,7 @@ export class UnitLayer implements Layer {
this.canvas.width = this.game.width();
this.canvas.height = this.game.height();
for (const unit of this.game.units()) {
// this.onUnitEvent(new UnitEvent(unit, unit.tile()))
this.onUnitEvent(unit);
}
}
@@ -112,8 +112,12 @@ export class UnitLayer implements Layer {
case UnitType.TradeShip:
this.handleTradeShipEvent(unit);
break;
case UnitType.MIRVWarhead:
this.handleMIRVWarhead(unit);
break;
case UnitType.AtomBomb:
case UnitType.HydrogenBomb:
case UnitType.MIRV:
this.handleNuke(unit);
break;
}
@@ -228,6 +232,23 @@ export class UnitLayer implements Layer {
}
}
private handleMIRVWarhead(unit: UnitView) {
const rel = this.relationship(unit);
this.clearCell(this.game.x(unit.lastTile()), this.game.y(unit.lastTile()));
if (unit.isActive()) {
// Paint area
this.paintCell(
this.game.x(unit.tile()),
this.game.y(unit.tile()),
rel,
this.theme.borderColor(unit.owner().info()),
255
);
}
}
private handleTradeShipEvent(unit: UnitView) {
const rel = this.relationship(unit);
@@ -28,7 +28,7 @@ interface BuildItemDisplay {
const buildTable: BuildItemDisplay[][] = [
[
{ unitType: UnitType.AtomBomb, icon: atomBombIcon },
{ unitType: UnitType.HydrogenBomb, icon: hydrogenBombIcon },
{ unitType: UnitType.MIRV, icon: hydrogenBombIcon },
{ unitType: UnitType.Warship, icon: warshipIcon },
{ unitType: UnitType.Port, icon: portIcon },
{ unitType: UnitType.MissileSilo, icon: missileSiloIcon },