public void OnBallInPlay(BallEventArgs e) { EventHandler ballInPlay = BallInPlay; if (ballInPlay != null) { ballInPlay(this, e); } }
void ball_BallInPlay(object sender, EventArgs e) { pitchNumber++; if (e is BallEventArgs) { BallEventArgs ballEventArgs = e as BallEventArgs; if ((ballEventArgs.Distance < 95) && (ballEventArgs.Trajectory < 60)) { CatchBall(); } else { CoverFirstBase(); } } }
void ball_BallInPlay(object sender, EventArgs e) { pitchNumber++; if (e is BallEventArgs) { BallEventArgs ballEventArgs = e as BallEventArgs; if (ballEventArgs.Distance > 400 && ballEventArgs.Trajectory > 30) { FanSays.Add("Rzut nr" + pitchNumber + ": Home run! Idę po piłkę!"); } else { FanSays.Add("Rzut nr" + pitchNumber + ": Jeee! Do boju!"); } } }
public void PlayBall() { BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance); ball.OnBallInPlay(ballEventArgs); }