Home > Software engineering >  Where to store the values of coins and experience points?
Where to store the values of coins and experience points?

Time:05-27

please tell me where you need to store coins and experience points, for example, I have passed the level I am credited with both coins and points, I want to add them with the values that I already have. Do I need to create a class with static variables where they will be stored or create a table with points in the database (SQLITE) where each user will have the number of coins and experience points?

CodePudding user response:

Use PlayerPrefs:

PlayerPrefs.SetInt("Coin", coin); // e.g set data

var loadCoin = PlayerPrefs.GetInt("Coin"); // e.g load data

CodePudding user response:

You could create a class LevelRewardConfig

    public class LevelRewardConfig
    {
         public int coins;
         public int exp;
    }

And another class which store a list of LevelRewardConfig, it can be MonoBehaviour or ScriptableObject.

  • Related