# Level

<figure><img src="/files/ywQO8S8kSfadFM0BU5aQ" alt=""><figcaption></figcaption></figure>

## Boxes Subsystem

### Overview

The Boxes subsystem is responsible for managing the box elements within the game. This includes defining the boundaries, visual elements, and interactions of the boxes. The system ensures that the boxes are correctly positioned and interact with other game elements as intended.

### Classes

#### Box

Singleton class that represents the Box in the level, including the collider and visual elements. This class handles the initialization and configuration of the box components, such as the BoxCollider2D, EdgeCollider2D, and LineRenderer.

**Key Responsibilities:**

* Setting the size and positions of the box components.
* Managing the visual representation of the box boundaries.
* Providing access to the box collider for other game elements.

## Buffer Subsystem

### Overview

The Buffer subsystem is responsible for managing the buffer UI in the game. This includes displaying the next candy object to be spawned and handling the animations and visibility of the buffer UI.

### Classes

#### BufferUI

Singleton class responsible for managing the buffer UI in the game. This class handles the initialization and configuration of the buffer UI components, such as the Image and Animator, and subscribes to relevant events to update the buffer display.

**Key Responsibilities:**

* Displaying the new candy in the buffer by updating the sprite and triggering the animation.
* Setting the visibility of the buffer UI in the editor.
* Subscribing to events to refresh the buffer display.

## Countdowns Subsystem

### Overview

The Countdowns subsystem is responsible for managing the countdown logic and synchronizing it with the animation. This includes handling the start and end of countdowns and updating the UI accordingly.

### Classes

#### Countdown

Singleton class that manages the countdown logic and synchronizes it with the animation. This class handles the initialization of the Animator component, subscribes to relevant events, and manages the lifecycle of the countdown.

**Key Responsibilities:**

* Initializing the Animator component.
* Subscribing to events for countdown begin and end.
* Handling the countdown process and updating the UI.

## Counters Subsystem

### Overview

The Counters subsystem is responsible for handling the logic for counting down when an object goes out of bounds. This includes starting and stopping the countdown, triggering particle effects, and updating the UI.

### Classes

#### Counter

Singleton class that handles the logic for counting down when an object goes out of bounds. This class manages the initialization of the Animator and TextMeshProUGUI components, subscribes to relevant events, and handles the countdown process.

**Key Responsibilities:**

* Handling the logic when a candy goes out of bounds.
* Starting and stopping the countdown process.
* Triggering particle effects and updating the UI.

## Popups Subsystem

### Overview

The Popups subsystem is responsible for handling the popup behavior for displaying candies in the UI. This includes setting the sprite, scale, and triggering the popup animation.

### Classes

#### Popup

Class that handles the popup behavior for displaying candies in the UI. This class manages the initialization of the Animator component, subscribes to relevant events, and handles the display of the popup.

**Key Responsibilities:**

* Displaying the popup with the given candy object.
* Setting the sprite and scale of the popup.
* Triggering the popup animation.

## Progressions Subsystem

### Overview

The Progressions subsystem is responsible for managing the progression of levels and handling thumbnail representations of candies. This includes setting up thumbnails, spawning thumbnails, and managing the progression logic.

### Classes

#### Progression

Singleton class that manages the progression of levels and handles thumbnail representations of candies. This class handles the initialization of the thumbnail components, subscribes to relevant events, and manages the progression logic.

**Key Responsibilities:**

* Setting up the thumbnails for candies in the progression.
* Spawning thumbnails for candies at specific positions and scales.
* Managing the progression logic and handling thumbnail representations.

## Scores Subsystem

### Overview

The Scores subsystem is responsible for managing the score UI, handling updates, and persistence of high scores. This includes displaying the current score, updating the high score, and saving/loading the score data.

### Classes

#### ScoreUI

Singleton class that manages the score UI, handling updates, and persistence of high scores. This class handles the initialization of the TextMeshProUGUI components, subscribes to relevant events, and manages the score data.

**Key Responsibilities:**

* Displaying the current score and high score.
* Updating the score and triggering score update animations.
* Saving and loading the score data.

By using these subsystems, you can manage the various aspects of the Candy Merge game, such as boxes, buffers, countdowns, counters, popups, progressions, and scores, providing a comprehensive and engaging gameplay experience for players.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://saitama-studio.gitbook.io/candy-merge/systems/level.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
