public void OnClick() { UserItemStock userItems = new UserItemStock(); userItems.Load(); if (userItems.HaveBuy(ItemAlias[0])) { messagePopup.Show("You have bought this Item!"); } else { if (Payment == PaymentType.Gem) { confirmationPopup.Show(IconItem.sprite, Name, textPrice.text + " Pearls", YesToBuy, NoToBuy); } else if (Payment == PaymentType.Gold) { confirmationPopup.Show(IconItem.sprite, Name, textPrice.text + " Coins", YesToBuy, NoToBuy); } } }
private void YesToBuy() { UserStockData userStock = UserStockData.Load(); UserItemStock userItems = new UserItemStock(); userItems.Load(); if (Payment == PaymentType.Gem) { if (userStock.PlusMinGem(-Price)) { for (int i = 0; i < ItemAlias.Length; i++) { userItems.Add(ItemAlias); } messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_ITEM"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); if (UserItemStock.Items.Contains(ItemAlias[0])) { textPrice.text = "Bought"; EffectedItem.SetActive(true); } } else { messagePopup.Show("You need " + (Price - userStock.Gems) + " more pearls!"); } } else if (Payment == PaymentType.Gold) { if (userStock.PlusMinGold(-Price)) { for (int i = 0; i < ItemAlias.Length; i++) { userItems.Add(ItemAlias[i]); } messagePopup.Show("You have bought " + Name); string command = "{"; command += "action:BUY_ITEM"; command += ",item:" + Name; command += "}"; ServerStatistic.DoRequest(command); if (UserItemStock.Items.Contains(ItemAlias[0])) { textPrice.text = "Bought"; EffectedItem.SetActive(true); } //gameObject.SetActive(!UserItemStock.Items.Contains(ItemAlias[0])); } else { messagePopup.Show("You need " + (Price - userStock.Gold) + " more coins!"); } } }