|
|
@@ -57,9 +57,11 @@ public class Database : MonoBehaviour {
|
|
|
internal void SetupNewOnlineGame(int limitPerQuestion, int limitPerPlayer, int toWin, List<InviteSearchResult> inviteUsers) {
|
|
|
List<int> playerIds = new List<int>();
|
|
|
inviteUsers.ForEach(i => playerIds.Add(i.GetId()));
|
|
|
- playerIds.Add(Database.Instance.GetSignedInUser());
|
|
|
+ int currentUser = Database.Instance.GetSignedInUser();
|
|
|
+ playerIds.Add(currentUser);
|
|
|
|
|
|
var form = new WWWForm();
|
|
|
+ form.AddField("currentUser", currentUser);
|
|
|
form.AddField("winNumber", toWin);
|
|
|
form.AddField("limitPerQuestion", limitPerQuestion);
|
|
|
form.AddField("limitPerPlayer", limitPerPlayer);
|
|
|
@@ -92,6 +94,7 @@ public class Database : MonoBehaviour {
|
|
|
public string startDate;
|
|
|
public string LastPlayedDate;
|
|
|
public string finishedDate;
|
|
|
+ public string status;
|
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
|
@@ -257,19 +260,26 @@ public class Database : MonoBehaviour {
|
|
|
return this.questionTimer;
|
|
|
}
|
|
|
|
|
|
- internal void GetOnlineGames(int userId) {
|
|
|
+ internal void GetOnlineGames(int userId, GameObject prefab) {
|
|
|
|
|
|
WWWForm formData = new WWWForm();
|
|
|
formData.AddField("userId", userId);
|
|
|
|
|
|
string response = CallOnlineDatabaseWithResponse("OnlineGames.php", formData);
|
|
|
|
|
|
- response = "{\"onlineGameList\" : [ " + response + " ]}";
|
|
|
+ response = "{\"onlineGamesList\" : [ " + response + " ]}";
|
|
|
|
|
|
OnlineGames og = new OnlineGames();
|
|
|
JsonUtility.FromJsonOverwrite(response, og);
|
|
|
|
|
|
+ GameObject onlineGameObject;
|
|
|
+ OnlineGameScript ogs = null;
|
|
|
+ foreach (OnlineGame game in og.onlineGamesList) {
|
|
|
+ onlineGameObject = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
|
|
|
+ ogs = onlineGameObject.GetComponent<OnlineGameScript>();
|
|
|
|
|
|
+ ogs.SetGameStatusText(game.status);
|
|
|
+ }
|
|
|
//TODO Continue development here
|
|
|
}
|
|
|
|