RogueLike2D — Unity Learn (C#)

A classic 2D turn-based roguelike built in Unity, focused on procedural level generation, deterministic AI behavior, resource-driven survival, and scalable game architecture.

RogueLike2D gameplay overview

Project Overview

This project recreates a traditional roguelike gameplay loop using modern Unity systems. The focus was not visual fidelity, but systems design: turn order, procedural content, AI decision-making, and state management.

  • Unity 2D
  • C#
  • Turn-Based Systems
  • Procedural Generation
  • AI Behavior
  • UI Feedback
//Procedural dungeon layout

Design Goals

The project was approached as a systems exercise rather than a prototype. Every mechanic needed to support scalability, clarity, and deterministic behavior.

Deterministic Modular Scalable Readable System-Driven
  • Turn-based clarity
    Every action resolves in a predictable order. No overlapping input, no race conditions, and no frame-dependent logic.
  • Procedural replayability
    Levels are generated dynamically using constrained randomness while preserving navigability and gameplay balance.
  • Simple, readable AI
    Enemy logic prioritizes debuggability and intent over complex pathfinding.
  • Clear player feedback
    UI, audio, and visual responses reinforce cause-and-effect for every action.

Core Architecture

The game is structured around a central GameManager that coordinates turn order, level progression, and persistent player state.

Centralized State Turn Locking Scene Persistence

┌──────────────────────────────┐
│         GameManager          │
│------------------------------│
│ Level Progression            │
│ Turn Control                 │
│ Game Over State              │
│ Player Persistence           │
└──────────────┬───────────────┘
               │
     ┌─────────┴─────────┐
     │                   │
┌──────────────┐   ┌──────────────┐
│ BoardManager │   │ Turn System  │
│--------------│   │--------------│
│ Dungeon Gen  │   │ Player Turn  │
│ Spawn Logic  │   │ Enemy Turn   │
└──────────────┘   └──────────────┘

All gameplay systems route through a single authoritative controller. This prevents desynchronization between player input, AI behavior, and world state.

Procedural Dungeon Generation

Each level is generated at runtime using a grid-based system. The dungeon layout changes every playthrough while maintaining consistent gameplay rules.

2D Arrays Constrained Randomness Tilemap-Based
  • Outer walls define level boundaries
  • Interior tiles are filled with walkable floor
  • Obstacles are placed using randomized empty cells
  • Enemy and item spawns use tracked free positions
Dungeon generation steps

Player & Turn-Based Movement

The player operates entirely within the turn system. Every input resolves into a single action: move, attack, or wait.

Grid-Based Input Locking Action Cost
  • Movement consumes a turn and food resource
  • Attempting to move into an enemy triggers an attack
  • Blocked movement prevents wasted turns

This design guarantees fairness: the player and enemies always act under the same rules.

Enemy AI Behavior

Enemy behavior is intentionally simple and deterministic. Each enemy performs exactly one action per enemy turn.

Distance-Based Logic Axis Priority Turn-Limited
  • Enemies track player position
  • Movement prioritizes X or Y axis based on distance
  • Adjacent enemies attack instead of moving

This approach avoids complex pathfinding while producing readable, predictable combat encounters.

Resource Management & Survival

Food serves as both health and a time constraint. Every action pushes the player closer to failure.

Dual-Purpose Resource Pacing Control Risk / Reward
  • Movement consumes food
  • Enemy attacks reduce food
  • Pickups restore food and extend survival
Food and level UI

UI & Player Feedback

Feedback systems reinforce every player action and consequence. The UI communicates state clearly without overwhelming the screen.

Immediate Feedback Minimal UI Clear State
  • Food counter updates per action
  • Screen flashes on damage
  • Level transition text reinforces progression
  • Game Over screen halts input and communicates failure

What I Learned

RogueLike2D reinforced that strong games emerge from strong systems. Simplicity, clarity, and deterministic logic outperform complexity when building scalable gameplay.

Systems Thinking Turn-Based Design AI Readability Procedural Logic
  • Turn-based games demand strict control flow
    Input must be gated and actions serialized to prevent logic errors.
  • Simple AI can still feel intelligent
    Predictability allows players to learn and plan.
  • Procedural systems need constraints
    Randomness is only fun when bounded by design rules.