|
|
@@ -68,6 +68,10 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
public string answer;
|
|
|
public string id;
|
|
|
public string category;
|
|
|
+ public int r;
|
|
|
+ public int g;
|
|
|
+ public int b;
|
|
|
+ public int a;
|
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
|
@@ -290,6 +294,7 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
List<KeyValuePair<string, string>> returnList = new List<KeyValuePair<string, string>>();
|
|
|
|
|
|
WWWForm form = new WWWForm();
|
|
|
+ form.AddField("f", "GetGameInfo");
|
|
|
form.AddField("gameId", gameId);
|
|
|
|
|
|
string response = CallOnlineDatabaseWithResponse("OnlineGameInfo.php", form);
|
|
|
@@ -579,36 +584,33 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public List<QuestionCard> GetPlayerQuestions(int gameId, string playerNameValue) {
|
|
|
+ public List<QuestionCard> GetPlayerQuestions(int gameId, string playerName) {
|
|
|
List<QuestionCard> questions = new List<QuestionCard>();
|
|
|
+ WWWForm form = new WWWForm();
|
|
|
+ form.AddField("f", "PlayerQuestions");
|
|
|
+ form.AddField("gameId", gameId);
|
|
|
+ form.AddField("userName", playerName);
|
|
|
|
|
|
- /*
|
|
|
- if (connectionType.Equals("Local")) {
|
|
|
- string sql = "SELECT * FROM questions inner join questionToCategory on questions.id = questionToCategory.questionId INNER JOIN category ON category.id = questionToCategory.categoryId WHERE questions.id IN ( SELECT questionId FROM usersLockedQuestions WHERE gameId = " + gameId + " AND playerName = '" + playerNameValue + "') ORDER BY answer ASC";
|
|
|
- IDbConnection conn = new SqliteConnection(databaseUrl);
|
|
|
- conn.Open();
|
|
|
- IDbCommand cmd = conn.CreateCommand();
|
|
|
- cmd.CommandText = sql;
|
|
|
+ string response = CallOnlineDatabaseWithResponse("OnlineGameInfo.php", form);
|
|
|
+ response = "{\"questionsList\" : [ " + response + " ]}";
|
|
|
|
|
|
- IDataReader reader = cmd.ExecuteReader();
|
|
|
- while (reader.Read()) {
|
|
|
- GameObject question = Instantiate(questionCardPrefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
|
|
|
- QuestionCard q = question.GetComponent<QuestionCard>();
|
|
|
+ Questions ql = new Questions();
|
|
|
|
|
|
- q.SetAnswerText(reader.GetInt32(2).ToString());
|
|
|
- q.SetQuestionText(reader.GetString(1));
|
|
|
- q.idString = reader.GetInt32(0).ToString();
|
|
|
- Color32 questionCategoryColor = new Color32((byte)reader.GetInt32(7), (byte)reader.GetInt32(8), (byte)reader.GetInt32(9), (byte)reader.GetInt32(10));
|
|
|
+ JsonUtility.FromJsonOverwrite(response, ql);
|
|
|
|
|
|
- q.SetQuestionCategoryColor(questionCategoryColor);
|
|
|
+ foreach (Question q in ql.questionsList) {
|
|
|
+ GameObject question = Instantiate(questionCardPrefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
|
|
|
+ QuestionCard qc = question.GetComponent<QuestionCard>();
|
|
|
|
|
|
- questions.Add(q);
|
|
|
- }
|
|
|
- cmd.Dispose();
|
|
|
- conn.Close();
|
|
|
+ qc.SetAnswerText(q.answer);
|
|
|
+ qc.SetQuestionText(q.question);
|
|
|
+ qc.idString = q.category;
|
|
|
+
|
|
|
+ Color32 questionCategoryColor = new Color32((byte)q.r, (byte)q.g, (byte)q.b, (byte)q.a);
|
|
|
+ qc.SetQuestionCategoryColor(questionCategoryColor);
|
|
|
+
|
|
|
+ questions.Add(qc);
|
|
|
}
|
|
|
- */
|
|
|
- // TODO Fix online call to question
|
|
|
return questions;
|
|
|
}
|
|
|
|