public void BuyCartItems() { if (!shoppingCart.activeSelf) { ToggleShoppingCart(); return; } if (total > money) { ToggleErrorLabel(); Invoke("ToggleErrorLabel", 2); return; } // we have to continuously take the first child because the indexes are resetting for (int i = 0; i < cartItems.Count;) { GameObject item = cartGrid.transform.GetChild(i).gameObject; store.ConvertToPlayerItem(item); RemoveItemFromTempCart(item); Grid.RemoveGrid(store.GridBG); Dictionary <string, object> entry = store.GetDictionary(store.List, item.name); #if UNITY_EDITOR Serializer.AddJSONItem(player.List, entry, player.Json); Serializer.RemoveJSONItem(store.List, entry, store.Json); #endif } CompleteTransaction("buy"); ToggleShoppingCart(); }
public void SellCartItems() { for (int i = 0; i < cartItems.Count;) { GameObject item = cartItems[i]; Debug.Log(item.name); store.ConvertToStoreItem(item); RemoveItemFromTempCart(item); Grid.RemoveGrid(player.GridBG); Dictionary <string, object> entry = store.GetDictionary(player.List, item.name); #if UNITY_EDITOR Serializer.AddJSONItem(store.List, entry, store.Json); Serializer.RemoveJSONItem(player.List, entry, player.Json); #endif } CompleteTransaction("sell"); player.ToggleBag(); store.scrollContainer.SetActive(true); }