GAME 1303 — Tier 4: Hazards, Level Pieces & Progression
Eighteen scripts. No changes to earlier tiers this time — Tier 4 sits on top of Tier 1 (Health, DamageOnContact, CollectionTracker, AudioManager, SceneLoader, GameManager) and optionally Tier 2 (Hurtbox for breakables and hit-switches).
Requires the Tier 3 v1.1 update of DamageOnContact (the one that respects its enabled checkbox). Almost every hazard here works by switching damage on and off, and without that fix a retracted spike still kills you.
Scripts/
Hazards/ SpinningSaw, SpikeTrap, Crusher, CyclingHazard, ElectricZone, KillZone
Level/ Breakable, Door, PuzzleSwitch, SwitchGroup, LevelExit
Progression/ ChoiceFlagManager, LevelData, LevelSet, LevelProgress,
LevelTimer, LevelSelectButton, LevelSelectMenu
The pattern behind every hazard
A hazard is a trigger collider + DamageOnContact + a script that turns that component on and off on a schedule. Once students see that, they can build any trap in their pitch without new code:
| Want | Build |
|---|---|
| Always-deadly spikes / acid | Trigger + DamageOnContact (Instant Kill). No hazard script needed. |
| Bottomless pit | KillZone stretched under the level. |
| Timed flame jet | CyclingHazard with On/Off times + a particle system. |
| Electric arc that stuns | ElectricZone (a CyclingHazard subclass — flicker + input stun). |
| Pop-up spikes | SpikeTrap, Timed or Triggered. |
| Ceiling shock ("jump too high") | ElectricZone, Always On, wide thin trigger along the top. |
| Slamming piston | Crusher (auto-measures its drop with a raycast). |
| Saw blade | SpinningSaw; add Tier 1 MovingPlatform to make it patrol. |
Every timed hazard has a Warning Time with a shake or a warning sprite. That's the fairness rule worth stating in class: a trap the player couldn't have anticipated isn't difficulty, it's a coin flip. Nicholas's course lives or dies on this.
Doors, switches and gates
Door— solid collider that opens by sliding, fading, or vanishing. Requirement is None, Collect (N of anItemTypefrom Tier 1'sCollectionTracker, optionally consumed), or Flag. FiresOnOpenFailedwhen the player is short, so you can show a hint.PuzzleSwitch— Touch, Stand (pressure plate), or Hit (needs a Tier 2 Hurtbox). WireOnActivated → Door.Open.SwitchGroup— "all three levers", with an option to break if one turns off.LevelExit— trigger that callsGameManager.LevelComplete(), sets a flag, and loads the next scene after a delay. Has the same Requirement options asDoor.ChoiceFlagManager— named true/false facts plus counters, persistent across scenes. It's here becauseDoorandLevelExitneed it; Tier 6's dialogue and ending scripts will use this same component, so it's already the narrative backbone.HasAll("has_key, !alarm_tripped")handles compound conditions including negation.
Progression (Zap Attack and MythoClash mainly)
LevelData (one asset per level) and LevelSet (one per sector/world) are ScriptableObjects; LevelProgress is a static PlayerPrefs helper — no component to place. A level unlocks when it's marked unlocked-from-start, was purchased, or its prerequisites are cleared (default: the previous level in the set). TryPurchase spends currency from the CollectionTracker, which is exactly Tony's green-electricity generator door at the level-select scale.
LevelTimer counts up (speedrun) or down (a limit), formats as mm:ss.hh, and saves the best time per level id. Wire LevelExit.OnCompleted → LevelTimer.StopAndRecord.
LevelSelectMenu + LevelSelectButton build the grid from a LevelSet and show locked / cleared / best-time state.
Warn students about Level Id: progress saves under that string, so renaming one after playtesting silently resets it. And PlayerPrefs persists across rebuilds and is shared per-project on a machine — that's the usual answer to "why is level 3 still unlocked?" LevelProgress.ResetAll() is wired into LevelSelectMenu.ResetAllProgress for a clear-save button.
Per-game recipes
- Conquer the Cutthroat Course (Nicholas) — this tier plus Tier 1 is his game.
SpinningSaw,CyclingHazard(fire),KillZone(acid pit),SpikeTrap,Crusher,ElectricZone(ceiling),LevelExit. SetRespawnManagerto Use Lives = 3. Wire the third death (RespawnManager.OnGameOver) toAudioManager.PlaySFXwith his funny sound. - Zap Attack (Tony) —
SpinningSaw,ElectricZone,SpikeTrap,Door(Collect: green electricity, Consume off) in front of the level-5 exit,LevelData/LevelSet/LevelSelectMenufor four sectors,LevelTimerfor time attack. - Commission Witch (Sylvia) —
DoorandLevelExitwith Requirement = Collect on her ingredientItemTypes;PuzzleSwitchfor the order board. - Roach Invasion (Joshua) —
SpikeTrap,KillZone,LevelExitrequiring all plants collected. - Spark of Corruption (Kathryn) —
Breakablewalls with Min Damage To Break set so only the Sorcerer's stronger hit opens them;PuzzleSwitch+SwitchGroupfor party-cooperation puzzles. - The Magnet (Amarion) —
Breakablecrates that drop loot, and Tier 3'sMetalObjectthrown at them. - Anabasis (Andraya) —
PuzzleSwitch,Door(Flag), andChoiceFlagManageras the memory of her player's choices.
AudioManager names referenced
spike_warn, spike_pop, crusher_slam, zap, fall, break, thud, door_open, door_locked, switch_on, level_complete.
Notes for the instructor
ElectricZoneextendsCyclingHazard— the only inheritance in the whole kit so far, and a decent five-minute lesson onvirtual/overrideif you want one. If it's a distraction, students can ignoreCyclingHazardand useElectricZonedirectly.Breakable's Min Damage To Break works by healing back damage that's too weak, so a weak hit is genuinely ignored rather than chipping it. It also forcesdestroyOnDeath = falseandinvulnerabilityTime = 0in Awake so students can't misconfigure it.SpikeTrap(Triggered mode) andDoor(proximity) poll withCollider2D.Overlaprather than needing a forwarder script on the child trigger — fewer files for students to wire, at the cost of a per-frame check. Fine at these scales.Crusherraycasts once at Start to find its own floor distance, so students can drag one prefab anywhere and it fits the shaft.- Same caveat as before: hand-reviewed, not compiled here.