示例#1
0
        private void TryUpTheLevel()
        {
            var userCurrency = UserInventory.Instance.Balance?.Find(currency => _targetCurrency.Sku == currency.Sku);

            if (userCurrency == null)
            {
                Debug.Log("UserInventory does not contain required currency");
                return;
            }

            if (userCurrency.Amount >= LevelUpPrice)
            {
                var levelUpPayment = new InventoryItemModel()
                {
                    Name = _targetCurrency.Name,
                    Sku  = _targetCurrency.Sku,
                };

                Action onSuccessConsume = () =>
                {
                    _characterLevel++;
                    SaveLevel(_characterLevelEntry, _characterLevel);
                    ShowLevel(_characterLevel);

                    if (UserInventory.IsExist)
                    {
                        UserInventory.Instance.Refresh(onError: StoreDemoPopup.ShowError);
                    }
                };

                if (DemoMarker.IsInventoryPartAvailable)
                {
                    DemoInventory.Instance.ConsumeInventoryItem(
                        levelUpPayment,
                        (int)LevelUpPrice,
                        onSuccess: _ => onSuccessConsume.Invoke(),
                        onError: _ => Debug.Log("Could not consume virtual currency"));
                }
                else
                {
                    Debug.LogError("Character level up supposed to be hidden in case InventoryDemo was not provided");
                }
            }
            else
            {
                var errorMessage = "Not enough currency amount to up the level";
                Debug.Log(errorMessage);
                StoreDemoPopup.ShowWarning(new Error(errorMessage: errorMessage));
            }
        }
 private void OnTimerEnd()
 {
     StoreDemoPopup.ShowWarning(
         error: new Error(errorMessage: "Code expired"),
         buttonCallback: OnResendButton);
 }