# x2shadow/escapefromcandytower architecture

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

- Interactive diagram: https://gitdiagram.com/x2shadow/escapefromcandytower
- Repository: https://github.com/x2shadow/escapefromcandytower

## Overview

The “Escape from Candy Tower” project is a Unity-based 3D Platformer. Its architecture is built on top of Unity’s game engine using the Universal Render Pipeline (URP) with several plugins and external assets to extend functionality (such as GamePush for online features, UniTask for async capability, the NEW Input System for improved player input, and the Safe Area Helper to manage UI on multiple devices).

##### Major Components
- Game Engine – At the heart of the project is Unity. Indicate Unity’s core systems (rendering, scene management, physics, etc.) since the project relies on Unity 2022.3.55f1 with URP.
- Scenes & Levels – The project includes multiple Unity scenes (Level1, Level2, Level3, MainMenu) which organize game flow and user experience.
- Game Logic & Managers – Look for key scripts and prefabs such as GameManager, AudioManager, CameraManager, PlayerController, and supporting managers (e.g., for checkpoints, UI, input handling).
- Assets & Art – There is a significant collection of art assets, 3D models, animations, materials, and prefabs (characters, platforms, environment objects) that define the visual and interactive aspects of the game.
- Input & UI – The project uses the new Unity Input System and TextMesh Pro, with dedicated scripts and prefabs for UI elements such as buttons, sliders, and on-screen feedback.
- Audio – An audio sub-system is indicated through AudioManager, audio prefabs, and relevant sound effect files.

##### Relationships and Interactions
- Unity Engine as the base platform and indicate that it hosts various subsystems (Scenes, Physics, Rendering, Input).
- Dependencies from game logic components to the plugin modules. For example, runtime game scripts interact with GamePush for online communications or achievements.
- Pull in the relationship between the UI layer (using TextMesh Pro, safe area management) and input systems.
- Asynchronous operations and external calls using UniTask, highlighting how gameplay scripts interact with these utility libraries for non-blocking operations.
- Out how art assets (3D models, animations, prefabs) are loaded into the scenes and manipulated by the logic scripts (for example, during character movement, collision detection, platform mechanics).

##### Architectural Patterns/Design Principles
- The overall design follows Unity’s component-based architecture where each game object has attached scripts (MonoBehaviours) handling discrete functionality.
- There’s a separation of editor (setup windows, game configuration editors under Editor folders) and runtime code (under Runtime folders).
- Many modules are organized in a modular fashion (for example, under the GamePush/Runtime/Modules directory) which suggests an emphasis on reusability and separation of concerns.
- Use of asynchronous programming with UniTask is a design choice to improve responsiveness and decouple heavy operations.

- Component is clearly labeled (e.g., “GamePush Runtime”, “UniTask Library”, “New Input System”) with explanations of roles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Engine and Core Systems
    U["Unity Engine (2022.3.55f1 with URP)"]:::engine
    R["Rendering Engine"]:::engine
    P["Physics Engine"]:::engine
    SM["Scene Management"]:::engine
    IU["Input System (Unity built-in)"]:::engine

    U --> R
    U --> P
    U --> SM
    U --> IU

    %% Game Scenes
    subgraph "Game Scenes"
        S["Scenes & Levels"]:::scene
        L1["Level1.unity"]:::scene
        L2["Level2.unity"]:::scene
        L3["Level3.unity"]:::scene
        MM["MainMenu.unity"]:::scene
    end

    SM --> S
    S --> L1
    S --> L2
    S --> L3
    S --> MM

    %% Game Logic & Managers
    subgraph "Game Logic & Managers"
        GM["Game Manager"]:::logic
        AM["Audio Manager"]:::logic
        CM["Camera Manager"]:::logic
        PC["Player Controller"]:::logic
        CP["Checkpoints & Game Logic"]:::logic
    end

    %% Connections from scenes to game management
    MM --> GM
    L1 --> GM
    L2 --> GM
    L3 --> GM

    GM --> PC
    GM --> CM
    GM --> AM
    GM --> CP

    %% Audio Sub-System
    subgraph "Audio Sub-System"
        AS["Audio Files & SFX"]:::audio
    end

    AM --> AS

    %% Input & UI
    subgraph "Input & UI"
        NI["New Input System"]:::input
        UI["UI Components & TextMesh Pro"]:::input
    end

    IU --> NI
    NI --> UI
    NI --> PC

    %% Plugins & External Modules
    subgraph "Plugins & External Modules"
        GP["GamePush"]:::plugin
        CF["CrystalFramework/Safe Area Helper"]:::plugin
        UT["UniTask Library"]:::plugin
    end

    GP --> GM
    UT --> GM
    CF --> UI

    %% Assets & Art
    subgraph "Assets & Art"
        AA["3D Models, Animations, Materials, Prefabs"]:::art
    end

    AA --> SM

    %% Click Events for Component Mapping
    click S "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/_Project/Scenes"
    click GM "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Scripts/GameManager.cs"
    click GM "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Prefabs/GameManager.prefab"
    click AM "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Scripts/AudioManager.cs"
    click AM "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Prefabs/Audio/AudioManager.prefab"
    click CM "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Scripts/CameraManager.cs"
    click CM "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Prefabs/CameraSystem.prefab"
    click PC "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Scripts/PlayerController.cs"
    click PC "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Prefabs/Character/Player.prefab"
    click CP "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Scripts/DozaScripts/Checkpoint.cs"
    click CP "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Scripts/DozaScripts/CheckpointsManager.cs"
    click GP "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/Plugins/GamePush"
    click CF "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/Plugins/CrystalFramework/Utility/SafeArea.cs"
    click UT "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/Plugins/UniTask"
    click NI "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Settings/PlayerInputActions.inputactions"
    click NI "https://github.com/x2shadow/escapefromcandytower/blob/main/Assets/_Project/Settings/PlayerInputActions.cs"
    click UI "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/_Project/Scripts/UI"
    click UI "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/TextMesh Pro"
    click AA "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/_Project/3D Models"
    click AA "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/_Project/Art"
    click AA "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/_Project/Materials"
    click AS "https://github.com/x2shadow/escapefromcandytower/tree/main/Assets/_Project/SFX"
    click AS "https://github.com/x2shadow/escapefromcandytower/blob/main/ProjectSettings/AudioManager.asset"

    %% Styles
    classDef engine fill:#f7f1e3,stroke:#e58e26,stroke-width:2px;
    classDef scene fill:#c7ecee,stroke:#22a6b3,stroke-width:2px;
    classDef logic fill:#dff9fb,stroke:#60a3bc,stroke-width:2px;
    classDef plugin fill:#f6e58d,stroke:#f9ca24,stroke-width:2px;
    classDef input fill:#badc58,stroke:#6ab04c,stroke-width:2px;
    classDef audio fill:#f9ca24,stroke:#f0932b,stroke-width:2px;
    classDef art fill:#ffeaa7,stroke:#fdcb6e,stroke-width:2px;
```
