Spaces:
Running
Running
ok
Browse files- index.html +2 -1
- src/ui/UIManager.js +16 -0
index.html
CHANGED
@@ -31,6 +31,7 @@
|
|
31 |
<div class="stat-label">Range</div><div class="stat-value" id="t_range">0</div>
|
32 |
<div class="stat-label">Fire Rate</div><div class="stat-value" id="t_rate">0</div>
|
33 |
<div class="stat-label">Damage</div><div class="stat-value" id="t_damage">0</div>
|
|
|
34 |
<div class="stat-label">Next Upgrade</div><div class="stat-value" id="t_nextCost">-</div>
|
35 |
</div>
|
36 |
<div class="u-flex u-gap-3">
|
@@ -50,4 +51,4 @@
|
|
50 |
</script>
|
51 |
<script type="module" src="src/main.js"></script>
|
52 |
</body>
|
53 |
-
</html>
|
|
|
31 |
<div class="stat-label">Range</div><div class="stat-value" id="t_range">0</div>
|
32 |
<div class="stat-label">Fire Rate</div><div class="stat-value" id="t_rate">0</div>
|
33 |
<div class="stat-label">Damage</div><div class="stat-value" id="t_damage">0</div>
|
34 |
+
<div class="stat-label" id="t_slow_label" style="display:none">Slow</div><div class="stat-value" id="t_slow" style="display:none">-</div>
|
35 |
<div class="stat-label">Next Upgrade</div><div class="stat-value" id="t_nextCost">-</div>
|
36 |
</div>
|
37 |
<div class="u-flex u-gap-3">
|
|
|
51 |
</script>
|
52 |
<script type="module" src="src/main.js"></script>
|
53 |
</body>
|
54 |
+
</html>
|
src/ui/UIManager.js
CHANGED
@@ -19,6 +19,9 @@ export class UIManager {
|
|
19 |
this.tRateEl = document.getElementById("t_rate");
|
20 |
this.tDamageEl = document.getElementById("t_damage");
|
21 |
this.tNextCostEl = document.getElementById("t_nextCost");
|
|
|
|
|
|
|
22 |
|
23 |
// Tower palette (floating)
|
24 |
this.palette = document.createElement("div");
|
@@ -193,6 +196,19 @@ export class UIManager {
|
|
193 |
this.tRateEl.textContent = tower.rate.toFixed(2);
|
194 |
this.tDamageEl.textContent = tower.damage.toFixed(2);
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
if (tower.canUpgrade) {
|
197 |
this.tNextCostEl.textContent = String(tower.nextUpgradeCost);
|
198 |
this.upgradeBtn.disabled = money < tower.nextUpgradeCost;
|
|
|
19 |
this.tRateEl = document.getElementById("t_rate");
|
20 |
this.tDamageEl = document.getElementById("t_damage");
|
21 |
this.tNextCostEl = document.getElementById("t_nextCost");
|
22 |
+
// Slow-specific UI (only visible for slow towers)
|
23 |
+
this.tSlowLabelEl = document.getElementById("t_slow_label");
|
24 |
+
this.tSlowEl = document.getElementById("t_slow");
|
25 |
|
26 |
// Tower palette (floating)
|
27 |
this.palette = document.createElement("div");
|
|
|
196 |
this.tRateEl.textContent = tower.rate.toFixed(2);
|
197 |
this.tDamageEl.textContent = tower.damage.toFixed(2);
|
198 |
|
199 |
+
// Show slow percentage for slow towers; hide for others
|
200 |
+
if (tower.type === "slow" && this.tSlowEl && this.tSlowLabelEl) {
|
201 |
+
const mult = tower.projectileEffect?.mult ?? 1.0;
|
202 |
+
// Convert to percentage slow (e.g., mult 0.75 => 25% slow)
|
203 |
+
const pct = Math.max(0, Math.min(100, Math.round((1 - mult) * 100)));
|
204 |
+
this.tSlowEl.textContent = `${pct}%`;
|
205 |
+
this.tSlowLabelEl.style.display = "";
|
206 |
+
this.tSlowEl.style.display = "";
|
207 |
+
} else if (this.tSlowEl && this.tSlowLabelEl) {
|
208 |
+
this.tSlowLabelEl.style.display = "none";
|
209 |
+
this.tSlowEl.style.display = "none";
|
210 |
+
}
|
211 |
+
|
212 |
if (tower.canUpgrade) {
|
213 |
this.tNextCostEl.textContent = String(tower.nextUpgradeCost);
|
214 |
this.upgradeBtn.disabled = money < tower.nextUpgradeCost;
|