Ejemplo n.º 1
0
        public IEnumerator LoadPurchasedItems(string roomID)
        {
            if (storeDataObjects == null)
            {
                WWWForm form = new WWWForm();
                form.AddField("userID", roomID);
                form.AddField("storeType", 0);
                UnityWebRequest www = UnityWebRequest.Post("https://circles-parellano.herokuapp.com/api/get-purchased-items", form);
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    string response = www.downloadHandler.text;
                    yield return(response);

                    storeDataObjects = new List <StoreItem>();
                    storeDataSkins   = new List <StoreItem>();
                    StoreResponse fullData = JsonUtility.FromJson <StoreResponse>(response);
                    foreach (StoreItem item in fullData.data)
                    {
                        if (item.type == "skin")
                        {
                            // CharacterChangeScript.AddToCharacterObjects(item.type == "skin", item);
                            CharacterCustomizer.AddAvailableItems(item);
                        }
                        else if (item.type == "object")
                        {
                            GameObject currentAsset = Resources.Load <GameObject>("StoreItems/" + item.location) as GameObject;
                            fullItemList.Add(currentAsset);
                        }
                    }
                    GameObject[] prevItems = Resources.LoadAll <GameObject>("TownPrefabs") as GameObject[];
                    foreach (GameObject prevItem in prevItems)
                    {
                        fullItemList.Add(prevItem);
                    }
                    uiManagerScript.ActivateEditing();
                }
            }
        }
Ejemplo n.º 2
0
        public IEnumerator LoadPurchasedItems(string roomID)
        {
            if (storeDataObjects == null)
            {
                WWWForm form = new WWWForm();
                form.AddField("userID", roomID);
                form.AddField("storeType", 0);
                UnityWebRequest www = UnityWebRequest.Post("https://circles-parellano.herokuapp.com/api/get-purchased-items", form);
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    string response = www.downloadHandler.text;
                    yield return(response);

                    storeDataObjects = new List <StoreItem>();
                    storeDataSkins   = new List <StoreItem>();
                    StoreResponse fullData = JsonUtility.FromJson <StoreResponse>(response);
                    foreach (StoreItem item in fullData.data)
                    {
                        if (item.type == "skin" || item.type == "accessory")
                        {
                            CharacterChangeScript.AddToCharacterObjects(item.type == "skin", item);
                        }
                        else
                        {
                            storeDataObjects.Add(item);
                        }
                    }
                    uiManagerScript.ActivateEditing();
                }
            }
        }