|
|
@@ -442,6 +442,7 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
WWWForm form = new WWWForm();
|
|
|
form.AddField("f", "GetQuestionsLost");
|
|
|
form.AddField("userName", playerName);
|
|
|
+ form.AddField("gameId", gameId);
|
|
|
|
|
|
string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
|
|
|
if (response.Equals("")) {
|
|
|
@@ -546,7 +547,7 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
int gameId = GameObject.Find("GameManager").GetComponent<GameManagerScript>().GameId;
|
|
|
Color32 questionCategoryColor = new Color32(0, 0, 20, 20);
|
|
|
|
|
|
- StartCoroutine(GetQuestionData(false));
|
|
|
+ GetQuestionData(false);
|
|
|
NewQuestion q = NewQuestion.Instance();
|
|
|
q.questionString = questionString;
|
|
|
q.answerString = answerString;
|
|
|
@@ -611,30 +612,22 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
return questions;
|
|
|
}
|
|
|
|
|
|
- private IEnumerator GetQuestionData(bool showAnswer) {
|
|
|
- UnityWebRequest www = UnityWebRequest.Get("nordh.xyz/narKampen/dbFiles/Question.php");
|
|
|
-
|
|
|
- yield return www.SendWebRequest();
|
|
|
+ private void GetQuestionData(bool showAnswer) {
|
|
|
+ WWWForm form = new WWWForm();
|
|
|
|
|
|
- if (www.isNetworkError || www.isHttpError) {
|
|
|
- Debug.Log(www.error);
|
|
|
- } else {
|
|
|
- while (!www.isDone) {
|
|
|
- yield return null;
|
|
|
- }
|
|
|
+ string response = CallOnlineDatabaseWithResponse("Question.php", form);
|
|
|
+
|
|
|
// Show result
|
|
|
- string jsonData = www.downloadHandler.text;
|
|
|
|
|
|
- jsonData = "{\"questionsList\" : [ " + jsonData + " ]}";
|
|
|
+ response = "{\"questionsList\" : [ " + response + " ]}";
|
|
|
|
|
|
Questions qe = new Questions();
|
|
|
- JsonUtility.FromJsonOverwrite(jsonData, qe);
|
|
|
+ JsonUtility.FromJsonOverwrite(response, qe);
|
|
|
|
|
|
questionString = qe.questionsList[0].question;
|
|
|
answerString = qe.questionsList[0].answer;
|
|
|
idString = qe.questionsList[0].id;
|
|
|
categoryString = qe.questionsList[0].category;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public List<UserName> GetUsersToInvite(string searchString) {
|