Example #1
0
    private IEnumerator GetPlayerScore()
    {
        WWWForm form = new WWWForm();

        form.AddField("name", _master.getName());

        UnityWebRequest request = UnityWebRequest.Post(link + "/score/getByName", form);

        request.SetRequestHeader("Authorization", _master.getToken());

        yield return(request.SendWebRequest());

        if (request.isNetworkError)
        {
            Debug.Log(request.error);
        }
        else
        {
            if (_master.finalScore > int.Parse(request.downloadHandler.text))
            {
                ownHighscore.text = _master.finalScore.ToString();
                StartCoroutine(UpdatePlayerScore());
            }
            else
            {
                ownHighscore.text = request.downloadHandler.text;
                StartCoroutine(GetMaxScore());
            }
        }
    }
Example #2
0
    private IEnumerator GetUpgrades()
    {
        WWWForm form = new WWWForm();

        form.AddField("name", _masterCounter.getName());

        UnityWebRequest request = UnityWebRequest.Post(link + "/player/getUpgrades", form);

        request.SetRequestHeader("Authorization", _masterCounter.getToken());

        yield return(request.SendWebRequest());

        if (request.isNetworkError)
        {
            Debug.Log(request.error);
        }
        else
        {
            JSONObject json = JSONObject.Parse(request.downloadHandler.text);
            GetUpgrades(json.GetArray("upgrades"));
        }
    }