Added fortify icon to units
This commit is contained in:
parent
65a6ee12ad
commit
00f6dd6e19
|
|
@ -668,6 +668,37 @@ export class CivilizationMapView {
|
|||
}).setOrigin(0.5);
|
||||
container.add([badge, num]);
|
||||
}
|
||||
// Fortification icon: shown when fortified on open ground (not in a city
|
||||
// or fortress, which give their own defensive bonuses). Drawn at the
|
||||
// unit's feet rather than shoulder height so it reads as ground defence.
|
||||
if (unit.fortified) {
|
||||
const hereCity = cityAt(this.state, c, r);
|
||||
const idx = tileIndex(this.state.world, c, r);
|
||||
const hasFortress = !!(this.state.world.improvements[idx] & IMP.FORTRESS);
|
||||
if (!hereCity && !hasFortress) {
|
||||
const iconY = spriteMode ? 0 : 12;
|
||||
const impSheet = scene.textures.exists('civilization-improvements');
|
||||
if (impSheet) {
|
||||
container.add(scene.add.image(0, iconY, 'civilization-improvements', 5).setScale(0.6));
|
||||
} else {
|
||||
// Procedural shield icon fallback.
|
||||
const sg = scene.add.graphics();
|
||||
sg.fillStyle(0x888888, 1);
|
||||
sg.beginPath();
|
||||
sg.moveTo(0, iconY - 7);
|
||||
sg.lineTo(6, iconY - 5);
|
||||
sg.lineTo(6, iconY + 1);
|
||||
sg.quadraticCurveTo(6, iconY + 7, 0, iconY + 8);
|
||||
sg.quadraticCurveTo(-6, iconY + 7, -6, iconY + 1);
|
||||
sg.lineTo(-6, iconY - 5);
|
||||
sg.closePath();
|
||||
sg.fillPath();
|
||||
sg.lineStyle(1, 0x000000, 0.6);
|
||||
sg.strokePath();
|
||||
container.add(sg);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only the currently-selected unit is clickable — clicking any other
|
||||
// unit's tile still goes through the normal tile-click select/move flow
|
||||
// in CivilizationGame (see bindPointer/onTileClick). Every unit is still
|
||||
|
|
|
|||
Loading…
Reference in New Issue