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()); } } }
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")); } }