byte[] IShopWebServiceContract.BuyItem(byte[] data)
        {
            try
            {
                using (var bytes = new MemoryStream(data))
                {
                    var itemId       = Int32Proxy.Deserialize(bytes);
                    var authToken    = StringProxy.Deserialize(bytes);
                    var currencyType = EnumProxy <UberStrikeCurrencyType> .Deserialize(bytes);

                    var durationType = EnumProxy <BuyingDurationType> .Deserialize(bytes);

                    var itemType = EnumProxy <UberStrikeItemType> .Deserialize(bytes);

                    var marketLocation = EnumProxy <BuyingLocationType> .Deserialize(bytes);

                    var recommendationType = EnumProxy <BuyingRecommendationType> .Deserialize(bytes);

                    BuyItemResult result = OnBuyItem(itemId, authToken, currencyType, durationType, itemType, marketLocation, recommendationType);
                    using (var outBytes = new MemoryStream())
                    {
                        EnumProxy <BuyItemResult> .Serialize(outBytes, result);

                        return(outBytes.ToArray());
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to handle BuyItem request:");
                Log.Error(ex);
                return(null);
            }
        }
Example #2
0
        private void OnPurchaseDone(CocoStoreItemData itemData, BuyItemResult result, Action <BuyItemResult> doneAction)
        {
            if (doneAction != null)
            {
                doneAction(result);
            }

            if (result.resultCode != BuyItemResultCode.Success)
            {
                return;
            }

            UpdateItemPurchaseState(itemData, true);
            RefreshNoAdsState();

            StoreUpdateStateSignal.Dispatch();
        }
Example #3
0
        public override bool TakeAction()
        {
            var shopcfg = new ShareCacheStruct <Config_Shop>().FindKey(_id);

            if (shopcfg == null)
            {
                return(false);
            }


            float discount = shopcfg.Discount / 10.0f;
            int   needCoin = Convert.ToInt32(shopcfg.Price * discount) * _num;


            if (shopcfg.CurrencyType == CoinType.Diamond)
            {
                if (GetBasis.DiamondNum < needCoin)
                {
                    receipt = BuyItemResult.NoDiamond;
                    return(true);
                }
                else
                {
                    UserHelper.ConsumeDiamond(Current.UserId, needCoin);
                }
            }
            else if (shopcfg.CurrencyType == CoinType.CombatCoin)
            {
                if (GetCombat.CombatCoin < needCoin)
                {
                    receipt = BuyItemResult.NoCombatGold;
                    return(true);
                }
                else
                {
                    UserHelper.ConsumeCombatCoin(Current.UserId, needCoin);
                }
            }

            UserHelper.RewardsItem(Current.UserId, shopcfg.ItemID, _num);

            receipt = BuyItemResult.Successfully;
            return(true);
        }
Example #4
0
        private void OnIAPPurchaseDone(PurchaseIAPResult iapResult)
        {
            if (!IsAutoRestoreInProgress)
            {
                return;
            }

            var itemKey  = PSDKBilling.GetMainId(iapResult.purchasedItem.id);
            var itemData = StoreConfigData.GetItemData(itemKey);

            if (itemData == null)
            {
                return;
            }

            var resultCode    = (iapResult.result == PurchaseIAPResultCode.Success) ? BuyItemResultCode.Success : BuyItemResultCode.InAppPurchaseFailed;
            var buyItemResult = new BuyItemResult(resultCode, iapResult);

            OnPurchaseDone(itemData, buyItemResult, null);
        }
Example #5
0
        public BuyItemResult BuyFundDriver(int fundDriverId)
        {
            if (Items.Length < fundDriverId)
            {
                throw new InvalidOperationException(string.Format("Fund driver {0} not found", fundDriverId));
            }
            var           fundDriver = Items[fundDriverId];
            BuyItemResult result     = null;

            if (!IsFundsDriverAvailableForBuy(fundDriver))
            {
                throw new InvalidOperationException(string.Format("Fund driver {0} not available to buy ", fundDriverId));
            }
            if (GameCash.CashOnHand >= fundDriver.Price)
            {
                PayWithFunds(fundDriver.Price);
                fundDriver.Price = fundDriver.Price +
                                   fundDriver.Price * fundDriver.InflationPercent / 100.0m;
                fundDriver.Bought++;
                var changedCounters = IncrementCounters(fundDriver.Incrementors);
                PerformBuyFundDriverCustomRule(fundDriver);
                result = new BuyItemResult
                {
                    ModifiedItem     = fundDriver,
                    ModifiedGameCash = new GameCash
                    {
                        Counters    = changedCounters,
                        CashOnHand  = GameCash.CashOnHand,
                        TotalEarned = GameCash.TotalEarned,
                        RootCounter = GameCash.RootCounter
                    }
                };
                ModifiedFundsDrivers[fundDriverId] = fundDriver;
            }
            PostBuyFundDriver(fundDriver);
            return(result);
        }
    // Token: 0x06000C96 RID: 3222 RVA: 0x00054F20 File Offset: 0x00053120
    private static void HandleBuyItem(IUnityItem item, BuyItemResult result, bool autoEquip)
    {
        BuyPanelGUI._isBuyingItem = false;
        switch (result)
        {
        case BuyItemResult.OK:
            UnityRuntime.StartRoutine(Singleton <InventoryManager> .Instance.StartUpdateInventoryAndEquipNewItem(item, autoEquip));
            break;

        case BuyItemResult.DisableInShop:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisItemCannotBeRented, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        default:
            if (result != BuyItemResult.InvalidLevel)
            {
                PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.DataError, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            }
            else
            {
                PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.YourLevelIsTooLowToBuyThisItem, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            }
            break;

        case BuyItemResult.DisableForRent:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisItemCannotBeRented, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.DisableForPermanent:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisItemCannotBePurchasedPermanently, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.DurationDisabled:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisItemCannotBePurchasedForDuration, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.PackDisabled:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisPackIsDisabled, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.IsNotForSale:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisItemIsNotForSale, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.NotEnoughCurrency:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.YouDontHaveEnoughPointsOrCreditsToPurchaseThisItem, PopupSystem.AlertType.OKCancel, new Action(BuyPanelGUI.HandleWebServiceError), LocalizedStrings.OkCaps, new Action(ApplicationDataManager.OpenBuyCredits), "GET CREDITS");
            break;

        case BuyItemResult.InvalidMember:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.AccountIsInvalid, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.InvalidExpirationDate:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, string.Format(LocalizedStrings.YouCannotPurchaseThisItemForMoreThanNDays, item.View.MaxDurationDays), PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.AlreadyInInventory:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.YouAlreadyOwnThisItem, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.InvalidAmount:
        {
            int maxOwnableAmount = (item.View as UberStrikeItemQuickView).MaxOwnableAmount;
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, string.Format(LocalizedStrings.TheAmountYouTriedToPurchaseIsInvalid, maxOwnableAmount), PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;
        }

        case BuyItemResult.NoStockRemaining:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.ThisItemIsOutOfStock, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;

        case BuyItemResult.InvalidData:
            PopupSystem.ShowMessage(LocalizedStrings.ProblemBuyingItem, LocalizedStrings.InvalidData, PopupSystem.AlertType.OK, new Action(BuyPanelGUI.HandleWebServiceError));
            break;
        }
        PanelManager.Instance.ClosePanel(PanelType.BuyItem);
    }