Exemple #1
0
        public void SaveBombs()
        {
            // Create a new data structure for our saving.
            Bomb_Data data = new Bomb_Data();

            // Save the data.
            data.bombAmount = bombAmount;
            // Turn the data into Json data.
            string bombToJson = JsonUtility.ToJson(data);

            // Save this information.
            PlayerPrefs.SetString("Bombs", bombToJson);
        }
Exemple #2
0
        private void LoadBombs()
        {
            // Get the encrypted information.
            string bombJson = PlayerPrefs.GetString("Bombs");

            // IF we have a null or empty string.
            if (String.IsNullOrEmpty(bombJson))
            {
                // We do nothing.
                return;
            }
            // Cast the Json data to our Bomb_Data.
            Bomb_Data data = JsonUtility.FromJson <Bomb_Data> (bombJson);

            // Set the amount of bombs we have.
            bombAmount = data.bombAmount;
        }