← Back to games
Tower Defense 2D
Mouse-aimed 2D defense shooter built on pooled projectiles and singleton managers
Unity 2021.3 LTSC#Object PoolSingletonTemplate MethodRigidbody2D

A 2D defense shooter: aim with the mouse, click to fire, and clear waves of enemies before they breach your base. Built as a study in keeping runtime allocations at zero and gameplay systems decoupled.
Tech stack
Unity 2021.3 LTS · C# · Unity 2D physics (Rigidbody2D, collision callbacks) · uGUI · PlayerPrefs persistence
Architecture & design patterns
- Object Pool —
BulletPoolpre-instantiates separate player and enemy bullet lists on startup and hands out deactivated instances viagetBullets(BulletType), so combat never callsInstantiateorDestroy - Singleton —
GameManager,EnemySpawner,BulletPool,SoundManagerandPlayerControllereach guard a staticInstanceinAwake(), destroying duplicates to keep a single authority per system - Template Method via inheritance —
EnemyControllerextendsGunControllerand overrides avirtual Aim(), reusing the shared fire/spawn pipeline while swapping mouse aiming for AI targeting - Enum-keyed lookup tables —
BulletTypeselects the pool to draw from, and a serializedSoundType[]mapsSoundEventstoAudioClips, so audio is triggered by intent rather than direct references - State-driven progression — a
Level[]model carriesLevelStatus(locked / unlocked / completed) and scales enemy count per level, with high scores persisted throughPlayerPrefs
Aiming uses ScreenToWorldPoint clamped to a maximum angle, with projectiles driven by physics impulses.