Save
Saves System
Overview
The Saves system is responsible for managing the saving and loading of game data in the Candy Merge game. This includes handling the storage and retrieval of player preferences and game state using various save mechanisms. The system ensures that game data is persisted correctly and can be retrieved when needed.
Classes
SaveManager
Manages saving and loading game data using a specified save system. This class is a singleton that handles the overall save and load operations, ensuring that data is stored and retrieved correctly.
Key Responsibilities:
Initializing Save System: Initializes the save system on awake.
Saving Data: Provides methods to save data as different types (string, int, float).
Loading Data: Provides methods to load data as different types (string, int, float).
Example Use Cases
Saving Game Data: The SaveManager class provides methods to save game data, such as player progress or settings, using a specified save system.
Loading Game Data: The SaveManager class provides methods to load game data, ensuring that the game state is restored correctly when the player returns.
PlayerPrefsSave
Handles saving and loading player data using Unity's PlayerPrefs. This class implements the ISave interface and provides methods to store and retrieve data using PlayerPrefs.
Key Responsibilities:
Saving Data: Saves data to PlayerPrefs based on the data type (string, int, float).
Loading Data: Loads data from PlayerPrefs based on the data type (string, int, float).
Example Use Cases
Saving Player Preferences: The PlayerPrefsSave class saves player preferences, such as audio settings or control configurations, using PlayerPrefs.
Loading Player Preferences: The PlayerPrefsSave class loads player preferences, ensuring that the settings are restored correctly when the game starts.
Data
Represents a data object containing a key-value pair to be saved. This class is used to encapsulate the data that needs to be stored or retrieved.
Key Responsibilities:
Storing Key-Value Pairs: Encapsulates the key-value pairs to be saved or loaded.
Example Use Cases
Creating Data Objects: The Data class is used to create data objects that contain the key-value pairs to be saved or loaded by the save system.
ISave
An interface that defines the methods for saving and loading data. This interface is implemented by classes that handle the actual storage and retrieval of data.
Key Responsibilities:
Defining Save Methods: Provides method signatures for saving data.
Defining Load Methods: Provides method signatures for loading data.
Example Use Cases
Implementing Save Systems: The ISave interface is implemented by classes like PlayerPrefsSave to handle the actual saving and loading of data.
By using the Saves system, you can manage the persistence of game data in the Candy Merge game, ensuring that player progress and settings are stored and retrieved correctly, providing a seamless and consistent gameplay experience for players.
Last updated