コード例 #1
0
    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();
    }