public void OnBallInPlay(BallEventArgs e) { EventHandler ballInPlay = BallInPlay; if (ballInPlay != null) { ballInPlay(this, e); } }
public MainPage() { Ball ball = new Ball(); Pitcher pitcher = new Pitcher(ball); BallEventArgs ballEventArgs = new BallEventArgs(50); ball.OnBallInPlay(ballEventArgs); this.InitializeComponent(); }
private void Ball_BallInPlay(object sender, EventArgs e) { if (e is BallEventArgs) { BallEventArgs ballEventArgs = e as BallEventArgs; if (ballEventArgs.Trajectory < 60) { CatchBall(); } else { CoverFirstBase(); } } }