remove deprecated buff system
This commit is contained in:
parent
35ea90f71b
commit
330a929985
22 changed files with 11 additions and 615 deletions
|
|
@ -101,10 +101,6 @@ namespace TD.UI
|
|||
|
||||
// Match-end overlay — built once on Start and toggled on Phase changes.
|
||||
private VisualElement matchEndOverlay;
|
||||
|
||||
// Buff menu overlay — toggled by the B key via ToggleBuffMenu().
|
||||
private VisualElement buffMenuOverlay;
|
||||
private VisualElement buffMenuContent;
|
||||
private Label matchEndTitle;
|
||||
|
||||
// Draft overlay (roguelike between-waves draft). Non-modal: the card row floats at
|
||||
|
|
@ -698,9 +694,6 @@ namespace TD.UI
|
|||
// MatchState.OnPhaseChanged fires Victory or Defeat.
|
||||
BuildMatchEndOverlay(root);
|
||||
|
||||
// Build the buff menu overlay. Hidden until the player presses B.
|
||||
BuildBuffMenuOverlay(root);
|
||||
|
||||
// Build the draft overlay (roguelike between-waves draft). Hidden until the
|
||||
// local player has an active draft (or to show the paid "Buy Roll" button).
|
||||
BuildDraftOverlay(root);
|
||||
|
|
@ -1173,13 +1166,11 @@ namespace TD.UI
|
|||
{
|
||||
// Build buttons come from the LOCAL player's deck — the per-player
|
||||
// unlocked set — not the global catalog. Each deck entry is a
|
||||
// TowerTypeId resolved back to its definition via the catalog. The
|
||||
// last grid slot is reserved for the Buffs button, so towers fill
|
||||
// slots 0..GRID_MAX-2.
|
||||
// TowerTypeId resolved back to its definition via the catalog.
|
||||
var deck = PlayerTowerDeck.Local;
|
||||
if (deck != null)
|
||||
{
|
||||
int count = Mathf.Min(deck.Count, GRID_MAX - 1);
|
||||
int count = Mathf.Min(deck.Count, GRID_MAX);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int typeId = deck.GetTypeIdAt(i);
|
||||
|
|
@ -1189,7 +1180,6 @@ namespace TD.UI
|
|||
}
|
||||
}
|
||||
}
|
||||
cells[GRID_MAX - 1] = CreateBuffMenuButton(HotkeyLayout[GRID_MAX - 1]);
|
||||
}
|
||||
else if (selection is TowerInstance tower)
|
||||
{
|
||||
|
|
@ -1374,9 +1364,7 @@ namespace TD.UI
|
|||
|
||||
// Sell action for a completed tower. Refund is computed on the TowerInstance (single
|
||||
// source of truth shared with the server) so the badge shows exactly what the player
|
||||
// gets back. Hotkey is Key.None: the bottom-right slot's letter (B) is already the
|
||||
// global buff-menu toggle — see CreateBuffMenuButton — so binding it here would fire
|
||||
// both. The button stays click-only.
|
||||
// gets back. The button stays click-only (Key.None).
|
||||
private VisualElement CreateSellButton(TowerInstance tower, Key hotkey)
|
||||
{
|
||||
// Only the tower's owner can sell it (the server enforces this too). A non-owner
|
||||
|
|
@ -1399,17 +1387,6 @@ namespace TD.UI
|
|||
return btn;
|
||||
}
|
||||
|
||||
private VisualElement CreateBuffMenuButton(Key hotkey)
|
||||
{
|
||||
// Key.None so HandleHotkeys doesn't register B here — BuilderInputController
|
||||
// already fires ToggleBuffMenu on B globally. Registering it in both places
|
||||
// causes a double-toggle on the same frame when the builder is selected.
|
||||
return CreateActionButton(
|
||||
costText: "Buffs [B]",
|
||||
hotkey: Key.None,
|
||||
onClick: () => ToggleBuffMenu());
|
||||
}
|
||||
|
||||
// Cancel action for an in-progress build. Fires the owner-only RPC; the
|
||||
// server cancels the matching job (or, for shelved sites, refunds + despawns
|
||||
// directly), full gold is refunded, the BuildSiteVisual is despawned, and
|
||||
|
|
@ -1712,149 +1689,6 @@ namespace TD.UI
|
|||
|
||||
// ----- Chat feed + input -----------------------------------------
|
||||
|
||||
// ----- Buff menu overlay ------------------------------------------
|
||||
|
||||
private void BuildBuffMenuOverlay(VisualElement root)
|
||||
{
|
||||
buffMenuOverlay = new VisualElement();
|
||||
buffMenuOverlay.style.position = Position.Absolute;
|
||||
buffMenuOverlay.style.left = 0;
|
||||
buffMenuOverlay.style.right = 0;
|
||||
buffMenuOverlay.style.top = 0;
|
||||
buffMenuOverlay.style.bottom = 0;
|
||||
buffMenuOverlay.style.alignItems = Align.Center;
|
||||
buffMenuOverlay.style.justifyContent = Justify.Center;
|
||||
buffMenuOverlay.style.backgroundColor = new Color(0f, 0f, 0f, 0.5f);
|
||||
buffMenuOverlay.style.display = DisplayStyle.None;
|
||||
buffMenuOverlay.pickingMode = PickingMode.Position;
|
||||
|
||||
var panel = new VisualElement();
|
||||
panel.style.minWidth = 340;
|
||||
panel.style.paddingTop = 20;
|
||||
panel.style.paddingBottom = 20;
|
||||
panel.style.paddingLeft = 28;
|
||||
panel.style.paddingRight = 28;
|
||||
panel.style.backgroundColor = new Color(0.08f, 0.08f, 0.10f, 0.95f);
|
||||
panel.style.borderTopWidth = panel.style.borderBottomWidth =
|
||||
panel.style.borderLeftWidth = panel.style.borderRightWidth = 2;
|
||||
var border = new Color(0.4f, 0.4f, 0.45f);
|
||||
panel.style.borderTopColor = panel.style.borderBottomColor =
|
||||
panel.style.borderLeftColor = panel.style.borderRightColor = border;
|
||||
|
||||
var title = new Label("Buffs");
|
||||
title.style.fontSize = 24;
|
||||
title.style.color = Color.white;
|
||||
title.style.unityFontStyleAndWeight = FontStyle.Bold;
|
||||
title.style.marginBottom = 12;
|
||||
panel.Add(title);
|
||||
|
||||
// Scrollable content area: current buffs + purchase buttons.
|
||||
// Rebuilt each time the menu is shown via RefreshBuffMenuContent().
|
||||
buffMenuContent = new VisualElement();
|
||||
panel.Add(buffMenuContent);
|
||||
|
||||
var closeBtn = new Button(() => SetBuffMenuVisible(false)) { text = "Close [B]" };
|
||||
closeBtn.style.marginTop = 16;
|
||||
closeBtn.style.height = 32;
|
||||
panel.Add(closeBtn);
|
||||
|
||||
buffMenuOverlay.Add(panel);
|
||||
root.Add(buffMenuOverlay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the buff menu overlay. Called by <see cref="TD.Gameplay.BuilderInputController"/>
|
||||
/// when the player presses B.
|
||||
/// </summary>
|
||||
public void ToggleBuffMenu()
|
||||
{
|
||||
bool nowVisible = buffMenuOverlay?.style.display == DisplayStyle.None;
|
||||
SetBuffMenuVisible(nowVisible);
|
||||
}
|
||||
|
||||
private void SetBuffMenuVisible(bool visible)
|
||||
{
|
||||
if (buffMenuOverlay == null) return;
|
||||
buffMenuOverlay.style.display = visible ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
if (visible) RefreshBuffMenuContent();
|
||||
}
|
||||
|
||||
private void RefreshBuffMenuContent()
|
||||
{
|
||||
if (buffMenuContent == null) return;
|
||||
buffMenuContent.Clear();
|
||||
|
||||
var buffManager = TD.Gameplay.PlayerBuffManager.Local;
|
||||
|
||||
// Current buffs section.
|
||||
var buffsHeader = new Label("Active Buffs");
|
||||
buffsHeader.style.color = new Color(0.7f, 0.9f, 0.7f);
|
||||
buffsHeader.style.fontSize = 14;
|
||||
buffsHeader.style.marginBottom = 4;
|
||||
buffMenuContent.Add(buffsHeader);
|
||||
|
||||
if (buffManager == null || buffManager.Buffs.Count == 0)
|
||||
{
|
||||
var none = new Label("None");
|
||||
none.style.color = new Color(0.55f, 0.55f, 0.55f);
|
||||
none.style.marginBottom = 8;
|
||||
buffMenuContent.Add(none);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < buffManager.Buffs.Count; i++)
|
||||
{
|
||||
var buff = buffManager.Buffs[i];
|
||||
string statName = buff.Stat == TD.Core.BuffStat.Damage ? "Damage" : "Attack Speed";
|
||||
string activeTag = buff.IsActive ? "" : " [DISABLED]";
|
||||
var row = new Label($"• {buff.DisplayName} ({statName} ×{buff.Multiplier:F2}){activeTag}");
|
||||
row.style.color = buff.IsActive ? Color.white : new Color(0.5f, 0.5f, 0.5f);
|
||||
row.style.fontSize = 13;
|
||||
buffMenuContent.Add(row);
|
||||
}
|
||||
buffMenuContent.style.marginBottom = 12;
|
||||
}
|
||||
|
||||
// Purchase buttons section.
|
||||
var buyHeader = new Label("Purchase");
|
||||
buyHeader.style.color = new Color(0.9f, 0.8f, 0.5f);
|
||||
buyHeader.style.fontSize = 14;
|
||||
buyHeader.style.marginTop = 8;
|
||||
buyHeader.style.marginBottom = 4;
|
||||
buffMenuContent.Add(buyHeader);
|
||||
|
||||
int categoryCount = buffManager?.CategoryCount ?? 0;
|
||||
if (categoryCount == 0)
|
||||
{
|
||||
var none = new Label("No categories available.");
|
||||
none.style.color = new Color(0.55f, 0.55f, 0.55f);
|
||||
buffMenuContent.Add(none);
|
||||
return;
|
||||
}
|
||||
|
||||
int localGold = TD.Gameplay.PlayerGoldManager.Local?.CurrentGold ?? 0;
|
||||
for (int i = 0; i < categoryCount; i++)
|
||||
{
|
||||
var category = buffManager.GetCategory(i);
|
||||
if (category == null) continue;
|
||||
|
||||
int idx = i; // capture for lambda
|
||||
var btn = new Button(() =>
|
||||
{
|
||||
TD.Gameplay.PlayerBuffManager.Local?.RequestPurchaseBuffRpc(idx);
|
||||
RefreshBuffMenuContent();
|
||||
})
|
||||
{
|
||||
text = $"{category.DisplayName} — {category.Cost}g"
|
||||
};
|
||||
btn.style.height = 34;
|
||||
btn.style.fontSize = 13;
|
||||
btn.style.marginBottom = 4;
|
||||
btn.SetEnabled(localGold >= category.Cost);
|
||||
buffMenuContent.Add(btn);
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom-left chat panel. Anchored 12px from the left edge, with the
|
||||
// bottom edge sitting above the 220px bottom-ui. Layout uses a flex
|
||||
// column: scrollable feed on top, input below. The feed clips at
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue