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

@ -2253,7 +2253,7 @@ MonoBehaviour:
m_EditorClassIdentifier: Assembly-CSharp::TD.Audio.AudioManager m_EditorClassIdentifier: Assembly-CSharp::TD.Audio.AudioManager
categories: categories:
- category: 0 - category: 0
maxVoices: 4 maxVoices: 6
volume: 0.5 volume: 0.5
- category: 1 - category: 1
maxVoices: 4 maxVoices: 4

View file

@ -1,5 +1,5 @@
// Assets/_Project/Scripts/Audio/AudioCategory.cs // Assets/_Project/Scripts/Audio/AudioCategory.cs
namespace TD.Audio 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) 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

@ -157,6 +157,21 @@ namespace TD.Gameplay
HUDController.Instance?.ToggleBuffMenu(); 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 (pointerOverHud) return;
if (!mouse.rightButton.wasPressedThisFrame) return; if (!mouse.rightButton.wasPressedThisFrame) return;

View file

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

View file

@ -1642,7 +1642,14 @@ namespace TD.UI
// WC3 / SC2 convention: clicking the portrait recenters the camera on // WC3 / SC2 convention: clicking the portrait recenters the camera on
// whoever is selected. Zoom is preserved (CameraController.JumpTo only // whoever is selected. Zoom is preserved (CameraController.JumpTo only
// moves the pivot). No-op when nothing is selected or the camera isn't wired. // 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; var sel = SelectionState.Instance?.SelectedObject;
if (sel == null) return; if (sel == null) return;