# azivast/state-based-skyforce architecture

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

- Interactive diagram: https://gitdiagram.com/azivast/state-based-skyforce
- Repository: https://github.com/azivast/state-based-skyforce

## Overview

##### Project type and purpose
- This is a 2D shooter game built in Unity.
- It follows a component-based architecture: GameObjects + Scripts + Prefabs.
- Core gameplay revolves around waves of enemies (Heli, Ship, PropPlane), a player ship, allies, projectiles, pickups, and a state-machine governing enemy behavior.

##### File structure
Top-level structure under Assets:
– Ally, Enemy, Player, Barrier, Projectiles, Pickups (game entities & behaviors)
– WaveManager & WaveObject (wave/spawn logic)
– StateMachine (BaseState, StateMachine classes)
– GameManager (central orchestrator)
– WorldMovement, Paths (scene/world scrolling & path logic)
– Menus & UI (MainMenu, Buttons, ScoreCounter, HealthBar, WeaponUpgradeCounter)
– Effects, Sfx, AudioMixer (visual/audio feedback)
– TextMeshPro, Font (text rendering)
– Scenes/Stage1.unity (entry point)

##### Gather additional insights
- The README only identifies project name.
- The use of a StateMachine folder shows that entities use a state-pattern.
- Prefab hierarchies define visual/physics/rend er setup; scripts add logic.

##### Main components & relationships
– Scene Management
– Physics, Rendering, Audio, Input subsystems
b. Scenes
– Stage1.unity loads on play
– MainMenu.unity for UI
c. Game Loop & Orchestration
– GameManager: initializes systems, listens for game state changes
– WaveManager + WaveObject: defines waves, spawns entities
– WorldMovement + Paths: scrolls background, moves entities along paths
d. Entity Layer (all game actors)
– Player (PlayerBehaviour, HealthObject, WeaponStats, Animator)
– Allies (AllyBehaviour)
– Enemies: Heli, Ship, PropPlane – each using a StateMachine (Fly, Shoot, Die, Despawn states)
– Projectiles (ProjectileBehaviour, MissleBehaviour)
– Barriers & Damageable interface
– Pickups (Score, WeaponUpgrade)
e. UI Layer
– HealthBar, ScoreCounter, WeaponUpgradeCounter
– Menus (Buttons, SceneChanger)
f. Effects & Resources
– Particle/Explosion/Smoke prefabs
– Sfx & AudioMixer
– Materials, Textures, Sprites, Fonts (TextMeshPro)

##### Architectural patterns & design principles
- Component-based design: scripts attach to prefabs, making reusable behaviors.
- State Pattern for enemy AI via StateMachine/BaseState.
- MVC-style separation in UI: Counters & Panels observe game events.
- Single GameManager as facade for high-level control.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Unity Engine"
        direction TB
        Physics["Physics Subsystem"]:::engine
        Rendering["Rendering Subsystem"]:::engine
        AudioSys["Audio Subsystem"]:::engine
        InputSys["Input Subsystem"]:::engine
        SceneMgr["Scene Manager"]:::engine
    end

    subgraph "Scenes"
        direction TB
        Stage1["Stage1.unity"]:::resource
        MainMenu["MainMenu.unity"]:::resource
    end

    subgraph "Managers & Controllers"
        direction TB
        GameMgr["GameManager"]:::controller
        WaveMgr["WaveManager"]:::controller
        WaveObj["WaveObject Definitions"]:::controller
        WorldMover["WorldMovement (Mover)"]:::controller
        WorldObj["WorldMovementObject"]:::controller
        Paths["Paths"]:::controller
    end

    subgraph "Entity Layer"
        direction TB
        PlayerCluster["Player"]:::entity
        AllyCluster["Ally"]:::entity
        subgraph "Enemies"
            direction TB
            Heli["Heli"]:::entity
            Ship["Ship"]:::entity
            PropPlane["PropPlane"]:::entity
            StateMachine["StateMachine"]:::controller
        end
        Projectiles["Projectiles"]:::entity
        Barrier["Barrier & IDamageable"]:::entity
        Pickups["Pickups"]:::entity
    end

    subgraph "UI Layer"
        direction TB
        HealthBar["HealthBar"]:::ui
        ScoreCounter["ScoreCounter"]:::ui
        WeaponUpgradeCounter["WeaponUpgradeCounter"]:::ui
        Buttons["UI Buttons & SceneChanger"]:::ui
    end

    subgraph "Effects & Resources"
        direction TB
        VFX["Visual Effects"]:::resource
        SFX["Audio & SFX"]:::resource
        Background["Background Materials & Scrolling"]:::resource
        TextMeshPro["TextMeshPro Resources"]:::resource
    end

    %% Connections
    SceneMgr -->|loads| MainMenu
    SceneMgr -->|loads| Stage1

    InputSys -->|player input| PlayerCluster
    InputSys -->|button input| Buttons

    GameMgr --> WaveMgr
    GameMgr --> WorldMover
    GameMgr --> HealthBar
    GameMgr --> ScoreCounter
    GameMgr --> WeaponUpgradeCounter

    WaveMgr -->|spawns| EnemyLayer[Enemies]
    WaveMgr -->|spawns| AllyCluster
    WaveMgr -->|spawns| Projectiles

    WorldMover --> Background
    Paths --> EnemyLayer

    EnemyLayer -->|uses| StateMachine
    Projectiles --|collides|--> EnemyLayer
    Projectiles --|collides|--> PlayerCluster
    Projectiles --|collides|--> Barrier
    Barrier -->|implements| IDamageable[IDamageable]

    Buttons -->|scene change| SceneMgr
    HealthBar -->|updates via| PlayerCluster
    ScoreCounter -->|updates via| EnemyLayer
    WeaponUpgradeCounter -->|updates via| Pickups

    PlayerCluster --> VFX
    EnemyLayer --> VFX
    Projectiles --> VFX

    PlayerCluster --> SFX
    EnemyLayer --> SFX

    %% Click Events
    click Stage1 "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Scenes/Stage1.unity"
    click MainMenu "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Menus/MainMenu.unity"
    click GameMgr "https://github.com/azivast/state-based-skyforce/blob/main/Assets/GameManager.cs"
    click WaveMgr "https://github.com/azivast/state-based-skyforce/blob/main/Assets/WaveManager/WaveManager.cs"
    click WaveObj "https://github.com/azivast/state-based-skyforce/blob/main/Assets/WaveObject/WaveObject.cs"
    click WorldMover "https://github.com/azivast/state-based-skyforce/blob/main/Assets/WorldMovement/Mover.cs"
    click WorldObj "https://github.com/azivast/state-based-skyforce/blob/main/Assets/WorldMovement/WorldMovementObject.cs"
    click Paths "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Paths/Path.cs"
    click Paths "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Paths/Node.cs"
    click BaseState "https://github.com/azivast/state-based-skyforce/blob/main/Assets/StateMachine/BaseState.cs"
    click StateMachine "https://github.com/azivast/state-based-skyforce/blob/main/Assets/StateMachine/StateMachine.cs"
    click PlayerCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Player/PlayerBehaviour.cs"
    click PlayerCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Player/Player.prefab"
    click PlayerCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Player/PlayerAnimator.controller"
    click PlayerCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Player/HealthObect/PlayerHealthObject.cs"
    click PlayerCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Player/WeaponStatsObject.cs"
    click AllyCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Ally/AllyBehaviour.cs"
    click AllyCluster "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Ally/Ally.prefab"
    click Heli "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Enemies/Heli/HeliBehaviour.cs"
    click Ship "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Enemies/Ship/ShipBehaviour.cs"
    click PropPlane "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Enemies/Prop Plane/PropPlaneBehaviour.cs"
    click Projectiles "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Projectiles/ProjectileBehaviour.cs"
    click Barrier "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Damageable/IDamageable.cs"
    click Pickups "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Pickups/Pickup.cs"
    click HealthBar "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Healthbar/HealthBar.cs"
    click ScoreCounter "https://github.com/azivast/state-based-skyforce/blob/main/Assets/ScoreCounter/ScoreCounter.cs"
    click WeaponUpgradeCounter "https://github.com/azivast/state-based-skyforce/blob/main/Assets/WeaponUpgradeCounter/WeaponUpgradeCounter.cs"
    click Buttons "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Menus/Buttons/SceneChanger.cs"
    click VFX "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Effects/Explosion.prefab"
    click VFX "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Effects/Smoke.prefab"
    click SFX "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Sfx/DeleteAfterAudio.cs"
    click Background "https://github.com/azivast/state-based-skyforce/blob/main/Assets/Background/ImageScroller.cs"

    %% Styles
    classDef engine fill:#bbbbbb,stroke:#333,stroke-width:1px;
    classDef controller fill:#a0c4ff,stroke:#333,stroke-width:1px;
    classDef entity fill:#caffbf,stroke:#333,stroke-width:1px;
    classDef ui fill:#ffd6a5,stroke:#333,stroke-width:1px;
    classDef resource fill:#fdffb6,stroke:#333,stroke-width:1px;
```
