示例#1
0
        private void DrawPrice(VirtualCurrencyModel priceCurrency, uint price)
        {
            var currencyObject = Instantiate(VirtualCurrencyPrefab.gameObject, PriceTagPlacement);
            var currencyUI     = currencyObject.GetComponent <VirtualCurrencyBalanceUI>();

            currencyUI.Initialize(priceCurrency);
            currencyUI.SetBalance(price);
        }
示例#2
0
        private void InitializeUI()
        {
            _targetCurrency = GetTargetCurrency();

            if (_targetCurrency == null)
            {
                Debug.Log("Could not obtain target currency");
                LevelUpButton.onClick -= TryUpTheLevel;
                return;
            }

            EnableUI();

            _characterLevel = LoadLevel(_characterLevelEntry);
            ShowLevel(_characterLevel);
            DrawPrice(_targetCurrency, LevelUpPrice);
        }
        private VirtualCurrencyBalanceUI AddCurrency(VirtualCurrencyModel item)
        {
            if (item == null)
            {
                return(null);
            }
            if (_currencies.ContainsKey(item.Sku))
            {
                return(_currencies[item.Sku]);
            }
            if (string.IsNullOrEmpty(item.ImageUrl))
            {
                return(null);
            }
            var currencyBalance = Instantiate(virtualCurrencyBalanceProvider.GetValue(), transform);
            var balanceUi       = currencyBalance.GetComponent <VirtualCurrencyBalanceUI>();

            balanceUi.Initialize(item);
            _currencies.Add(item.Sku, balanceUi);
            return(balanceUi);
        }
 public void GetVirtualCurrencies(Action <List <VirtualCurrencyModel> > onSuccess, Action <Error> onError = null)
 {
     XsollaStore.Instance.GetVirtualCurrencyList(XsollaSettings.StoreProjectId, items =>
     {
         var currencies = items.items.ToList();
         if (currencies.Any())
         {
             var result = currencies.Select(c =>
             {
                 var model = new VirtualCurrencyModel();
                 FillItemModel(model, c);
                 return(model);
             }).ToList();
             onSuccess?.Invoke(result);
         }
         else
         {
             onSuccess?.Invoke(new List <VirtualCurrencyModel>());
         }
     }, onError);
 }
示例#5
0
        private VirtualCurrencyModel GetTargetCurrency()
        {
            var allCurrencies = UserCatalog.Instance.VirtualCurrencies;

            if (allCurrencies == null)
            {
                Debug.LogWarning("UserCatalog returned null as VirtualCurrencies");
                return(null);
            }

            VirtualCurrencyModel targetCurrency = null;

            if (!string.IsNullOrEmpty(CurrencySkuOrName))
            {
                targetCurrency = allCurrencies.Find(currency => { return(CurrencySkuOrName == currency.Sku || CurrencySkuOrName == currency.Name); });

                if (/*still*/ targetCurrency == null)
                {
                    Debug.LogWarning($"Could not find specified virtual currency: {CurrencySkuOrName}");

                    if (TryUseDefaultCurrencyOnFailure)
                    {
                        Debug.Log("Will try to get default project's currency");
                        targetCurrency = allCurrencies.Count > 0 ? allCurrencies[0] : null;
                    }
                }
            }
            else
            {
                targetCurrency = allCurrencies.Count > 0 ? allCurrencies[0] : null;
            }

            if (targetCurrency == null)
            {
                Debug.LogWarning("Could not find virtual currency");
            }

            return(targetCurrency);
        }