Exemple #1
0
 public void HitTheBall(BallEventArgs e)
 {
     if (hitBallCallback != null)
     {
         hitBallCallback(e);
     }
 }
        private void play_Click(object sender, EventArgs e)
        {
            Bat           bat           = ball.GetNewBat();
            BallEventArgs ballEventArgs = new BallEventArgs((int)Trajectory.Value, (int)Distance.Value);

            bat.HitTheBall(ballEventArgs);
        }
Exemple #3
0
        protected void OnBallInPlay(BallEventArgs e)
        {
            EventHandler <BallEventArgs> ballInPlay = BallInPlay;

            if (ballInPlay != null)
            {
                ballInPlay(this, e);
            }
        }
 private void ball_BallEventArgs(object sender, EventArgs e)
 {
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if (ballEventArgs.Distance > 400 && ballEventArgs.Trajectory > 30)
         {
             Console.WriteLine("Fan : Home run! I m going for the ball!");
         }
         else
         {
             Console.WriteLine("Fan : Woo-hoo!! yeah!");
         }
     }
 }
 private void ball_BallInPlay(object sender, EventArgs e)
 {
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if ((ballEventArgs.Distance < 95) && (ballEventArgs.Trajectory < 60))
         {
             catchBall();
         }
         else
         {
             coverFirstBase();
         }
     }
 }