Exemplo n.º 1
0
    IEnumerator UploadUserItem(string email)
    {
        inFirst = true;
        WWW       www;
        Hashtable postHeader = new Hashtable();

        postHeader.Add("Content-Type", "application/json");

        UserEmail ue = new UserEmail();

        ue.setEmail(email);
        // convert json string to byte
        string json     = JsonUtility.ToJson(ue);
        var    formData = System.Text.Encoding.UTF8.GetBytes(json);

        Debug.Log("1");
        www = new WWW("http://localhost:8080/api/getItems", formData, postHeader);

        yield return(www);

        Debug.Log("ITEM LIST");
        Debug.Log(www.text);
        items = JsonUtility.FromJson <Items>(www.text);
        foreach (Item item in items.userItemList)
        {
            Debug.Log(item.itemName);
            itemList.Add(item.itemName);
        }
        Debug.Log("END");
        inFirst = false;
    }
Exemplo n.º 2
0
    IEnumerator UploadUserHeroes(string email)
    {
        //inFirst = true;
        WWW       www;
        Hashtable postHeader = new Hashtable();

        postHeader.Add("Content-Type", "application/json");

        UserEmail ue = new UserEmail();

        ue.setEmail(email);
        // convert json string to byte
        string json     = JsonUtility.ToJson(ue);
        var    formData = System.Text.Encoding.UTF8.GetBytes(json);

        Debug.Log("8719236");
        www = new WWW("http://localhost:8080/api/getHeroesByUser", formData, postHeader);

        yield return(www);

        userHeroesObject = JsonUtility.FromJson <UserHeroes>(www.text);
        Debug.Log("HERE LIST");
        Debug.Log(www.text);
        foreach (HeroCustom heroCustom in userHeroesObject.userHeroes)
        {
            Debug.Log("ID HEROES");
            Debug.Log(heroCustom.levelPath);
            heroesList.Add(heroCustom.heroId);
        }
        Debug.Log(heroesList[0]);
        Debug.Log(heroesList[1]);
        Debug.Log("END LIST");
        //inFirst = false;
    }
Exemplo n.º 3
0
    IEnumerator UploadUserItem(string email)
    {
        WWW       www;
        Hashtable postHeader = new Hashtable();

        postHeader.Add("Content-Type", "application/json");

        UserEmail ue = new UserEmail();

        ue.setEmail(email);
        // convert json string to byte
        string json     = JsonUtility.ToJson(ue);
        var    formData = System.Text.Encoding.UTF8.GetBytes(json);

        www = new WWW("http://localhost:8080/api/getItems", formData, postHeader);

        yield return(www);

        //location = (Location)JsonUtility.FromJson<Location>(www.downloadHandler.text);
        items = (Items)JsonUtility.FromJson <Items>(www.text);

        //Debug.Log(items[0].name);
    }