private void TestForm_OnPointEnded(object sender, PointEndedEventArgs e)
 {
     if (e.Joueur == 1)
     {
         this.ScoreJoueur1.Point++;
         switch (this.ScoreJoueur1.Point)
         {
             case 0:
                 this.Jeu.Score1.Point = 0;
                 break;
             case 1:
                 this.Jeu.Score1.Point = 15;
                 break;
             case 2:
                 this.Jeu.Score1.Point = 30;
                 break;
             case 3:
                 this.Jeu.Score1.Point = 40;
                 break;
             case 4:
                 this.ScoreJoueur1 = new Score();
                 GameEndedEventArgs geea = new GameEndedEventArgs(1, this.Jeu);
                 this.OnGameEnded(this, geea);
                 this.Jeu.Score1.Point = 0;
                 break;
         }
     }
     else
     {
         this.ScoreJoueur2.Point++;
         switch (this.ScoreJoueur2.Point)
         {
             case 0:
                 this.Jeu.Score2.Point = 0;
                 break;
             case 1:
                 this.Jeu.Score2.Point = 15;
                 break;
             case 2:
                 this.Jeu.Score2.Point = 30;
                 break;
             case 3:
                 this.Jeu.Score2.Point = 40;
                 break;
             case 4:
                 this.ScoreJoueur2 = new Score();
                 GameEndedEventArgs geea = new GameEndedEventArgs(2, this.Jeu);
                 this.OnGameEnded(this, geea);
                 this.Jeu.Score2.Point = 0;
                 break;
         }
     }
     this.scoreJoueur1ToolBox.Text = this.ScoreJoueur1.Point.ToString();
     this.jeuJoueur1ToolBox.Text = this.Jeu.Score1.Point.ToString();
     this.scoreJoueur2ToolBox.Text = this.ScoreJoueur2.Point.ToString();
     this.jeuJoueur2ToolBox.Text = this.Jeu.Score2.Point.ToString();
 }
Exemple #2
0
 private void Pong_OnPointEnded(object sender, PointEndedEventArgs e)
 {
     if (e.Joueur == 1)
     {
         this.ScoreJoueur1.Point++;
         switch (this.ScoreJoueur1.Point)
         {
             case 0:
                 this.Jeu.Score1.Point = 0;
                 break;
             case 1:
                 this.Jeu.Score1.Point = 15;
                 break;
             case 2:
                 this.Jeu.Score1.Point = 30;
                 break;
             case 3:
                 this.Jeu.Score1.Point = 40;
                 break;
             case 4:
                 this.ScoreJoueur1 = new Score();
                 GameEndedEventArgs geea = new GameEndedEventArgs(1, this.Jeu);
                 this.OnGameEnded(this, geea);
                 this.Jeu.Score1.Point = 0;
                 break;
         }
     }
     else
     {
         this.ScoreJoueur2.Point++;
         switch (this.ScoreJoueur2.Point)
         {
             case 0:
                 this.Jeu.Score2.Point = 0;
                 break;
             case 1:
                 this.Jeu.Score2.Point = 15;
                 break;
             case 2:
                 this.Jeu.Score2.Point = 30;
                 break;
             case 3:
                 this.Jeu.Score2.Point = 40;
                 break;
             case 4:
                 this.ScoreJoueur2 = new Score();
                 GameEndedEventArgs geea = new GameEndedEventArgs(2, this.Jeu);
                 this.OnGameEnded(this, geea);
                 this.Jeu.Score2.Point = 0;
                 break;
         }
     }
     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();
 }
 private void gagneJoueur2Button_Click(object sender, RoutedEventArgs e)
 {
     PointEndedEventArgs peea = new PointEndedEventArgs(2);
     this.OnPointEnded(this, peea);
 }
Exemple #4
0
 private void OnTimedEvent(object sender, ElapsedEventArgs e)
 {
     if (this.AllerBalle)
     {
         if (this.Balle.Centre.X < this.Joueur2.Centre.X)
         {
             this.Balle.Centre = new Point(this.Balle.Centre.X + this.Balle.Rayon, this.Balle.Centre.Y + this.AngleBalle);
         }
         else
         {
             if (this.Balle.Centre.X == this.Joueur2.Centre.X)
             {
                 if ((this.Balle.Centre.Y >= this.Joueur2.Centre.Y) &&
                     (this.Balle.Centre.Y <= this.Joueur2.Centre.Y + this.Joueur2.Largeur))
                 {
                     this.AngleBalle += this.AngleJoueur2;
                     this.Balle.Centre = new Point(this.Balle.Centre.X - this.Balle.Rayon, this.Balle.Centre.Y + this.AngleBalle);
                     this.AllerBalle = false;
                     if (this.VibrationsJoueur2)
                     {
                         if (this.Parent.ManetteController.Manette2Controller.IsAlive)
                         {
                             this.Parent.ManetteController.Manette2.Vibrate(7500, 7500);
                             Thread.Sleep(150);
                             this.Parent.ManetteController.Manette2.Vibrate(0, 0);
                         }
                     }
                     if (this.Sons)
                     {
                         this.SoundPlayer.SoundLocation = @"Resources/4359__NoiseCollector__PongBlipF4.wav";
                         this.SoundPlayer.Play();
                     }
                 }
                 else
                 {
                     this.ServiceJoueur1 = true;
                     this.ServiceJoueur2 = false;
                     this.AllerBalle = true;
                     this.AngleBalle = 0;
                     this.AngleJoueur1 = 0;
                     this.AngleJoueur2 = 0;
                     this.TimerBalle.Enabled = false;
                     this.TimerBalle.Stop();
                     this.Balle.Centre = new Point(this.Joueur1.Centre.X + 10, this.Joueur1.Centre.Y);
                     PointEndedEventArgs peea = new PointEndedEventArgs(1);
                     this.OnPointEnded(this, peea);
                 }
                 this.UpButtonPressedJoueur1 = 0;
                 this.DownButtonPressedJoueur1 = 0;
             }
         }
     }
     else
     {
         if (this.Balle.Centre.X > 15)
         {
             this.Balle.Centre = new Point(this.Balle.Centre.X - this.Balle.Rayon, this.Balle.Centre.Y + this.AngleBalle);
         }
         else
         {
             if ((this.Balle.Centre.Y >= this.Joueur1.Centre.Y) &&
                 (this.Balle.Centre.Y <= this.Joueur1.Centre.Y + this.Joueur1.Largeur))
             {
                 this.AngleBalle += this.AngleJoueur1;
                 this.Balle.Centre = new Point(this.Balle.Centre.X + this.Balle.Rayon, this.Balle.Centre.Y + this.AngleBalle);
                 this.AllerBalle = true;
                 if (this.VibrationsJoueur1)
                 {
                     if (this.Parent.ManetteController.Manette1Controller.IsAlive)
                     {
                         this.Parent.ManetteController.Manette1.Vibrate(7500, 7500);
                         Thread.Sleep(150);
                         this.Parent.ManetteController.Manette1.Vibrate(0, 0);
                     }
                 }
                 if (this.Sons)
                 {
                     this.SoundPlayer.SoundLocation = @"Resources/4360__NoiseCollector__ponblipG_5.wav";
                     this.SoundPlayer.Play();
                 }
             }
             else
             {
                 this.ServiceJoueur1 = false;
                 this.ServiceJoueur2 = true;
                 this.AllerBalle = false;
                 this.AngleBalle = 0;
                 this.AngleJoueur1 = 0;
                 this.AngleJoueur2 = 0;
                 this.TimerBalle.Enabled = false;
                 this.TimerBalle.Stop();
                 this.Balle.Centre = new Point(this.Joueur2.Centre.X - 10, this.Joueur2.Centre.Y);
                 PointEndedEventArgs peea = new PointEndedEventArgs(2);
                 this.OnPointEnded(this, peea);
             }
             this.UpButtonPressedJoueur2 = 0;
             this.DownButtonPressedJoueur2 = 0;
         }
     }
     if (this.Balle.Centre.Y <= 10)
         this.AngleBalle += this.Balle.Rayon / 2;
     if (this.Balle.Centre.Y >= this.Terrain.Largeur)
         this.AngleBalle -= this.Balle.Rayon / 2;
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render,
         new Action(() => this.Parent.InvalidateVisual()));
 }