Beispiel #1
0
        private void playBall_Click(object sender, EventArgs e)
        {
            BallEventArgs ballEventArgs = new BallEventArgs((int)trajectory.Value, (int)distance.Value);
            Bat           bat           = ball.GetNewBat();

            bat.HitTheBall(ballEventArgs);
        }
Beispiel #2
0
 public void HitTheBall(BallEventArgs e)
 {
     if (hitBallCallBack != null)
     {
         hitBallCallBack(e);
     }
 }
Beispiel #3
0
        protected void OnBallInPlay(BallEventArgs e)
        {
            EventHandler <BallEventArgs> ballInPlay = BallInPlay;

            if (ballInPlay != null)
            {
                ballInPlay(this, e);
            }
        }
Beispiel #4
0
 void ball_BallInPlay(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!");
         }
     }
 }
Beispiel #5
0
 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();
         }
     }
 }