Пример #1
0
    private IEnumerator OnResponse(WWW req, showIdList show)
    {
        int t_scr = 0;

        yield return(req);

        //responseText.text = req.text;

        JSONNode data = JSON.Parse(req.text);

        //List<string> parsedData = new List<string>();
        //List<int> postScores = new List<int>();

        foreach (JSONNode post in data["result"]["posts"])
        {
            string message = post["message"].Value;
            string account = post["account"]["name"].Value;
            score = post["score"].AsInt;
            //Debug.Log("Account name: " + account + "; Caption: " + message + "; Score: " + score);

            //postScores.Add(score);
            //parsedData.Add("Account name: " + account + "; Caption: " + message + "; Score: " + score);

            t_scr += score;
            //Debug.Log(" + " + score + ", total score: " + t_scr);
        }

        if (req.isDone == true)
        {
            Debug.Log("Data downloaded.");
            totalScore = t_scr;
        }

        if (totalScore > 1000)
        {
            Debug.Log("End total score: " + totalScore);
            loading.SetActive(false);
            loadingBox.SetActive(false);

            int m_totalScore = Mathf.Clamp(totalScore, 0, maxScr);
            Debug.Log("Constrained total score: " + m_totalScore);

            if (totalScore > maxScr)
            {
                Debug.Log("total score is bigger!!!!!!!!!!");
            }

            ManagerScript.instance.ResetWorlds();
            ManagerScript.instance.RevealItems(m_totalScore, threshold, parent, tempType);
            //ManagerScript.instance.RevealItems(totalScore, threshold, parent, tempType);
        }
    }
Пример #2
0
    public void Request(showIdList show, string startDate, string endDate)
    {
        WWWForm form = new WWWForm();
        Dictionary <string, string> headers = form.headers;

        headers["x-api-token"] = API_TOKEN;
        WWW request = new WWW(POSTS_ENDPOINT
                              + "?startDate=" + startDates[s_dropdown.value]
                              + "&endDate=" + endDates[e_dropdown.value]
                              + "&sortBy=" + sortBy
                              + "&listIds=" + this.show.Id
                              + "&count=" + count,
                              null, headers);

        //Debug.Log("Show id :" + this.show.Id);
        Debug.Log(request.url);
        Debug.Log("Data requested!");
        StartCoroutine(OnResponse(request, show));
        StartCoroutine(DayCounter(startDate, endDate));
    }