# tranhaok4/hyperspace-cosmo-clash architecture

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

- Interactive diagram: https://gitdiagram.com/tranhaok4/hyperspace-cosmo-clash
- Repository: https://github.com/tranhaok4/hyperspace-cosmo-clash

## Overview

##### Project type and purpose
- This is a Unity‐based 2D/3D game project (“Hyperspace-Cosmo-Clash”).
- It comprises game scenes, assets (sprites, materials, audio, VFX), ScriptableObject data, prefabs, and C# gameplay scripts.

##### File structure
- Top‐level Unity folders:
- Assets (Animate, Data, Materials, Music, Prefabs, Scenes, Scripts, Sprites, TilePalette)
- Packages, ProjectSettings, UserSettings
- Under Assets/Scripts, directories group by feature: CommonScripts, Player, Ship, Enemy, Bullet, Obstacles, Spawner, Stages, UI, Music, VFX, Item, Enhancement, etc.
- Data folder stores ScriptableObject definitions (e.g. ShipProfileSO, BossAbilitiesData, SceneMusicData).
- Scenes folder holds Unity scene files (GameMenuScene, ShipSelectionScene, Map1, PrototypeScene).

##### README
- Minimal content (“# Hyperspace-Cosmo-Clash”), but structure implies a data-driven architecture: ScriptableObjects driving game parameters.

##### Main components and their interactions
a. Core engine (Unity)
b. Input subsystem
- InputManager → receives player input → dispatches to ShipController, UI
c. Gameplay manager layer
- GameCtrl / GameLevelManager → orchestrates scene loading, stage progression
- StageSpawnerManager & SpawnerStage → spawn waves of enemies, meteorites
d. Entity layer
- PlayerShip (ShipCtrl, ShipMovement, ShipShootByMouse)
- Enemies (EnemyCtrl, BossCtrl, movement/AI scripts)
- Obstacles (MeteoriteCtrl)
- Projectiles (BulletCtrl, MissileFollowEnemy)
e. Data layer (ScriptableObjects)
- ShipProfileSO, BossAbilitiesDataSO, EnhancementDataSO, SceneMusicDataSO
- These feed into controllers (e.g. ShipEnhanceManager reads EnhancementDataSO)
f. Visual/Audio layer
- Sprites, Materials, Animations, VFX prefabs (Animate folder, VFX scripts)
- AudioManager / GameMusicManager → plays SceneMusic, SFX via SoundEffectDataSO
g. UI layer
- HUD controllers (CoinHUD, ExpLevelHUD, UIEnemyHPBar, PauseMenuHUD, ShipSelectionUI)
- BaseUIComponent provides common behavior

##### Architectural patterns and principles
- Data-driven: ScriptableObjects define parameters, so designers tune without code changes.
- Separation of concerns: Input → Gameplay logic → Entities → Rendering/Audio → UI
- Manager/controller pattern: central “GameCtrl” and specialized managers (AudioManager, GameLevelManager).
- Spawner and StageController manage lifecycles, decoupled from entity behaviors.
- Observer/Notificater pattern: scripts like Notificater, PlayShipSkillNotificater broadcast events.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Central Engine
    UNITY["Unity Engine"]:::engine

    %% Subgraphs
    subgraph "Subsystems" 
        direction TB
        InputMgr["InputManager"]:::subsystem
        AudioMgr["AudioManager"]:::subsystem
        GameMusicMgr["GameMusicManager"]:::subsystem
    end

    subgraph "Core Managers" 
        direction TB
        GameCtrl["GameCtrl"]:::core
        GameLevelMgr["GameLevelManager"]:::core
        StageActivator["StageActivator"]:::core
        StageSpawnerMgr["StageSpawnerManager"]:::core
        SpawnerStage["SpawnerStageCtrl"]:::core
    end

    subgraph "Data Layer (ScriptableObjects)"
        direction TB
        ShipProfileSO["ShipProfileSO"]:::data
        BossAbilitiesData["BossAbilitiesDataSO"]:::data
        EnhancementData["EnhancementDataSO"]:::data
        StagesData["StagesData"]:::data
        SceneMusicData["SceneMusicDataSO"]:::data
        SoundEffectData["SoundEffectDataSO"]:::data
    end

    subgraph "Entity Layer"
        direction TB
        PlayerShip["PlayerShip\n(ShipCtrl, Movement, Shooting, EnhanceManager)"]:::entity
        Enemy["Enemy\n(EnemyCtrl, BossCtrl)"]:::entity
        Obstacles["Meteorite\n(MeteoriteCtrl)"]:::entity
        Projectiles["Projectiles\n(BulletCtrl, MissileFollowEnemy)"]:::entity
    end

    subgraph "Visual & VFX Layer"
        direction TB
        Animate["Animations & Clips"]:::visual
        VFXCtrl["VFXCtrl"]:::visual
        VFXDesp["VFXDespawning"]:::visual
        SpritesMaterials["Sprites & Materials"]:::visual
    end

    subgraph "UI Layer"
        direction TB
        BaseUI["BaseUIComponent"]:::ui
        CoinHUD["CoinHUD"]:::ui
        ExpHUD["ExpLevelHUD"]:::ui
        EnemyHP["UIEnemyHPBar"]:::ui
        PauseMenu["PauseMenuHUD"]:::ui
        ShipSelectUI["ShipSelectionUI"]:::ui
        UIShipProfile["ShipProfileSO"]:::ui
    end

    subgraph "Scenes"
        direction TB
        MenuScene["GameMenuScene"]:::scene
        ShipSelectScene["ShipSelectionScene"]:::scene
        Map1Scene["Map1"]:::scene
        PrototypeScene["PrototypeScene"]:::scene
    end

    %% Connections
    UNITY -->|"runs subsystems"| InputMgr
    UNITY -->|"runs subsystems"| AudioMgr
    UNITY -->|"runs subsystems"| GameMusicMgr
    UNITY -->|"hosts managers"| GameCtrl
    UNITY --> GameLevelMgr
    UNITY --> StageActivator
    UNITY --> StageSpawnerMgr
    UNITY --> SpawnerStage

    InputMgr -->|"dispatches input to"| GameCtrl
    InputMgr --> UIShipProfile

    GameCtrl -->|"orchestrates scenes"| GameLevelMgr
    GameLevelMgr --> MenuScene
    GameLevelMgr --> ShipSelectScene
    GameLevelMgr --> Map1Scene
    GameLevelMgr --> PrototypeScene

    GameCtrl --> StageActivator
    StageActivator --> StageSpawnerMgr
    StageSpawnerMgr --> SpawnerStage
    SpawnerStage --> Enemy
    SpawnerStage --> Obstacles

    GameCtrl --> PlayerShip
    GameCtrl --> Enemy
    GameCtrl --> Projectiles

    PlayerShip -->|reads data| ShipProfileSO
    PlayerShip -->|reads data| EnhancementData

    Enemy -->|reads data| BossAbilitiesData

    StageSpawnerMgr -->|reads data| StagesData

    GameMusicMgr -->|reads data| SceneMusicData
    AudioMgr -->|reads data| SoundEffectData
    GameMusicMgr -->|"plays music"| UNITY

    PlayerShip -->|triggers VFX| VFXCtrl
    PlayerShip -->|uses sprites| SpritesMaterials
    Enemy -->|triggers VFX| VFXDesp
    Obstacles -->|triggers VFX| VFXDesp

    Enemy -->|updates HUD via events| EnemyHP
    PlayerShip -->|updates HUD via events| CoinHUD
    PlayerShip --> ExpHUD
    PauseMenu -->|pauses game| GameCtrl
    ShipSelectUI -->|"selects profile"| ShipProfileSO

    %% Click Events
    click InputMgr "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/CommonScripts/InputManager.cs"
    click GameCtrl "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/CommonScripts/GameCtrl.cs"
    click GameLevelMgr "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/CommonScripts/GameLevelManager.cs"
    click GameLevelMgr "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Prefabs/GameLevelManager.prefab"
    click StageActivator "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Stages/StageActivator.cs"
    click StageSpawnerMgr "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Stages/StageSpawnerManager.cs"
    click SpawnerStage "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Spawner/SpawnerStage/SpawnerStageCtrl.cs"
    click PlayerShip "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Ship/ShipCtrl.cs"
    click PlayerShip "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Ship/ShipMovement.cs"
    click PlayerShip "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Ship/ShipShootByMouse.cs"
    click PlayerShip "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Ship/ShipEnhanceManager.cs"
    click ShipProfileSO "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/ShipProfileSO"
    click Enemy "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Enemy/EnemyCtrl.cs"
    click BossAbilitiesData "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Scripts/Enemy/Boss/BossAbilities"
    click Obstacles "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Obstacles/Meteorite/MeteoriteCtrl.cs"
    click Projectiles "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Bullet/BulletCtrl.cs"
    click Projectiles "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Bullet/Missle/MissleFollowEnemy.cs"
    click ShipProfileSO "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/ShipProfileSO"
    click BossAbilitiesData "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/BossAbilitiesData"
    click EnhancementData "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/EnhancementData"
    click StagesData "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/StagesData"
    click SceneMusicData "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/SceneMusicData"
    click SoundEffectData "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Data/SoundEffectData"
    click AudioMgr "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Music/AudioManager.cs"
    click GameMusicMgr "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Music/GameMusicManager.cs"
    click SceneMusicData "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Music/SceneMusicDataSO.cs"
    click SoundEffectData "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/Music/SoundEffectDataSO.cs"
    click Animate "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Animate"
    click VFXCtrl "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/VFX/VFXCtrl.cs"
    click VFXDesp "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/VFX/VFXDespawning.cs"
    click SpritesMaterials "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Sprites"
    click SpritesMaterials "https://github.com/tranhaok4/hyperspace-cosmo-clash/tree/main/Assets/Material"
    click BaseUI "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/BaseUIComponent.cs"
    click CoinHUD "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/Coin/CoinHUD.cs"
    click ExpHUD "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/ExpLevel/ExpLevelHUD.cs"
    click EnemyHP "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/EnemyUI/UIEnemyHPBar.cs"
    click PauseMenu "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/PauseMenu/PauseMenuHUD.cs"
    click ShipSelectUI "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/ShipSelection/ShipSelectionUI.cs"
    click UIShipProfile "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scripts/UI/ShipSelection/ShipProfileSO.cs"
    click MenuScene "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scenes/GameMenuScene.unity"
    click ShipSelectScene "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scenes/ShipSelectionScene.unity"
    click Map1Scene "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scenes/Map1.unity"
    click PrototypeScene "https://github.com/tranhaok4/hyperspace-cosmo-clash/blob/main/Assets/Scenes/PrototypeScene.unity"

    %% Styles
    classDef engine fill:#f9f,stroke:#333,stroke-width:1px
    classDef subsystem fill:#f90,stroke:#333,stroke-width:1px
    classDef core fill:#9cf,stroke:#333,stroke-width:1px
    classDef data fill:#6c6,stroke:#333,stroke-width:1px
    classDef entity fill:#c9f,stroke:#333,stroke-width:1px
    classDef visual fill:#ccc,stroke:#333,stroke-width:1px
    classDef ui fill:#ff9,stroke:#333,stroke-width:1px
    classDef scene fill:#ddd,stroke:#333,stroke-width:1px
```
