private void NotifyOnCurrencyChanged(float before, CurrencyDecorator after)
 {
     if (OnCurrencyChanged != null)
     {
         OnCurrencyChanged(before, after);
     }
 }
 private void OnPlayerCurrencyChanged(float amountBefore, CurrencyDecorator decorator)
 {
     if (currentBlueprint != null)
     {
         SetCraftingBlueprint(currentBlueprint);
     }
 }
        public CurrencyDecorator ToCurrencyDecorator()
        {
            var dec = new CurrencyDecorator();

            ToCurrencyDecorator(dec);
            return(dec);
        }
Exemple #4
0
        public static bool RemoveCurrency(CurrencyDecorator decorator, float amountMultipier = 1.0f)
        {
            if (decorator.amount <= 0f)
            {
                return(true);
            }

            return(RemoveCurrency(decorator.currency.ID, decorator.amount * amountMultipier));
        }
Exemple #5
0
        /// <summary>
        /// Can we remove the amount of given currency?
        /// </summary>
        /// <param name="currencyDecorator"></param>
        /// <param name="allowCurrencyConversion">Allow converting a higher currency down to this currency? For example convert gold to silver.</param>
        /// <param name="checkBank"></param>
        /// <returns></returns>
        public static bool CanRemoveCurrency(CurrencyDecorator currencyDecorator, bool allowCurrencyConversion, bool checkBank)
        {
            if (currencyDecorator.amount <= 0f)
            {
                return(true);
            }

            Assert.IsNotNull(currencyDecorator.currency, "Currency decorator is empty! The currency cannot be removed!");
            return(CanRemoveCurrency(currencyDecorator.currency.ID, currencyDecorator.amount, allowCurrencyConversion, checkBank));
        }
        private void OnPlayerCurrencyChanged(float amountBefore, CurrencyDecorator decorator)
        {
            if (window.isVisible == false)
            {
                return;
            }

            if (window.isVisible)
            {
                RepaintWindow();
            }
        }
        private void LootUIOnOnCurrencyChanged(float before, CurrencyDecorator after)
        {
            var lookup = currencies.FirstOrDefault(o => o.currency == after.currency);

            if (lookup != null)
            {
                lookup.amount = after.amount;
            }

            if (lootUI.isEmpty)
            {
                trigger.UnUse();

                if (_destroyWhenEmpty)
                {
                    Destroy(gameObject);
                }
            }
        }
Exemple #8
0
        public void Repaint(CurrencyDecorator decorator)
        {
            SetActive(true);

            if (_amount != null)
            {
                if (decorator.amount <= 0f && _hideWhenEmpty)
                {
                    _amount.gameObject.SetActive(false);
                }

                _amount.text = decorator.ToString(1.0f, _overrideStringFormat ? _overrideStringFormatString : "");
            }

            if (_icon != null)
            {
                if (decorator.amount <= 0f && _hideWhenEmpty)
                {
                    _icon.gameObject.SetActive(false);
                }

                _icon.sprite = decorator.currency.icon;
            }
        }
 private void OnPlayerCurrencyChanged(float amountBefore, CurrencyDecorator decorator)
 {
     Repaint();
 }
Exemple #10
0
 /// <summary>
 /// Add currency to the loot to collections.
 /// Note: Currency is auto. converted if it's exceeding the conversion restrictions.
 /// </summary>
 /// <param name="decorator"></param>
 /// <param name="amountMultipier"></param>
 /// <returns></returns>
 public static bool AddCurrency(CurrencyDecorator decorator, float amountMultipier = 1.0f)
 {
     return(AddCurrency(decorator.currency.ID, decorator.amount * amountMultipier));
 }
Exemple #11
0
 public static bool CanAddCurrency(CurrencyDecorator currencyDecorator)
 {
     return(CanAddCurrency(currencyDecorator.currency.ID, currencyDecorator.amount));
 }
 public void ToCurrencyDecorator(CurrencyDecorator dec)
 {
     dec.currency = ItemManager.database.currencies.FirstOrDefault(o => o.ID == currencyID);
     dec.amount   = amount;
 }
 public CurrencyDecoratorSerializationModel(CurrencyDecorator currency)
     : this(currency.currency.ID, currency.amount)
 {
 }
 public void RemoveCurrency(CurrencyDecorator decorator)
 {
     lookups.Remove(decorator);
 }
 public void AddCurrency(CurrencyDecorator decorator)
 {
     decorator.parentGroup = this;
     lookups.Add(decorator);
 }