# egofree71/wanted-monty-mole architecture

> Architecture diagram of the GitHub repository egofree71/wanted-monty-mole, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/egofree71/wanted-monty-mole
- Repository: https://github.com/egofree71/wanted-monty-mole

## Overview

##### Project type and purpose
- This is a Unity-based remake of the C64 game “Wanted: Monty Mole” (beta, ~80% complete).
- It consists of Unity scenes, C# scripts, assets (sprites, animations, audio, fonts), and uses Unity’s Mono runtime and TextMeshPro.

##### File structure to extract high-level modules
- Top-level Unity folders under Assets:
- Animation (Clips, Controllers)
- Prefabs (Entities, Environment, UI)
- Resources (audio, fonts, Levels.json, map data, mods)
- Scenes (Intro, Main, Maze, End)
- Scripts (Entities, Maze, Intro, Tiles, Managers)
- Sprites (Entities, Environment, Fonts, Squares)
- TextMeshPro (shaders, docs, fonts)
- ProjectSettings & Packages hold engine/configuration metadata.
- Build output directories (Monty_Data, maze_Data, monty_mole_Data) contain Unity’s runtime data and Mono files.

##### README for additional insights
- Game is loaded by opening Main scene (runtime) or Maze scene (pre-generate maze).
- Input via gamepad or keyboard controls.
- Maze generation is a key feature (80% implemented).

a. Main components
- Unity Engine Core (Rendering, Physics2D, Audio, Input, SceneManagement)
- Mono/.NET Scripting Runtime (C# scripts)
- Game Manager Layer
– GameManager, LevelManager, MazeGenerator, ImportMaze
- Entity Module
– Prefabs + Scripts under Scripts/Entities + Animators/Controllers
- Maze Module
– Maze prefabs (TilesMap, BridgeTile, CrusherTile, etc.) + generator scripts
- UI & Intro Module
– IntroManager, TextScroll, ScrollingText, HealthBar, TextMeshPro integration
- Resource Loader
– Resources/Levels.json, map bytes, audio clips, fonts, mods loaded at runtime
- Scenes
– Intro → Maze (optional) → Main → End
b. Relationships & data flow
- Input System → GameManager → LevelManager → Entity Module & Maze Module
- MazeGenerator → Environment prefabs → Scene graph
- Entity Scripts respond to physics events → Animator Controllers → Rendering
- GameManager updates UI Module → HealthBar/TextMeshPro output
- Resources.Load API calls fetch JSON, audio, fonts at start or on demand
- SceneManager loads/unloads Scenes and persists managers where needed
c. Architectural patterns & design principles
- Unity’s component-based architecture (GameObjects + MonoBehaviours)
- Separation of concerns: Maze generation vs. Entities vs. UI vs. Game flow
- Prefab-driven content: reusable environment and entity prefabs
- Data-driven levels: JSON and binary maps in Resources
d. Technologies & frameworks
- Unity 2020.3 LTS
- C# / .NET / Mono runtime
- Unity2D Physics, Audio, Animation systems
- TextMeshPro for rich text in UI
- JSON file I/O for level data

##### Detail without overthinking
- Major scripts, prefabs, and data sources as separate components.
- Essential flow (input → logic → physics → rendering/audio → UI) and how the maze generation fits in.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Engine Subsystems
    subgraph "Unity Engine Core" 
        direction TB
        Input["Input"]:::engine
        Physics2D["Physics2D"]:::engine
        Rendering["Rendering"]:::engine
        Audio["Audio"]:::engine
        SceneMgmt["SceneManagement"]:::engine
    end

    %% Data Sources
    subgraph "Resources" 
        direction TB
        LevelsJSON["Levels.json"]:::data
        MapBin["Map.bin/.bytes"]:::data
        AudioClips["Fire_and_ice.mp3"]:::data
        Fonts["Fonts/*.asset"]:::data
        Mods["Mods/*.mod"]:::data
    end

    %% Scripts & Managers
    subgraph "Game Manager Layer" 
        direction TB
        GM["GameManager"]:::module
        LM["LevelManager"]:::module
        LD["Levels.cs"]:::module
        MG["MazeGenerator"]:::module
        IM["ImportMaze"]:::module
    end

    subgraph "Entity Module"
        direction TB
        Entities["Entity Scripts"]:::module
        PrefabEntities["Entity Prefabs"]:::module
        AnimCtrl["Animator Controllers"]:::module
        AnimClips["Animation Clips"]:::module
    end

    subgraph "Maze Module"
        direction TB
        MazeLogic["Maze.cs"]:::module
        MG2["MazeGenerator"]:::module
        IM2["ImportMaze"]:::module
        MazePrefabs["Maze Prefabs"]:::module
        TileMap["TilesMap.cs"]:::module
    end

    subgraph "Tiles Module"
        direction TB
        Tiles["Tile Behaviors"]:::module
    end

    subgraph "UI & Intro Module"
        direction TB
        Intro["IntroManager & Text"]:::module
        Health["HealthBar"]:::module
        Scroll["TextScroll"]:::module
        TMP["Fonts & Materials"]:::module
    end

    %% Scenes
    subgraph "Intro Scene" 
        direction TB
        Intro
    end
    subgraph "Maze Scene" 
        direction TB
        MG2
        IM2
        TileMap
    end
    subgraph "Main Scene"
        direction TB
        GM
        LM
        Entities
        PrefabEntities
        AnimCtrl
        AnimClips
        Health
        Scroll
    end
    subgraph "End Scene"
        direction TB
        GM
    end

    %% Data Flow
    Input -->|gets input| GM
    GM -->|manages levels| LM
    LM -->|loads levels| LevelsJSON
    LM -->|triggers| MG
    MG -->|generates| MazeLogic
    MazeLogic -->|uses| MapBin
    MG2 -->|instantiates| MazePrefabs
    GM -->|controls| Entities
    Entities -->|uses| AnimCtrl
    AnimCtrl -->|plays| AnimClips
    Entities -->|collisions| Physics2D
    Physics2D -->|updates| Rendering
    GM -->|updates| Health
    Scroll -->|display text| Rendering
    Fonts -->|provided to| TMP
    AudioClips -->|played by| Audio
    SceneMgmt -->|loads/unloads| IntroScene
    SceneMgmt -->|loads/unloads| MazeScene
    SceneMgmt -->|loads/unloads| MainScene
    SceneMgmt -->|loads/unloads| EndScene

    %% Click Events
    click GM "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/GameManager.cs"
    click LM "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/LevelManager.cs"
    click LD "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Levels.cs"
    click MG "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Maze/MazeGenerator.cs"
    click IM "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Maze/ImportMaze.cs"
    click Entities "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Scripts/Entities"
    click PrefabEntities "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Prefabs/Entities"
    click AnimCtrl "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Animation/Controllers"
    click AnimClips "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Animation/Clips"
    click MazeLogic "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Maze/Maze.cs"
    click MG2 "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Maze/MazeGenerator.cs"
    click IM2 "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Maze/ImportMaze.cs"
    click MazePrefabs "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Prefabs/Environment/Maze"
    click TileMap "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/TilesMap.cs"
    click Tiles "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Scripts/Tiles"
    click Intro "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/Intro/IntroManager.cs"
    click Health "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/HealthBar.cs"
    click Scroll "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Scripts/TextScroll.cs"
    click TMP "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/TextMesh Pro/Resources/Fonts & Materials"
    click LevelsJSON "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Resources/Levels.json"
    click MapBin "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Resources/Map.bin"
    click AudioClips "https://github.com/egofree71/wanted-monty-mole/blob/master/Assets/Resources/Fire_and_ice.mp3"
    click Fonts "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Resources/Fonts"
    click Mods "https://github.com/egofree71/wanted-monty-mole/tree/master/Assets/Resources"

    %% Styles
    classDef engine fill:#AED6F1,stroke:#1B4F72,color:#1B2631;
    classDef module fill:#A9DFBF,stroke:#196F3D,color:#1B2631;
    classDef data fill:#F9E79F,stroke:#B7950B,color:#1B2631;
    classDef scene fill:#D5D8DC,stroke:#566573,color:#1B2631;
```
