Finish Phase 1.2 HUD: selection wiring, command grid context, build progress bar
- Builder.DisplayName: stub property ("Builder (P{n})") for portrait label; swaps
to real player name when MatchState lands in Phase 1.3
- HUDController: subscribe SelectionState.OnSelectionChanged in OnEnable/OnDisable;
HandleSelectionChanged drives portrait label + grays out command grid when nothing
is selected; Start() seeds initial state in case builder auto-selected before Start
- BuildSiteVisual: ComputeProgressNormalized() public API ([0,1], safe on any client);
OnNetworkSpawn spawns a non-networked BuildProgressBar child
- BuildProgressBar: new world-space uGUI Canvas bar; green while Constructing, yellow
while Paused, hidden while Queued; billboards to Camera.main each LateUpdate;
auto-destroyed when parent BuildSiteVisual despawns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6c37e569ab
commit
bc557af624
4 changed files with 135 additions and 0 deletions
|
|
@ -105,6 +105,8 @@ namespace TD.UI
|
|||
// Start() is safe because all OnEnable() calls have completed by then.
|
||||
InitializeUI();
|
||||
TryPopulateCommandGrid();
|
||||
// Seed portrait/grid state in case the builder already auto-selected before Start.
|
||||
HandleSelectionChanged(SelectionState.Instance?.SelectedBuilder);
|
||||
}
|
||||
|
||||
private void InitializeUI()
|
||||
|
|
@ -172,11 +174,15 @@ namespace TD.UI
|
|||
private void OnEnable()
|
||||
{
|
||||
TowerPlacementController.OnRejectionMessageReady += ShowRejectionMessage;
|
||||
if (SelectionState.Instance != null)
|
||||
SelectionState.Instance.OnSelectionChanged += HandleSelectionChanged;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
TowerPlacementController.OnRejectionMessageReady -= ShowRejectionMessage;
|
||||
if (SelectionState.Instance != null)
|
||||
SelectionState.Instance.OnSelectionChanged -= HandleSelectionChanged;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
|
@ -304,6 +310,13 @@ namespace TD.UI
|
|||
portraitName.text = string.IsNullOrEmpty(unitName) ? "" : unitName;
|
||||
}
|
||||
|
||||
private void HandleSelectionChanged(Builder builder)
|
||||
{
|
||||
SetSelectedUnitName(builder != null ? builder.DisplayName : null);
|
||||
if (commandGrid != null)
|
||||
commandGrid.SetEnabled(builder != null);
|
||||
}
|
||||
|
||||
// ----- Tooltip ----------------------------------------------------
|
||||
|
||||
private void ShowTooltip(TowerDefinition def)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue