public void PlayBall()
        {
            Bat           bat           = _ball.GetNewBat();
            BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);

            bat.HitTheBall(ballEventArgs);
        }
Esempio n. 2
0
 private void Ball_BallInPlay(object sender, EventArgs e)
 {
     _pitcherNumber++;
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if ((ballEventArgs.Distance < 95) && (ballEventArgs.Trajectory < 60))
         {
             CatchBall();
         }
         else
         {
             CoverFirstBase();
         }
     }
 }
 private void Ball_BallInPlay(object sender, EventArgs e)
 {
     _pitcherNumber++;
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if ((ballEventArgs.Distance > 400) && (ballEventArgs.Trajectory > 30))
         {
             FanSays.Add($"Pitcher #{_pitcherNumber}: Home Run! I'm going for the ball.");
         }
         else
         {
             FanSays.Add($"Pitcher #{_pitcherNumber}: Woo-hoo! Yeah!");
         }
     }
 }
 public void HitTheBall(BallEventArgs e)
 {
     hitBallCallback?.Invoke(e);
 }
 protected void OnBallInPlay(BallEventArgs e)
 {
     BallInPlay?.Invoke(this, e);
 }