Server: PostScore

parent 0fa7e1df
No preview for this file type
...@@ -41,23 +41,13 @@ namespace Assets.Scripts.API ...@@ -41,23 +41,13 @@ namespace Assets.Scripts.API
} }
} }
public void PostScore(int score, String playerName, String playerTeam = null) public static 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(); WWWForm form = new WWWForm();
form.AddField("name", playerName); form.AddField("name", playerName);
form.AddField("team", playerTeam); form.AddField("team", playerTeam);
form.AddField("score", score); form.AddField("score", score);
WWW www = new WWW(HOST_PROD + "/score/", form);
WWW w = new WWW(HOST_DEV + "/score/", form);
yield return w;
if (!string.IsNullOrEmpty(w.error)) {
print(w.error);
}
} }
[Serializable] [Serializable]
......
...@@ -34,9 +34,8 @@ namespace Assets.Scripts ...@@ -34,9 +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