Skip to content
This repository has been archived by the owner on Dec 28, 2019. It is now read-only.

Commit

Permalink
Funktionierendes "Score-Submiting"
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed May 29, 2017
1 parent 21ab185 commit 070c4e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1155,12 +1155,12 @@ Prefab:
- target: {fileID: 224902029835350780, guid: f6748a010e46d4334a2b9717aa34b24d,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 158.38164
value: 159.62134
objectReference: {fileID: 0}
- target: {fileID: 224902029835350780, guid: f6748a010e46d4334a2b9717aa34b24d,
type: 2}
propertyPath: m_AnchoredPosition.y
value: 0
value: -216.5
objectReference: {fileID: 0}
- target: {fileID: 224902029835350780, guid: f6748a010e46d4334a2b9717aa34b24d,
type: 2}
Expand Down Expand Up @@ -1882,12 +1882,12 @@ Prefab:
- target: {fileID: 224902029835350780, guid: f6748a010e46d4334a2b9717aa34b24d,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 158.38164
value: 159.62134
objectReference: {fileID: 0}
- target: {fileID: 224902029835350780, guid: f6748a010e46d4334a2b9717aa34b24d,
type: 2}
propertyPath: m_AnchoredPosition.y
value: 0
value: -141.5
objectReference: {fileID: 0}
- target: {fileID: 224902029835350780, guid: f6748a010e46d4334a2b9717aa34b24d,
type: 2}
Expand Down
22 changes: 17 additions & 5 deletions Platformer_001/Assets/Scripts/Bestenliste/Bestenliste.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Runtime.InteropServices.ComTypes;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
Expand Down Expand Up @@ -33,26 +31,40 @@ private void Start()
StartCoroutine(GetRank());
}

public IEnumerator Submit()
public void Submit()
{
// TODO: Implement submitting score
btnSubmit.interactable = false;
btnSubmit.GetComponentInChildren<Text>().text = "...";
StartCoroutine(SubmitNow());
}

public IEnumerator SubmitNow()
{
btnSubmit.interactable = false;
btnSubmit.GetComponentInChildren<Text>().text = "...";

print("Submitting score: " + score + " (" + nameInput.text + ")");
WWWForm form = new WWWForm();
var form = new WWWForm();
form.AddField("name", nameInput.text);
form.AddField("score", score);
form.AddField("scoreConfirmationString", scoreConfirmation);
var myWr = UnityWebRequest.Post(serverAdress + "/" + submitAdress, form);

yield return myWr.Send();

Debug.Log("Submiting.");

if (myWr.isError)
{
Debug.LogError("Submit has failed.");
}
else
{
print(myWr.responseCode);
print(myWr.downloadHandler.text);
PlayerPrefs.SetInt("maxSubmitedEndlosweite", score);
CheckSubmitable();
StartCoroutine(SetupBestenliste());
}
}

Expand Down

0 comments on commit 070c4e2

Please sign in to comment.