Esempio n. 1
0
        /// <summary>
        /// Set the saved properties to perferences within the context of the specified GameItem.
        /// </summary>
        /// Save / SaveBest mode of 'Always' will cause XxAmount(Best) be copied to the corresponding saved
        /// variables before saving to prefs, other modes of updating the should be triggered coopied.
        public void UpdatePlayerPrefs()
        {
            if (Configuration.CounterType == CounterConfiguration.CounterTypeEnum.Int)
            {
                if (Configuration.Save != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetInt(_prefsKey, IntAmountSaved);       // CI = CounterInt)
                }
                if (Configuration.SaveBest != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetInt(_prefsKeyBest, IntAmountBestSaved);  // CIH = CounterIntHighest)
                }
            }
            else
            {
                if (Configuration.Save != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetFloat(_prefsKey, FloatAmountSaved);
                }

                if (Configuration.SaveBest != CounterConfiguration.SaveType.None)
                {
                    PreferencesFactory.SetFloat(_prefsKeyBest, FloatAmountBestSaved);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Update PlayerPrefs with values that should be saved.
 /// </summary>
 /// Note: This does not call PreferencesFactory.Save()
 /// <param name="prefix"></param>
 /// <param name="useSecurePrefs"></param>
 public void UpdatePlayerPrefs(string prefix = "", bool?useSecurePrefs = null)
 {
     foreach (var variable in BoolVariables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetBool(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
     foreach (var variable in FloatVariables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetFloat(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
     foreach (var variable in IntVariables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetInt(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
     foreach (var variable in StringVariables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetString(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
     foreach (var variable in Vector2Variables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetVector2(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
     foreach (var variable in Vector3Variables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetVector3(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
     foreach (var variable in ColorVariables)
     {
         if (variable.PersistChanges)
         {
             PreferencesFactory.SetColor(prefix + variable.Tag, variable.Value, useSecurePrefs);
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Save GameManager state
        /// </summary>
        public override void SaveState()
        {
            MyDebug.Log("GameManager: SaveState");

            PreferencesFactory.SetInt("TimesPlayedForRatingPrompt", TimesPlayedForRatingPrompt);
            PreferencesFactory.SetInt("TimesGamePlayed", TimesGamePlayed);
            PreferencesFactory.SetInt("TimesLevelsPlayed", TimesLevelsPlayed);

            PreferencesFactory.SetFloat("BackGroundAudioVolume", BackGroundAudioVolume, false);
            PreferencesFactory.SetFloat("EffectAudioVolume", EffectAudioVolume, false);

            PreferencesFactory.Save();
        }