public override IEnumerator GetMatchesBetween(string from_date, string to_date) { BackEndManager.Instance().IsMatchDataRecieved = false; BackEndManager.Instance().matchDatas.Clear(); string uri = BackEndManager.Instance().SQL_MATCH_BASE_URL + "Get?date1=" + from_date + "&date2=" + to_date; using (UnityWebRequest webRequest = UnityWebRequest.Get(uri)) { // Request and wait for the desired page. yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(uri + " Error: " + webRequest.error); } else { Debug.Log(uri + " Received: " + webRequest.downloadHandler.text); RootObject rawData = JsonUtility.FromJson <RootObject>("{\"rootData\":" + webRequest.downloadHandler.text + "}"); foreach (var Data in rawData.rootData) { if (Data.date_of_match != null) { BackEndManager.Instance().matchDatas.Add(Data); } } BackEndManager.Instance().IsMatchDataRecieved = true; } } }
public void ShowMyRankingList() { BackEndManager.Instance().matchDatas.Clear(); BackEndManager.Instance().playerDatas.Clear(); StartCoroutine(sQLWebClient.GetMatchesByPlayerID(GameLoader.playerID)); show = true; IsShowButtonPress = false; }
private void FixedUpdate() { if (BackEndManager.Instance().playerData.IsFound) { _login = true; } else { _login = false; } }
public override IEnumerator DeletePlayer(string username) { string uri = BackEndManager.Instance().SQL_PLAYER_BASE_URL + "Delete?username="******" Error: " + webRequest.error); } else { Debug.Log(uri); } }
public override IEnumerator DeleteMatch(int playerdata_idplayerdata) { string uri = BackEndManager.Instance().SQL_MATCH_BASE_URL + "Delete?playerid=" + playerdata_idplayerdata; UnityWebRequest webRequest = new UnityWebRequest(uri, "Delete"); // UnityWebRequest webRequest = UnityWebRequest.Delete(uri); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(uri + " Error: " + webRequest.error); } else { //Debug.Log(uri + " Received: " + webRequest.downloadHandler.text); Debug.Log("Deleted"); } }
public void ShowRankingList() { BackEndManager.Instance().matchDatas.Clear(); BackEndManager.Instance().playerDatas.Clear(); int from_year = Int32.Parse(dateYearFromInput.text); int from_month = Int32.Parse(dateMonthFromInput.text); int from_day = Int32.Parse(dateDayFromInput.text); int to_year = Int32.Parse(dateYearToInput.text); int to_month = Int32.Parse(dateMonthToInput.text); int to_day = Int32.Parse(dateDayToInput.text); DateTime from = new DateTime(from_year, from_month, from_day); DateTime to = new DateTime(to_year, to_month, to_day); StartCoroutine(sQLWebClient.GetMatchesBetween(from.ToString("yyyy-MM-dd"), to.ToString("yyyy-MM-dd"))); show = true; IsShowButtonPress = false; }
public void Update() { if (BackEndManager.Instance().IsMatchDataRecieved) { highScoreEntryList.Clear(); foreach (var matchData in BackEndManager.Instance().matchDatas) { StartCoroutine(sQLWebClient.GetPlayerByID(matchData.playerdata_idplayerdata)); } BackEndManager.Instance().IsMatchDataRecieved = false; } if (show && IsShowButtonPress) { foreach (Transform trans in entryContainer) { if (trans.name == "highScoreTemplate(Clone)") { Destroy(trans.gameObject); } } highScoreEntryList = new List <HighScoreEntry>(); highScoreEntryTransformList = new List <Transform>(); for (int i = 0; i < BackEndManager.Instance().matchDatas.Count(); i++) { HighScoreEntry entry = new HighScoreEntry(); entry.score = BackEndManager.Instance().matchDatas[i].score; entry.name = BackEndManager.Instance().playerDatas[i].username; highScoreEntryList.Add(entry); } foreach (HighScoreEntry highScoreEntry in highScoreEntryList) { CreateHighScoreEntryTransform(highScoreEntry, entryContainer, highScoreEntryTransformList); } show = false; IsShowButtonPress = false; } }
public override IEnumerator UpdatePlayerProfile(PlayerData PlayerData) { string uri = BackEndManager.Instance().SQL_PLAYER_BASE_URL + "Put"; string jsonData = JsonUtility.ToJson(PlayerData); UnityWebRequest webRequest = new UnityWebRequest(uri, "Put"); byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(jsonData); webRequest.uploadHandler = (UploadHandler) new UploadHandlerRaw(jsonToSend); webRequest.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); webRequest.SetRequestHeader("Content-Type", "application/json"); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(uri + " Error: " + webRequest.error); } else { Debug.Log(uri + " Received: " + webRequest.downloadHandler.text); } }
public override IEnumerator GetPlayerByUsername(string username) { BackEndManager.Instance().IsPlayerDataRecieved = false; string uri = BackEndManager.Instance().SQL_PLAYER_BASE_URL + "Get?username="******" Error: " + webRequest.error); } else { Debug.Log(uri + " Received: " + webRequest.downloadHandler.text); BackEndManager.Instance().playerData = JsonUtility.FromJson <PlayerData>(webRequest.downloadHandler.text); BackEndManager.Instance().IsPlayerDataRecieved = true; GameLoader.playerID = BackEndManager.Instance().playerData.idplayerdata; } } }
public override IEnumerator GetPlayerByID(int id) { BackEndManager.Instance().IsPlayerDataRecieved = false; string uri = BackEndManager.Instance().SQL_PLAYER_BASE_URL + "Get?playerid=" + id.ToString(); using (UnityWebRequest webRequest = UnityWebRequest.Get(uri)) { // Request and wait for the desired page. yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(uri + " Error: " + webRequest.error); } else { Debug.Log(uri + " Received: " + webRequest.downloadHandler.text); var temp = JsonUtility.FromJson <PlayerData>(webRequest.downloadHandler.text); BackEndManager.Instance().playerDatas.Add(temp); BackEndManager.Instance().IsPlayerDataRecieved = true; } } }