```git commit message

Add tower range visualization with rotating line indicator and improve tile validation logic

- Enhanced tower selection interface by adding a rotating green line that visualizes the tower's range
- Updated range circle color from #c0b15c to #c009900 for better visibility
- Modified tile validation logic to properly handle multiple child object types (Rectangle, Arc, Line) when checking placement validity
- Improved code readability by using Array.includes() instead of multiple !== comparisons
```
This commit is contained in:
Brian Fertig 2025-09-04 16:05:10 -06:00
parent 2c37e407cd
commit 706d5b2cde
1 changed files with 15 additions and 4 deletions

View File

@ -365,11 +365,23 @@ export class InterfaceManager {
const towerInteractive = this.scene.add.rectangle(0, 0, 200, 200, 0x000000, 0); const towerInteractive = this.scene.add.rectangle(0, 0, 200, 200, 0x000000, 0);
this.selectedTower.add(towerInteractive); this.selectedTower.add(towerInteractive);
const rangeCircle = this.scene.add.circle(0, 0, TOWERS_CONFIG[type].level1.range, 0xc0b15c, 0.2) const rangeCircle = this.scene.add.circle(0, 0, TOWERS_CONFIG[type].level1.range, 0xc009900, 0.2)
.setOrigin(0.5) .setOrigin(0.5)
.setScrollFactor(0); .setScrollFactor(0);
this.selectedTower.add(rangeCircle); this.selectedTower.add(rangeCircle);
const centerToEdgeLine = this.scene.add.line(0, 0, 0, 0, TOWERS_CONFIG[type].level1.range, 0, 0x00ff00)
.setOrigin(0)
.setDepth(6);
this.selectedTower.add(centerToEdgeLine);
this.scene.tweens.add({
targets: centerToEdgeLine,
angle: 360,
duration: 8000,
repeat: -1
});
const towerBase = this.scene.add.sprite(0, 0, 'towers', 7) const towerBase = this.scene.add.sprite(0, 0, 'towers', 7)
.setOrigin(0.5) .setOrigin(0.5)
.setScrollFactor(0) .setScrollFactor(0)
@ -445,15 +457,14 @@ export class InterfaceManager {
const tile = platformsLayer.getTileAt(tileX, tileY); const tile = platformsLayer.getTileAt(tileX, tileY);
if (tile) { if (tile) {
this.selectedTower.iterate((child) => { this.selectedTower.iterate((child) => {
if (child.type !== 'Rectangle' && child.type !== 'Arc') { if (!['Rectangle', 'Arc', 'Line'].includes(child.type)) {
child.setTint(0x48ff00); child.setTint(0x48ff00);
} }
}); });
this.selectedTower.safe = true; this.selectedTower.safe = true;
} else { } else {
this.selectedTower.iterate((child) => { this.selectedTower.iterate((child) => {
if (child.type !== 'Rectangle' && child.type !== 'Arc') { if (!['Rectangle', 'Arc', 'Line'].includes(child.type)) {
console.log(child.type);
child.setTint(0xa32a00); child.setTint(0xa32a00);
} }
}); });