tab once selects builder, tab twice focuses builder

This commit is contained in:
Ian Woods 2026-07-16 20:49:13 -07:00
parent 826d7b5037
commit fe2c59d326
6 changed files with 28 additions and 6 deletions

View file

@ -1,5 +1,5 @@
// Assets/_Project/Scripts/Audio/AudioCategory.cs
namespace TD.Audio
{
public enum AudioCategory { TowerFire, EnemyHitDeath, UI }
public enum AudioCategory { Combat, EnemyHitDeath, UI }
}

View file

@ -38,7 +38,7 @@ namespace TD.Combat
private void HandleAreaFired(Vector3[] positions)
{
AudioManager.Instance?.Play(fireSound.clip, AudioCategory.TowerFire, fireSound.RandomPitch(), fireSound.volume);
AudioManager.Instance?.Play(fireSound.clip, AudioCategory.Combat, fireSound.RandomPitch(), fireSound.volume);
}
}
}

View file

@ -156,7 +156,22 @@ namespace TD.Gameplay
{
HUDController.Instance?.ToggleBuffMenu();
}
// Tab: select the builder, or (if already selected) recenter the camera on it.
if (keyboard != null && keyboard.tabKey.wasPressedThisFrame
&& !HUDController.IsTextInputActive)
{
var selection = SelectionState.Instance;
if (selection != null && selection.IsSelected(builder))
{
HUDController.Instance?.CenterCameraOnSelection();
}
else
{
selection?.Select(builder);
}
}
if (pointerOverHud) return;
if (!mouse.rightButton.wasPressedThisFrame) return;

View file

@ -65,7 +65,7 @@ namespace TD.Gameplay.BuilderSpells
Destroy(Instantiate(impactVfxPrefab, targetPoint, Quaternion.identity), impactVfxLifetime);
if (impactSound.clip != null)
AudioManager.Instance?.Play(impactSound.clip, AudioCategory.TowerFire,
AudioManager.Instance?.Play(impactSound.clip, AudioCategory.Combat,
impactSound.RandomPitch(), impactSound.volume);
}
}

View file

@ -1642,7 +1642,14 @@ namespace TD.UI
// WC3 / SC2 convention: clicking the portrait recenters the camera on
// whoever is selected. Zoom is preserved (CameraController.JumpTo only
// moves the pivot). No-op when nothing is selected or the camera isn't wired.
private void OnPortraitClicked(ClickEvent evt)
private void OnPortraitClicked(ClickEvent evt) => CenterCameraOnSelection();
/// <summary>
/// Recenters the camera on the current selection (same behavior as clicking the
/// portrait). No-op when nothing is selected or the camera isn't wired. Also used
/// by the Tab hotkey (select-builder-then-focus) in BuilderInputController.
/// </summary>
public void CenterCameraOnSelection()
{
var sel = SelectionState.Instance?.SelectedObject;
if (sel == null) return;