public void EndGameMessageReceived(Player winner) { debugOut("Endgame Message Received"); mainGame.GeneralMessageQueue.Enqueue("Game Over!"); client.frameEndgame.populate(); client.frameController.activate(client.frameEndgame); if (winner.ID == clientData.CurrentPlayer.ID) { AudioHelper.play(ContentStore.soundVictory); } Thread.Sleep(3000); int maxScore = -1; PlayerContainer winners = new PlayerContainer(); foreach (Score score in network.Scores.GetAllScores()) { if (maxScore == -1 || score.Value > maxScore) { maxScore = score.Value; } } foreach (Score score in network.Scores.GetAllScores()) { if (score.Value == maxScore) { winners.AddPlayer(network.Players.GetPlayerByID(score.ID)); } } String message = ""; if (winners.GetPlayers().Count == 1) { message = winners.GetPlayers()[0].Name + " won with a score of " + maxScore + "!"; } else if (winners.GetPlayers().Count == 2) { message = winners.GetPlayers()[0].Name + " and " + winners.GetPlayers()[1].Name + " drew with a score of " + maxScore + "!"; } else if (winners.GetPlayers().Count > 2) { for (int i = 0; i < winners.GetPlayers().Count - 1; i++) { message += winners.GetPlayers()[i].Name + ", "; } message += " and " + winners.GetPlayers()[winners.GetPlayers().Count - 1].Name + " drew with a score of " + maxScore + "!"; } mainGame.GeneralMessageQueue.Enqueue(message); }
public void EndGame() { network.SendEndGameMessage(winner); if (MainGame.Instance.HostOnly) { MainGame.Instance.GeneralMessageQueue.Enqueue("Game over!"); } Thread.Sleep(3000); int maxScore = -1; PlayerContainer winners = new PlayerContainer(); foreach (Score score in network.Scores.GetAllScores()) { if (maxScore == -1 || score.Value > maxScore) { maxScore = score.Value; } } foreach (Score score in network.Scores.GetAllScores()) { if (score.Value == maxScore) { winners.AddPlayer(network.Players.GetPlayerByID(score.ID)); } } String message = ""; if (winners.GetPlayers().Count == 1) { message = winners.GetPlayers()[0].Name + " won with a score of " + maxScore + "!"; } else if (winners.GetPlayers().Count == 2) { message = winners.GetPlayers()[0].Name + " and " + winners.GetPlayers()[1].Name + " drew with a score of " + maxScore + "!"; } else if (winners.GetPlayers().Count > 2) { for (int i = 0; i < winners.GetPlayers().Count - 1; i++) { message += winners.GetPlayers()[i].Name + ", "; } message += " and " + winners.GetPlayers()[winners.GetPlayers().Count - 1].Name + " drew with a score of " + maxScore + "!"; } if (MainGame.Instance.HostOnly) { MainGame.Instance.GeneralMessageQueue.Enqueue(message); } }