Exemplo n.º 1
0
        /// <summary>
        /// This function adds a value to the current ammount;
        /// </summary>
        /// <param name="ToAdd">quantity to add</param>
        ///  /// <param name="ToAddLevel">level of the quantitie to add</param>
        public void Add(float ToAdd, eCurrencyLevels ToAddLevel)
        {
            if (!isInitialized)
            {
                ThrowInitializedError();
                return;
            }

            int distance = ToAddLevel - level;

            if (distance == 0)
            {
                ammount += ToAdd;
            }
            else if (distance == -1)
            {
                ammount += ToAdd / 1000;
            }
            else if (distance > 0)
            {
                ammount += ToAdd * (1000 * distance);
            }

            while (ammount > 1000)
            {
                level   += 1;
                ammount /= 1000;
            }

            SaveData();
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function substracts a value from the current ammount;
        /// </summary>
        /// <param name="ToAdd">Quantity to sustract</param>
        ///  /// <param name="ToAddLevel">level of the quantitie to be substracted</param>
        public void Substarct(float ToRemove, eCurrencyLevels ToAddLevel)
        {
            if (!isInitialized)
            {
                ThrowInitializedError();
                return;
            }

            int distance = ToAddLevel - level;

            if (distance == 0)
            {
                ammount -= ToRemove;
            }
            else if (distance < 0)
            {
                ammount -= ToRemove / (1000 * distance);
            }
            else if (distance > 0)
            {
                ammount -= ToRemove * (1000 * distance);
            }

            while (ammount > 0 && ammount < 1)
            {
                level   -= 1;
                ammount *= 1000;
            }

            SaveData();
        }
Exemplo n.º 3
0
 /// <summary>
 /// This function loads the data from a class that inherits from CurrencyDataSaver.
 /// </summary>
 /// <param name="SaverInjection">The saver to be used to I/O data</param>
 void Init(CurrencyDataSaver SaverInjection)
 {
     if (!isInitialized)
     {
         isInitialized = true;
         saver         = SaverInjection;
         ammount       = saver.LoadAmmount();
         level         = saver.LoadLevel();
     }
 }