# vilbeyli/pacman architecture

> Architecture diagram of the GitHub repository vilbeyli/pacman, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vilbeyli/pacman
- Repository: https://github.com/vilbeyli/pacman

## Overview

##### Project type and purpose
- This is a Unity3D‐based 2D Pacman clone (full‐stack in the sense of game front end & game logic but entirely client‐side).
- Purpose: replicate classic Pacman gameplay (player, ghosts with AI), menus, level progression, scoring—and deployable as WebGL via Unity.

##### File structure
- Top level:
- Assets/
– Animation/ (per‐character animation clips & controllers)
– Prefabs/ (Pacman, ghosts, pellets, UI elements)
– Scenes/ (menu, game, scores, credits)
– Scripts/
· GUI Scripts/ (menu navigation, in‐game UI updates)
· Managers/ (GameManager, ScoreManager, TileManager, MusicManager)
· Core scripts (AI.cs, PlayerController.cs, GhostMove.cs, Energizer.cs, Pacdot.cs, etc.)
– Materials, Fonts, Sprites
- ProjectSettings/ (Unity project configuration)
- README.md, LICENSE.txt

##### README for additional insights
- Implements original Pacman ghost AI behavior from Game Internals link.
- Includes tutorial base code plus custom menus, global high scores, and level progression.

##### Detail
- Every major script or manager as its own node.
- Inter‐component dependencies (e.g., “GhostMove → TileManager”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Runtime
    UE["Unity Engine Runtime"]:::engine

    %% Scenes as states
    subgraph "Scenes"
        direction TB
        MS["Menu Scene"]:::scene
        GS["Game Scene"]:::scene
        SS["Scores Scene"]:::scene
        CS["Credits Scene"]:::scene
    end

    %% Input Layer
    subgraph "Input Layer"
        direction TB
        PI["Player Input"]:::input
        PC["PlayerController\n(MonoBehaviour)"]:::core
    end

    %% Gameplay Logic
    subgraph "Gameplay Logic"
        direction TB
        AI["AI.cs\n(Ghost targeting logic)"]:::core
        GMV["GhostMove.cs\n(Ghost movement & states)"]:::core
        TM["TileManager.cs\n(Maze grid & pathfinding)"]:::core
        EN["Energizer.cs\n(Power-up collectible)"]:::core
        PD["Pacdot.cs\n(Standard collectible)"]:::core
        PT["Point.cs\n(Scoring trigger & popup)"]:::core
    end

    %% Managers
    subgraph "Managers"
        direction TB
        GM["GameManager.cs\n(Scene flow & level progression)"]:::manager
        SM["ScoreManager.cs\n(High-score tracking)"]:::manager
        MM["MusicManager.cs\n(Background music & SFX)"]:::manager
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MN["MenuNavigation.cs\n(Main menu controls)"]:::ui
        GU["GameGUINavigation.cs\n(In-game HUD updates)"]:::ui
        SCU["Scores.cs\n(High-score display)"]:::ui
        MVU["Move.cs\n(Demo movement/tutorial)"]:::ui
        NT["NameToTitle.cs\n(Scene title switcher)"]:::ui
        PS["PacdotSpawner.cs\n(Pacdot layout spawner)"]:::ui
    end

    %% Assets
    subgraph "Assets"
        direction TB
        subgraph Prefabs
            direction TB
            PP["Pacman Prefab"]:::asset
            BL["blinky.prefab"]:::asset
            INK["inky.prefab"]:::asset
            PIY["pinky.prefab"]:::asset
            CLD["clyde.prefab"]:::asset
            PDf["pacdot.prefab"]:::asset
            ENf["energizer.prefab"]:::asset
            P200["point200.prefab"]:::asset
            P400["point400.prefab"]:::asset
            P800["point800.prefab"]:::asset
            P1600["point1600.prefab"]:::asset
        end
        subgraph Animations
            direction TB
            APC["Animation Controllers & Clips"]:::asset
        end
        MT["Materials & Fonts"]:::asset
    end

    %% Connections
    UE --> MS
    UE --> GS
    UE --> SS
    UE --> CS

    MS -->|Start Game| GS
    GS -->|View Scores| SS
    SS -->|Back to Menu| MS
    MS -->|View Credits| CS

    MS --> MN
    GS --> GU
    SS --> SCU
    CS --> NT

    PI --> PC
    PC --> GS
    PC --> PP
    PC --> TM

    PC -->|Move Query| TM
    GMV -->|Move Query| TM
    AI -->|Pathfinding| TM

    EN --> SM
    EN --> GM
    PD --> SM
    PD --> GM
    PT --> SM

    GM --> MS
    GM --> GS
    GM --> SS
    GM --> CS

    MN --> GM
    GU --> GM
    SCU --> SM
    MVU --> GM
    NT --> GM
    PS --> TM

    GM --> MM
    SM --> GU
    GM --> GU
    GM --> MN

    %% Click Events
    click MS "https://github.com/vilbeyli/pacman/blob/master/Assets/Scenes/menu.unity"
    click GS "https://github.com/vilbeyli/pacman/blob/master/Assets/Scenes/game.unity"
    click SS "https://github.com/vilbeyli/pacman/blob/master/Assets/Scenes/scores.unity"
    click CS "https://github.com/vilbeyli/pacman/blob/master/Assets/Scenes/credits.unity"
    click PC "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/PlayerController.cs"
    click AI "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/AI.cs"
    click GMV "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GhostMove.cs"
    click TM "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Managers/TileManager.cs"
    click EN "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Energizer.cs"
    click PD "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Pacdot.cs"
    click PT "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Point.cs"
    click GM "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Managers/GameManager.cs"
    click SM "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Managers/ScoreManager.cs"
    click MM "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/Managers/MusicManager.cs"
    click MN "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GUI Scripts/MenuNavigation.cs"
    click GU "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GUI Scripts/GameGUINavigation.cs"
    click SCU "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GUI Scripts/Scores.cs"
    click MVU "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GUI Scripts/Move.cs"
    click NT "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GUI Scripts/NameToTitle.cs"
    click PS "https://github.com/vilbeyli/pacman/blob/master/Assets/Scripts/GUI Scripts/PacdotSpawner.cs"
    click PP "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/pacdotMove.prefab"
    click BL "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/blinky.prefab"
    click INK "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/inky.prefab"
    click PIY "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/pinky.prefab"
    click CLD "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/clyde.prefab"
    click PDf "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/pacdot.prefab"
    click ENf "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/energizer.prefab"
    click P200 "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/point200.prefab"
    click P400 "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/point400.prefab"
    click P800 "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/point800.prefab"
    click P1600 "https://github.com/vilbeyli/pacman/blob/master/Assets/Prefabs/point1600.prefab"
    click APC "https://github.com/vilbeyli/pacman/tree/master/Assets/Animation"
    click MT "https://github.com/vilbeyli/pacman/blob/master/Assets/Materials/pauseTexture.mat"

    %% Styles
    classDef engine fill:#FADBD8,stroke:#C0392B,color:#000
    classDef scene fill:#EBDEF0,stroke:#8E44AD,color:#000
    classDef input fill:#D6EAF8,stroke:#2874A6,color:#000
    classDef core fill:#D0EFFF,stroke:#21618C,color:#000
    classDef manager fill:#D5F5E3,stroke:#239B56,color:#000
    classDef ui fill:#FCF3CF,stroke:#B7950B,color:#000
    classDef asset fill:#E5E7E9,stroke:#7B7D7D,color:#000
```
