|
@@ -148,9 +148,9 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
public string lastPlayedDate;
|
|
public string lastPlayedDate;
|
|
|
public string finishedDate;
|
|
public string finishedDate;
|
|
|
public string status;
|
|
public string status;
|
|
|
- public int userId;
|
|
|
|
|
|
|
+ public string userId;
|
|
|
public string username;
|
|
public string username;
|
|
|
- public int userLockedQuestions;
|
|
|
|
|
|
|
+ public string userLockedQuestions;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[Serializable]
|
|
[Serializable]
|
|
@@ -299,12 +299,37 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
GameObject onlineGameObject;
|
|
GameObject onlineGameObject;
|
|
|
OnlineGameScript ogs = null;
|
|
OnlineGameScript ogs = null;
|
|
|
List<OnlineGameScript> games = new List<OnlineGameScript>();
|
|
List<OnlineGameScript> games = new List<OnlineGameScript>();
|
|
|
|
|
+ int gameId = -1;
|
|
|
|
|
+ string playerToAct = "";
|
|
|
|
|
+
|
|
|
foreach (OnlineGame game in og.onlineGamesList) {
|
|
foreach (OnlineGame game in og.onlineGamesList) {
|
|
|
- onlineGameObject = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
|
|
|
|
|
- ogs = onlineGameObject.GetComponent<OnlineGameScript>();
|
|
|
|
|
- ogs.CurrentPlayer = game.currentPlayer;
|
|
|
|
|
|
|
+ Int32.TryParse(game.id, out int currentGameId);
|
|
|
|
|
+ if (gameId != currentGameId) {
|
|
|
|
|
+ if (ogs != null) {
|
|
|
|
|
+ games.Add(ogs);
|
|
|
|
|
+ }
|
|
|
|
|
+ onlineGameObject = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
|
|
|
|
|
+ ogs = onlineGameObject.GetComponent<OnlineGameScript>();
|
|
|
|
|
+ gameId = currentGameId;
|
|
|
|
|
+
|
|
|
|
|
+ if (game.currentPlayer.Equals(game.userId)) {
|
|
|
|
|
+ playerToAct = game.username;
|
|
|
|
|
+ ogs.CurrentPlayer = game.username;
|
|
|
|
|
+ ogs.addPlayer(game.username);
|
|
|
|
|
+ ogs.SetGameStatus("YOUR_TURN");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ogs.addPlayer(game.username);
|
|
|
|
|
+ if (game.currentPlayer.Equals(game.userId)) {
|
|
|
|
|
+ ogs.SetGameStatus("YOUR_TURN");
|
|
|
|
|
+ playerToAct = game.username;
|
|
|
|
|
+ ogs.CurrentPlayer = game.username;
|
|
|
|
|
+ ogs.addPlayer(game.username);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ogs.SetGameStatus(game.status);
|
|
ogs.SetGameStatus(game.status);
|
|
|
- Int32.TryParse(game.id, out int gameId);
|
|
|
|
|
|
|
+ //ogs.CurrentPlayer = game.currentPlayer;
|
|
|
List<KeyValuePair<string, string>> playerInfos = GetGameInfo(gameId);
|
|
List<KeyValuePair<string, string>> playerInfos = GetGameInfo(gameId);
|
|
|
if (game.status.Equals("PENDING")) {
|
|
if (game.status.Equals("PENDING")) {
|
|
|
string extraInfo = "";
|
|
string extraInfo = "";
|
|
@@ -320,9 +345,9 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
ogs.SetGameStatusText(extraInfo);
|
|
ogs.SetGameStatusText(extraInfo);
|
|
|
|
|
|
|
|
} else if (game.status.Equals("OTHERS_TURN")) {
|
|
} else if (game.status.Equals("OTHERS_TURN")) {
|
|
|
- ogs.SetGameStatusText(game.playerToAct);
|
|
|
|
|
|
|
+ ogs.SetGameStatusText(ogs.CurrentPlayer);
|
|
|
} else if (game.status.Equals("ACTIVE")) {
|
|
} else if (game.status.Equals("ACTIVE")) {
|
|
|
- ogs.SetGameStatusText(game.playerToAct);
|
|
|
|
|
|
|
+ ogs.SetGameStatusText(ogs.CurrentPlayer);
|
|
|
} else {
|
|
} else {
|
|
|
ogs.SetGameStatusText();
|
|
ogs.SetGameStatusText();
|
|
|
}
|
|
}
|
|
@@ -335,10 +360,11 @@ public class OnlineDatabase : MonoBehaviour {
|
|
|
ogs.StartDate = game.startDate;
|
|
ogs.StartDate = game.startDate;
|
|
|
ogs.LastPlayedDate = game.lastPlayedDate;
|
|
ogs.LastPlayedDate = game.lastPlayedDate;
|
|
|
|
|
|
|
|
- games.Add(ogs);
|
|
|
|
|
ogs.PlayerInfos = playerInfos;
|
|
ogs.PlayerInfos = playerInfos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ games.Add(ogs);
|
|
|
|
|
+
|
|
|
return games;
|
|
return games;
|
|
|
}
|
|
}
|
|
|
|
|
|