Server: Post Score (fixme, not usable currently)

parent c9e2e08a
...@@ -26,7 +26,6 @@ namespace Assets.Scripts.API ...@@ -26,7 +26,6 @@ namespace Assets.Scripts.API
public void GetScores() public void GetScores()
{ {
StartCoroutine(GetScoresAsync()); StartCoroutine(GetScoresAsync());
Debug.Log("Done.");
} }
IEnumerator GetScoresAsync() { IEnumerator GetScoresAsync() {
...@@ -42,6 +41,25 @@ namespace Assets.Scripts.API ...@@ -42,6 +41,25 @@ namespace Assets.Scripts.API
} }
} }
public void PostScore(int score, String playerName, String playerTeam = null)
{
//TODO (Fixme) How can I use Server.PostScore()
StartCoroutine(PushScoreAsync(score, playerName, playerTeam));
}
IEnumerator PushScoreAsync(int score, String playerName, String playerTeam) {
WWWForm form = new WWWForm();
form.AddField("name", playerName);
form.AddField("team", playerTeam);
form.AddField("score", score);
WWW w = new WWW(HOST_DEV + "/score/", form);
yield return w;
if (!string.IsNullOrEmpty(w.error)) {
print(w.error);
}
}
[Serializable] [Serializable]
public class ScoresRes { public class ScoresRes {
public string status; public string status;
......
...@@ -50,3 +50,4 @@ public class HighScores : MonoBehaviour { ...@@ -50,3 +50,4 @@ public class HighScores : MonoBehaviour {
SceneManager.LoadScene("Menu"); SceneManager.LoadScene("Menu");
} }
} }
\ No newline at end of file
...@@ -34,6 +34,8 @@ namespace Assets.Scripts ...@@ -34,6 +34,8 @@ namespace Assets.Scripts
{ {
if (PlayerPrefs.GetInt("highscore") < Score) if (PlayerPrefs.GetInt("highscore") < Score)
PlayerPrefs.SetInt("highscore", Score); PlayerPrefs.SetInt("highscore", Score);
Server server = GetComponent(typeof(Server)) as Server;
server.PostScore(Score, "PLN", "iGEM IONIS");
SceneManager.LoadScene("GameOver"); SceneManager.LoadScene("GameOver");
} }
if (Progression == 25) if (Progression == 25)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment