diff --git a/Assets/_Project/Scripts/Audio/README.md b/Assets/_Project/Scripts/Audio/README.md new file mode 100644 index 0000000..2f7d81c --- /dev/null +++ b/Assets/_Project/Scripts/Audio/README.md @@ -0,0 +1,36 @@ +# Audio System + +Centralised voice-limited audio for the game. Lives in `Assets/_Project/Scripts/Audio/`. + +## How it works + +`AudioManager` is a per-scene MonoBehaviour singleton. On `Awake` it pre-allocates a pool of `AudioSource` components (on its own GameObject) for each sound category. Callers request playback via `AudioManager.Instance.Play(clip, category, pitch)` — the manager picks the next source in that category's pool using round-robin, interrupting the oldest sound if all voices are busy. + +## Categories (`AudioCategory` enum) + +| Category | Typical use | +|---|---| +| `TowerFire` | Tower attack sounds | +| `EnemyHitDeath` | Enemy damage and death sounds | +| `UI` | Button clicks, placement confirmation, etc. | +| `Music` | Background music | + +Voice limits and volume per category are configured in the Inspector on the `AudioManager` scene GameObject. + +## Scene setup + +An empty GameObject named `AudioManager` must exist in each gameplay scene with the `AudioManager` component attached. Configure the `Categories` array in the Inspector — one entry per `AudioCategory` value. + +Suggested defaults: +- TowerFire: 4 voices, volume 1.0 +- EnemyHitDeath: 8 voices, volume 1.0 +- UI: 4 voices, volume 1.0 +- Music: 2 voices, volume 0.8 + +## Adding a new sound-emitting component + +1. Get a reference to an `AudioClip` via `[SerializeField]` +2. Call `AudioManager.Instance?.Play(clip, AudioCategory.YourCategory)` at the point the sound should trigger +3. Pitch randomization (if desired) is the caller's responsibility: `Random.Range(minPitch, maxPitch)` passed as the third argument + +See `TeslaTowerFireSound.cs` in `Scripts/Combat/` as a reference implementation. diff --git a/Assets/_Project/Scripts/Audio/README.md.meta b/Assets/_Project/Scripts/Audio/README.md.meta new file mode 100644 index 0000000..284147a --- /dev/null +++ b/Assets/_Project/Scripts/Audio/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4acf87ebbb79a6ce482e6e4767d27b41 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: