Exemplo n.º 1
0
        private void VerifyBallCollision(int i, bool reverse, GameTime gt)
        {
            GamePadState stateGamepad = GamePad.GetState((PlayerIndex)i);
            Vector2 location = i == 0 ? this.Parent.HumanGame.PositionRaquette : this.Parent.AiGame.PositionRaquette;
            if (this.Parent.BallGame.PositionBalle.Y < location.Y + 64 &&
                this.Parent.BallGame.PositionBalle.Y > location.Y - 64)
            {
                if (reverse)
                    this.Parent.BallGame.TrajectoireBalle.X = -this.Parent.BallGame.TrajectoireBalle.X;
                this.Parent.BallGame.TrajectoireBalle.Y = (this.Parent.BallGame.PositionBalle.Y - location.Y) * 0.01f;

                if (i == 0)
                {
                    if (this.Parent.Sons)
                        this.Parent.SdEffect2.Play();
                }

                else
                {
                    if (this.Parent.Sons)
                        this.Parent.SdEffect1.Play();
                }
            }
            else
            {
                if (i == 0)
                {
                    this.Parent.Partie = false;
                    this.Parent.ServiceJoueur1 = false;
                    this.Parent.ServiceJoueur2 = true;
                    this.AllerBalle = false;
                    PointEndedEventArgs peea = new PointEndedEventArgs(2);
                    this.OnPointEnded(this, peea);
                }

                else
                {
                    this.Parent.Partie = false;
                    this.Parent.ServiceJoueur1 = true;
                    this.Parent.ServiceJoueur2 = false;
                    this.AllerBalle = true;
                    PointEndedEventArgs peea = new PointEndedEventArgs(1);
                    this.OnPointEnded(this, peea);
                }
            }
        }
Exemplo n.º 2
0
 public void Pong_OnPointEnded(object sender, PointEndedEventArgs e)
 {
     if (e.Joueur == 1)
     {
         this.Parent.ScoreJoueur1.Point++;
         switch (this.Parent.ScoreJoueur1.Point)
         {
             case 0:
                 this.Parent.Jeu.Score1.Point = 0;
                 break;
             case 1:
                 this.Parent.Jeu.Score1.Point = 15;
                 break;
             case 2:
                 this.Parent.Jeu.Score1.Point = 30;
                 break;
             case 3:
                 this.Parent.Jeu.Score1.Point = 40;
                 break;
             case 4:
                 this.Parent.ScoreJoueur1 = new Score();
                 GameEndedEventArgs geea = new GameEndedEventArgs(1, this.Parent.Jeu);
                 this.OnGameEnded(this, geea);
                 this.Parent.Jeu.Score1.Point = 0;
                 break;
         }
     }
     else
     {
         this.Parent.ScoreJoueur2.Point++;
         switch (this.Parent.ScoreJoueur2.Point)
         {
             case 0:
                 this.Parent.Jeu.Score2.Point = 0;
                 break;
             case 1:
                 this.Parent.Jeu.Score2.Point = 15;
                 break;
             case 2:
                 this.Parent.Jeu.Score2.Point = 30;
                 break;
             case 3:
                 this.Parent.Jeu.Score2.Point = 40;
                 break;
             case 4:
                 this.Parent.ScoreJoueur2 = new Score();
                 GameEndedEventArgs geea = new GameEndedEventArgs(2, this.Parent.Jeu);
                 this.OnGameEnded(this, geea);
                 this.Parent.Jeu.Score2.Point = 0;
                 break;
         }
     }
 }