/// <summary> /// Geeft score/doet dingen als het antwoord correct is. /// </summary> private void CorrectAnswer(PictureBox pb, Image img) { if (dmxcon.dmx.IsOpen) { dmxeffects.correctanswer(4, LightFixt(), "on"); } MethodInvoker Label = delegate { GameManager.Score += 400; VraagLabel.Text = "Correct! + 200 score"; VraagLabel.ForeColor = Green; pb.Image = img; }; Invoke(Label); Thread.Sleep(1000); if (dmxcon.dmx.IsOpen) { dmxeffects.correctanswer(4, LightFixt(), "off"); } MethodInvoker Next = delegate { TriviaInitialize(); }; Invoke(Next); MethodInvoker Label2 = delegate { VraagLabel.Text = Question[0].ToUpper(); VraagLabel.ForeColor = Yellow; }; Invoke(Label2); if (answeredquestions < 3) { return; } MethodInvoker Control = delegate { w5.CancelAsync(); w7.CancelAsync(); Controller.DisconnectGamepad(); ControlScherm obj = new ControlScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }; Invoke(Control); }
private void RestartGame_Click(object sender, EventArgs e) { Hide(); Controller.DisconnectGamepad(); StartScherm obj = new StartScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }
/// <summary> /// Invoke New Form, dit is nodig omdat deze method gecalled wordt vanuit de Gamepad thread. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StartButton_Click(object sender, MouseEventArgs e) { GameManager.Score = 1000; GameManager.Time = 0; GameManager.Fouten = 0; Trivia.Bombs[0] = false; Trivia.Bombs[1] = false; Trivia.Bombs[2] = false; MethodInvoker startForm = delegate { w1.CancelAsync(); //Kill Gamepad Listener Backgroundworker Controller.DisconnectGamepad(); //Kill Gamepad Backgroundworker ControlScherm obj = new ControlScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }; Invoke(startForm); }
private void GetColor(object sender, DoWorkEventArgs e) { while (AntiDouble == false) { if (!GameManager.PreviousColors.Contains(GameManager.Color) && GameManager.Colors.Contains(GameManager.Color)) { if (GameManager.Color == "Blue") { Trivia.Bombs[0] = true; GameManager.PreviousColors.Add("Blue"); } if (GameManager.Color == "Green") { GameManager.PreviousColors.Add("Green"); Trivia.Bombs[1] = true; } if (GameManager.Color == "Yellow") { GameManager.PreviousColors.Add("Yellow"); Trivia.Bombs[2] = true; } if (GameManager.Color == "Red" && Trivia.Bombs[0] && Trivia.Bombs[1] && Trivia.Bombs[2]) { dmxeffects.bombsdone(4, 3); DisplayEndscreen = true; GameManager.PreviousColors.Add("Yellow"); } if (GameManager.Color == "Red" && Trivia.Bombs.Contains(false)) { return; } if (w8.CancellationPending == true) //Check for Cancellation Request { e.Cancel = true; break; } break; } } if (DisplayEndscreen) { GameManager.KeepCounting = false; w6.CancelAsync(); MethodInvoker EindForm = delegate { Hide(); Controller.DisconnectGamepad(); Socket.DisconnectStream(); w8.CancelAsync(); EindScherm obj = new EindScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }; Invoke(EindForm); return; } if (AntiDouble || DisplayEndscreen) { return; } Controller.DisconnectGamepad(); Socket.DisconnectStream(); MethodInvoker startForm = delegate { Hide(); w8.CancelAsync(); KeuzeScherm obj = new KeuzeScherm(); Hide(); obj.Closed += (s, args) => Close(); obj.Show(); }; Invoke(startForm); return; }