コード例 #1
0
    //public void PullManyFromGB(System.Action<bool, GBDataSingle> callback)
    //{
    //    int offset = Random.Range(0, (MAXNR - amtOfGamesToPull));
    //    StartCoroutine(PullFromGBCo(GAMESURL + "/?api_key=" + APIkey + "&offset=" + offset + urlPost, true, callback));
    //}

    public void GotData(bool b, GBDataSingle data)
    {
        FillGame(data.results);


        if (!pulledGames.Contains(data.results))
        {
            pulledGames.Add(data.results);
            StoreGameJson(data.results);
        }
    }
コード例 #2
0
    IEnumerator PullFromGBCo(string url, bool many, System.Action <bool, GBDataSingle> callback)
    {
        //  print("starting pull");
        using (WWW www = new WWW(url))
        {
            yield return(www);

            if (www.error != null)
            {
                Debug.LogError("HTML ERROR " + www.error + " " + www.responseHeaders);

                yield break;
            }


            //   print(www.text);

            if (www.text.Contains("Object Not Found"))
            {
                Debug.LogError("Object not found!");
                yield break;
            }



            GBDataSingle data = new GBDataSingle();
            data = JsonMapper.ToObject <GBDataSingle>(www.text);
            if (ErrorHandling(data))
            {
                // pulledData.Add(data);
                //   print(data.error + " " + data.status_code);
                print(data.results.name);

                //  print(data.results.characters);

                callback(true, data);
            }
            // print(game.name);
        }
    }