private void timer1_Tick(object sender, EventArgs e) { int elaspedSeconds = (int)(DateTime.Now - startTime).TotalSeconds; int remainingSeconds = TimerCountdown - elaspedSeconds; timerLabel.Text = String.Format("{0}", remainingSeconds); if (remainingSeconds <= 0 || client.CheckIfAllPlayersAnswered(CurrentGame.Instance.Game, currentRoundAction)) { CheckAllButtons(); timer1.Stop(); //Temp fix if (CurrentGame.Instance.Game.Players.First().Id == PlayerCredentials.Instance.Player.Id) { client.GetPlayerOrder(CurrentGame.Instance.Game, currentRoundAction); } PlayerOrder[] playerOrder = client.getGamePlayerOrder(CurrentGame.Instance.Game); var sortedList = playerOrder.OrderBy(x => x.Position).ToList(); timerLabel.Text = ""; int i = 1; foreach (PlayerOrder p in sortedList) { timerLabel.Text += string.Format("{0}. {1} ", i, p.Player.Name); i++; } if (CurrentGame.Instance.Game.Players.First().Id == PlayerCredentials.Instance.Player.Id) { client.SetMapStartTime(currentRoundAction); } this.Hide(); (new MapScreen(CurrentGame.Instance.Game)).Show(); } }
private void QuestionCountdown(object sender, EventArgs e) { if (QuestionCountdownCanRun) { int elaspedSeconds = (int)(DateTime.Now - startTime).TotalSeconds; int remainingSeconds = QuestionCountdownTimer - elaspedSeconds; StatusLabel.Text = String.Format("Time left to answer question: {0}", remainingSeconds); bool playersAnswered = Client.CheckIfAllPlayersAnswered(CurrentGame, CurrentRound); if (remainingSeconds <= 0 || playersAnswered) { Client.CreateRound(CurrentGame); EnableDisableButtons(false); CheckButton(); timer1.Stop(); startTime = DateTime.Now; QuestionCountdownCanRun = false; NextRoundCountdownCanRun = true; timer1.Start(); } } }