예제 #1
0
 void TestForm_onMatchEnded(object sender, MatchEndedEventArgs e)
 {
     if (e.Match.Score1.Point > e.Match.Score2.Point)
         new WinForm("Le Joueur 1 a gagné !").ShowDialog();
     else if (e.Match.Score1.Point < e.Match.Score2.Point)
         new WinForm("Le Joueur 2 a gagné !").ShowDialog();
     else
         new WinForm("Egalite !").ShowDialog();
 }
예제 #2
0
 private void Pong_onMatchEnded(object sender, MatchEndedEventArgs e)
 {
     if (e.Match.Score1.Point > e.Match.Score2.Point)
         new WinForm("Le Joueur 1 a gagné !").ShowDialog();
     else if (e.Match.Score1.Point < e.Match.Score2.Point)
         new WinForm("Le Joueur 2 a gagné !").ShowDialog();
     else
         new WinForm("Egalite !").ShowDialog();
     this.Partie = false;
     this.TimerBalle.Stop();
     this.TimerBalle.Close();
     this.ScoreJoueur1 = new Score();
     this.ScoreJoueur2 = new Score();
     this.Jeu = new Jeu();
     this.Set = new Set();
     this.Match = new Match();
     this.CreateEnvironment();
     this.Parent.NouvellePartieMenuItem.IsEnabled = true;
     this.Parent.TerminerLaPartieMenuItem.IsEnabled = false;
     this.Parent.JoueursMenuItem.IsEnabled = true;
     this.Parent.DifficultéMenuItem.IsEnabled = true;
     if (!this.Parent.ManetteController.ManetteController.IsAlive)
     {
         this.Parent.ManetteController.ManetteController = new Thread(this.Parent.ManetteController.ManetteThread);
         this.Parent.ManetteController.ManetteController.Start();
     }
     if (this.Parent.ClavierMenuItem.IsChecked || this.Parent.ClavierMenuItem1.IsChecked)
         this.Parent.KeyDown -= new KeyEventHandler(this.Parent.canvas1_KeyDown);
     if (this.Parent.SourisMenuItem.IsChecked || this.Parent.SourisMenuItem1.IsChecked)
     {
         this.Parent.Canvas1.MouseDown -= new MouseButtonEventHandler(this.Parent.canvas1_MouseDown);
         this.Parent.Canvas1.MouseMove -= new MouseEventHandler(this.Parent.canvas1_MouseMove);
     }
     if (this.Parent.ManetteController.Manette1Controller.IsAlive)
         this.Parent.ManetteController.Manette1Controller.Abort();
     if (this.Parent.ManetteController.Manette2Controller.IsAlive)
         this.Parent.ManetteController.Manette2Controller.Abort();
     if (this.Parent.AiController.Ai1Controller.IsAlive)
         this.Parent.AiController.Ai1Controller.Abort();
     if (this.Parent.AiController.Ai2Controller.IsAlive)
         this.Parent.AiController.Ai2Controller.Abort();
 }
예제 #3
0
 private void TestForm_OnSetEnded(object sender, SetEndedEventArgs e)
 {
     if (e.Joueur == 1)
     {
         if (this.Match.Score1.Point == 3)
         {
             MatchEndedEventArgs meea = new MatchEndedEventArgs(this.Match);
             this.onMatchEnded(this, meea);
             this.Match.Score1.Point = 0;
         }
         else
         {
             this.Match.ListeSet.AddLast(new Set(e.Set));
             if (e.Set.Score1.Point > e.Set.Score2.Point)
                 this.Match.Score1.Point++;
             else if (e.Set.Score1.Point < e.Set.Score2.Point)
                 this.Match.Score2.Point++;
             else
                 this.Match.Score1.Point++;
         }
     }
     else
     {
         if (this.Match.Score2.Point == 3)
         {
             MatchEndedEventArgs meea = new MatchEndedEventArgs(this.Match);
             this.onMatchEnded(this, meea);
             this.Match.Score2.Point = 0;
         }
         else
         {
             this.Match.ListeSet.AddLast(new Set(e.Set));
             if (e.Set.Score1.Point > e.Set.Score2.Point)
                 this.Match.Score1.Point++;
             else if (e.Set.Score1.Point < e.Set.Score2.Point)
                 this.Match.Score2.Point++;
             else
                 this.Match.Score2.Point++;
         }
     }
     this.matchJoueur1ToolBox.Text = this.Match.Score1.Point.ToString();
     this.matchJoueur2ToolBox.Text = this.Match.Score2.Point.ToString();
 }
예제 #4
0
 private void Pong_OnSetEnded(object sender, SetEndedEventArgs e)
 {
     if (e.Joueur == 1)
     {
         if (this.Match.Score1.Point == 3)
         {
             MatchEndedEventArgs meea = new MatchEndedEventArgs(this.Match);
             this.onMatchEnded(this, meea);
             this.Match.Score1.Point = 0;
         }
         else
         {
             this.Match.ListeSet.AddLast(new Set(e.Set));
             if (e.Set.Score1.Point > e.Set.Score2.Point)
                 this.Match.Score1.Point++;
             else if (e.Set.Score1.Point < e.Set.Score2.Point)
                 this.Match.Score2.Point++;
             else
                 this.Match.Score1.Point++;
         }
     }
     else
     {
         if (this.Match.Score2.Point == 3)
         {
             MatchEndedEventArgs meea = new MatchEndedEventArgs(this.Match);
             this.onMatchEnded(this, meea);
             this.Match.Score2.Point = 0;
         }
         else
         {
             this.Match.ListeSet.AddLast(new Set(e.Set));
             if (e.Set.Score1.Point > e.Set.Score2.Point)
                 this.Match.Score1.Point++;
             else if (e.Set.Score1.Point < e.Set.Score2.Point)
                 this.Match.Score2.Point++;
             else
                 this.Match.Score2.Point++;
         }
     }
     this.ScoreTexteJoueur1.Texto = this.ScoreJoueur1.Point.ToString() + " - " +
         this.Jeu.Score1.Point.ToString() + " - " + this.Set.Score1.Point.ToString() + " - " +
         this.Match.Score1.Point.ToString();
     this.ScoreTexteJoueur2.Texto = this.ScoreJoueur2.Point.ToString() + " - " +
         this.Jeu.Score2.Point.ToString() + " - " + this.Set.Score2.Point.ToString() + " - " +
         this.Match.Score2.Point.ToString();
 }