public void BuyItemTest() { AppId.AppName app = AppId.AppName.CounterStrikGlobalOffensive; List <ItemOnSale> itemsOnSale = InventoryOnSale.GetInventoryOnSale(app, 1, "", 0, 0.01, InventoryOnSale.SortBy.Price, InventoryOnSale.SortOrder.Asc, InventoryOnSale.ThreeChoices.NotImportant, InventoryOnSale.ThreeChoices.NotImportant, InventoryOnSale.ThreeChoices.NotImportant, InventoryOnSale.ResultsPerPage.R30, InventoryOnSale.ThreeChoices.False); if (itemsOnSale.Count > 0) { ItemOnSale item = itemsOnSale[0]; List <BoughtItem> boughtItems = Purchase.BuyItem(app, new List <string> { item.ItemId }, new List <double> { item.Price.Value }, false, false); string itemId = boughtItems[0].ItemId; Assert.AreEqual(item.ItemId, itemId); } Assert.IsTrue(true); }
public void PurchaseItem(string itemName) { bool wasPurchased = StoreManager.Instance.PurchaseItem(itemName); ItemOnSale purchasedItem = ItemOnSale.None; if (wasPurchased) { purchaseItemSound.Play(); switch (itemName) { case "Winchester": purchasedItem = ItemOnSale.Winchester; itemPurchaseButtons[(int)purchasedItem].interactable = false; itemPrices[(int)purchasedItem].SetActive(false); break; case "Snake Oil": purchasedItem = ItemOnSale.SnakeOil; break; case "Bait": purchasedItem = ItemOnSale.Bait; break; } switch (purchasedItem) { case ItemOnSale.SnakeOil: case ItemOnSale.Bait: int currentAmount = PlayerManager.Instance.GetItemAmount(itemName); int maxAmount = PlayerManager.Instance.GetItemMaxAmount(itemName); consumablesAmountText[(int)purchasedItem].text = currentAmount.ToString() + "/" + maxAmount.ToString(); if (currentAmount == maxAmount) { itemPurchaseButtons[(int)purchasedItem].interactable = false; itemPrices[(int)purchasedItem].SetActive(false); } break; default: break; } currencyText.text = PlayerManager.Instance.Currency.ToString(); itemPurchasingText.text = purchasingPanelTexts[0]; } else { notPurchaseItemSound.Play(); if (PlayerManager.Instance.Currency >= StoreManager.Instance.GetItemPrice(itemName)) { itemPurchasingText.text = purchasingPanelTexts[2]; } else { itemPurchasingText.text = purchasingPanelTexts[1]; } } }