Exemple #1
0
        private void InitializeData(bool reset)
        {
            var str   = Prefs.GetString(Key);
            var fresh = reset || string.IsNullOrEmpty(str);

            if (!fresh)
            {
                _data = JsonUtility.FromJson <CurrencyModifier>(str);
            }
            else
            {
                _data = new CurrencyModifier
                {
                    Total    = StartAmount,
                    Lifetime = StartAmount
                }
            };

            var force = ForceAmount;

            if (Prefs.HasKey(LegacyKey))
            {
                force = Prefs.GetInt(LegacyKey);
                Prefs.DeleteKey(LegacyKey);
            }
            if (force >= 0)
            {
                _data.Total = (ulong)force;
            }
            _dirty = fresh || force >= 0;
            UpdateTracking();
        }