RAT RUNNER LAB

[ SEWER NAVIGATION SYSTEM ]

GALLERY CHANGELOG ARCHITECTURE GIT REPO WEB BUILD ITCH.IO

CHANGELOG

> SYSTEM LOG - MAINTENANCE REPORTS

> ACCESSING DEVELOPMENT HISTORY...

> LOADING...

RAT RUNNER - TECHNICAL ARCHITECTURE

OVERVIEW

Rat Runner is a Unity 3D stealth game (Unity 2023.2.20f1) built with a singleton manager pattern and event-driven architecture. The design emphasizes modularity, maintainability, and clean separation of concerns.

CORE ARCHITECTURE

Singleton Manager System

Seven persistent singleton managers orchestrate game systems across scenes:

Manager Responsibility
GameManager State machine (PLAYING, PAUSED, CRAFTING, CONSOLE)
DayManager Progression system, save/load, respawn logic
UpgradeManager Centralized stat modification system
AudioManager Event-driven sound system with auto-registration
ScreenEffectManager Real-time visual feedback (health, enemy proximity)

Event-Driven Communication

Systems communicate via UnityEvents instead of direct references, enabling loose coupling:

GameManager.OnWorkbenchOpened.AddListener(HandleCrafting);
Inventory.OnItemAdded.AddListener(UpdateUI);
Player.OnHealthChanged.AddListener(UpdateEffects);

This pattern allows independent system development and prevents cascading dependencies.

Component-Based Player Design

The Player class acts as a lightweight hub that delegates to specialized components rather than implementing monolithic logic:

  • PlayerMovement - Tank controls with upgrade support
  • Inventory - Dictionary-based item tracking with events
  • Health System - Damage handling with invincibility frames
  • Upgrade Tracking - Dictionary of applied stat bonuses

KEY SYSTEMS

NavMesh Enemy AI

Three-mode behavior system with dynamic state transitions:

  • Patrol: Waypoint cycling with distance-based switching
  • Hunt: Player pursuit triggered by proximity zones
  • Proximity: Final enemy activation based on player distance

Includes final-day difficulty scaling and performance optimization (pauses pathfinding when game is frozen).

Crafting & Upgrade System

ScriptableObject-based recipes define requirements and rewards. Three upgrade types with additive stat bonuses:

Upgrade Effect Implementation
Mobility Movement/turning speed Modifies PlayerMovement physics
Vision Light range Modifies Light component radius
Vigor Max health Increases base health pool

Upgrades apply immediately on craft and persist through save/load cycles.

Save/Load System

BinaryFormatter serialization preserves:

  • Player inventory and upgrade states
  • Day progression counter
  • World item positions/rotations (tag-based collection)

Automatic save triggers on player death; data deletion on game over or successful escape.

Day Cycle Progression

Countdown system (Day 3 → Day 1) with escalating difficulty:

  • Death decrements counter and triggers respawn
  • Final day increases enemy speed
  • Game over on Day 1 death

Visual Feedback System

ScreenEffectManager provides context-aware overlays:

  • Low Health: Red vignette pulse at critical health
  • Enemy Proximity: Noise overlay with sine wave animation

Both effects use real-time alpha blending for smooth transitions.

DATA ARCHITECTURE

ScriptableObject Pattern

Game data defined as designer-friendly assets rather than hardcoded values:

[CreateAssetMenu(menuName = "Crafting Recipe/Upgrade")]
public class CraftingRecipe : ScriptableObject
{
    public List<ItemRequirement> _requiredItems;
    public UpgradesEnum _upgradeGranted;
    public bool CanCraft(Inventory inv) { ... }
}

Enum-Based Type Safety

Inventory and upgrade systems use enums with Dictionary storage for compile-time safety and O(1) lookups:

  • Dictionary<ItemsEnum, int> - Item quantities
  • Dictionary<UpgradesEnum, int> - Upgrade levels

TECHNICAL STACK

Component Technology
Engine Unity 2023.2.20f1
Physics Rigidbody with custom gravity
AI Pathfinding Unity NavMesh
Input Unity Input System (action maps)
Persistence BinaryFormatter serialization
UI Unity UI + TextMeshPro

KEY CLASSES

Core Managers

GameManager
State machine controller managing game states, cursor behavior, and time scale. Broadcasts events for state transitions.
DayManager
Handles day countdown (Day 3→1), player/enemy respawning, save/load operations, and upgrade application on load.
UpgradeManager
Centralized system that applies stat bonuses to PlayerMovement, PlayerLight, and PlayerHealth based on upgrade dictionary.
AudioManager
Event-driven audio system with automatic button sound registration and scene-aware atmosphere management.

Player Components

Player
Hub class managing references to Movement, Inventory, Health, and Upgrades. Handles collision detection and damage application.
PlayerMovement
Tank control implementation with Rigidbody physics. Stores baseline stats for additive upgrade calculations.
Inventory
Dictionary-based item management with ItemsEnum type safety. Fires events on item add/remove for UI updates.

AI & Gameplay

EnemyNavigation
NavMesh AI with patrol/hunt/proximity modes. Handles day scaling, audio/visual triggers, and performance optimization.
Workbench
Crafting interaction controller with proximity detection, UI coordination, and keyboard shortcuts (1-3 for quick crafting).
CraftingRecipe
ScriptableObject defining item requirements and upgrade rewards. Includes validation logic for crafting eligibility.

Persistence

SaveSystem
BinaryFormatter serialization handler. Static methods for save/load/delete to persistent data path.
GameData
Serializable container for inventory, day count, upgrades, and world item transforms.

DESIGN PHILOSOPHY

Hub-and-Spoke Architecture: Managers serve as central hubs while game objects communicate via events rather than direct references. This creates a highly modular codebase where individual systems can be modified independently without cascading changes. The Player class exemplifies this—it's a lightweight container that delegates to specialized components rather than implementing monolithic logic.

GIT REPOSITORY

> ACCESSING SERVER...

View GitHub Repository

WEB BUILD

> LAUNCHING RAT RUNNER...

Play Rat Runner Online

[Note: As this is a minimum viable product build, performance may vary based on browser and device capabilities. There may also be uncaught bugs or unrefined features]

ITCH.IO

> ACCESSING ITCH.IO...

View on Itch.io