added dialogue manager and radar

This commit is contained in:
2026-02-18 13:53:02 +00:00
parent e1df65bce2
commit 23362e7bdd
11 changed files with 915 additions and 3 deletions

View File

@@ -38,6 +38,10 @@ Pickups are standalone GameObjects placed anywhere in the scene — **not** chil
| `WeaponManager` | Player | Instantiates weapon prefabs, handles slot switching |
| `BootsEffect` | Player | Watches inventory for Bunny Hop Boots equipped state, applies stamina boost |
| `StaminaBoostPickup` | Pickup GameObjects | Legacy — superseded by BootsEffect. Left in for reference. |
| `RadarHUD` | Player | Mini-map radar disc (IMGUI), top-left corner — shows enemies, NPCs, pickups |
| `DialogueLine` | (data class) | Serializable speaker + pages of text, populated in Inspector on DialogueNPC |
| `DialogueNPC` | Any interactable object | World prompt + E-to-talk trigger, references DialogueLine array |
| `DialogueManager` | Any persistent GameObject | Singleton — renders the dialogue box, handles input and cursor lock |
---
@@ -259,7 +263,71 @@ Each weapon prefab gets its own values, so Gun Splat can sit differently from an
---
## 9. Equippable Items — `BootsEffect`
## 9. Radar HUD — `RadarHUD`
Attach to the **Player** alongside `PlayerHUD`. Draws a circular mini-map in the top-left corner. Rotates so "up" always faces the player's forward direction.
**Blip legend:**
| Blip | Colour | Shape | Source component |
|---|---|---|---|
| Player | White | Round | (always centre) |
| Enemy | Red (pulsing) | Round | `HumanoidEnemy` |
| NPC | Green | Round | `DialogueNPC` |
| Pickup | Yellow | Square | `PickupItem` |
Points beyond `worldRange` are clamped to the disc edge so off-screen threats always show a direction.
**Key Inspector fields:**
| Field | Notes |
|---|---|
| `radarRadius` | Visual size of the disc in pixels (default 60) |
| `worldRange` | World-space units covered (default 40) |
| `scanInterval` | How often the scene is re-scanned for objects (default 0.25s) |
No tags or layers required — blips are found by component type.
---
## 10. Dialogue — `DialogueNPC` + `DialogueManager`
### Setup
1. Add `DialogueManager` to any persistent GameObject in the scene (e.g. a "Managers" empty). One instance required per scene.
2. Add `DialogueNPC` to any world object you want to be talkable.
3. In the Inspector on `DialogueNPC`, expand the `Lines` array and fill in speaker names and pages.
### `DialogueNPC` Inspector fields
| Field | Notes |
|---|---|
| `lines[]` | Array of `DialogueLine` entries — each has a speaker name + pages of text |
| `interactRange` | Max distance for the E prompt to appear (default 3.5 units) |
| `interactAngle` | Max degrees off-centre the player can be looking (default 45°) |
| `occlusionMask` | Layer mask for the line-of-sight raycast |
| `promptText` | Label shown in the world-space prompt bubble (default `[E] Talk`) |
### Dialogue box controls
| Key | Action |
|---|---|
| E / Space / Enter | Advance page (or skip typewriter) |
| Escape | Close immediately |
### `DialogueManager` Inspector fields
| Field | Notes |
|---|---|
| `useTypewriter` | Enable/disable letter-by-letter reveal (default on) |
| `charsPerSecond` | Typewriter speed (default 40) |
| `boxHeightFraction` | Box height as fraction of screen height (default 0.22) |
Rich text tags (`<b>`, `<i>`, `<color=red>`) work inside page text — good for glitchy/stylised dialogue.
While the dialogue box is open, mouse look and movement are frozen and the cursor is unlocked automatically.
### NPCs on the radar
Any GameObject with a `DialogueNPC` component automatically appears as a **green dot** on the `RadarHUD`. No extra tagging needed.
---
## 11. Equippable Items — `BootsEffect`
**Add `BootsEffect` to the Player** for the Bunny Hop Boots to work.
@@ -332,6 +400,7 @@ if (inv.HasItem("Medkit")) {
- **Starting gun** — any `SimpleGun` that's a child of the Camera at Start gets auto-registered but starts inactive. Player needs to find it as a pickup in the scene.
- **Inventory is IMGUI** — not Canvas. Performance fine at this scale. All data logic is decoupled from drawing so a Canvas swap later would be straightforward.
- **`SimpleGun` assumes it's always active** — non-SimpleGun weapons will slot-switch fine but need their own input handling to shoot.
- **Dialogue LOS raycast** — uses `occlusionMask` defaulting to `~0` (all layers). If geometry is blocking the prompt unexpectedly, trim the mask on the `DialogueNPC` component.
---
@@ -345,7 +414,7 @@ if (inv.HasItem("Medkit")) {
| Left Click | Shoot |
| Right Click | Context menu (inventory open) |
| R | Reload |
| E | Pick up nearby item |
| E | Pick up nearby item / advance dialogue |
| I | Open / close inventory |
| F | Equip selected item |
| Scroll Wheel | Cycle weapons |