protected virtual void OnMove(BallEventArgs e) { if (BallMove != null) { BallMove(this, e); } }
protected virtual void OnMove(BallEventArgs e) { if (BallMove != null) { BallMove(this,e); } }
private void BallMove(object sender,BallEventArgs bea) { if (sender is Ball) { Ball bsender = (Ball)sender; if (bsender.Location.Y > _bar.Top) { bsender.Stop(); this.Controls.Remove(bsender); gameStart = false; lives--; if (lives == 0) { if(MessageBox.Show("Game Over. New Game?", "Window Bounce", MessageBoxButtons.YesNo)== System.Windows.Forms.DialogResult.Yes){ lives=3; NewGame(); } } return; } foreach (var b in this.Controls) { if (b is Ball) { Ball inball = (Ball)b; if (bsender!= inball) { if (bsender.CollisionDetected(inball) && inball.CollisionDetected(bsender)) { bsender.ChangeDirection(false); break; } } } else { if (bsender.CollisionDetected((Control)b)) { bsender.ChangeDirection(true); if (b is Brick) { if (((Brick)b).WeakCount == 0) { this.Controls.Remove(((Control)b)); if (AreBricksGone()) { //MessageBox.Show("Congratulations"); gameLevel++; if (gameLevel == 6) { MessageBox.Show("Congratulations You beat the Game"); } else { NewGame(); } } } else { ((Brick)b).Hit(); } } break; } } } } }
private void BallMove(object sender, BallEventArgs bea) { if (sender is Ball) { Ball bsender = (Ball)sender; if (bsender.Location.Y > _bar.Top) { bsender.Stop(); this.Controls.Remove(bsender); gameStart = false; lives--; if (lives == 0) { if (MessageBox.Show("Game Over. New Game?", "Window Bounce", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { lives = 3; NewGame(); } } return; } foreach (var b in this.Controls) { if (b is Ball) { Ball inball = (Ball)b; if (bsender != inball) { if (bsender.CollisionDetected(inball) && inball.CollisionDetected(bsender)) { bsender.ChangeDirection(false); break; } } } else { if (bsender.CollisionDetected((Control)b)) { bsender.ChangeDirection(true); if (b is Brick) { if (((Brick)b).WeakCount == 0) { this.Controls.Remove(((Control)b)); if (AreBricksGone()) { //MessageBox.Show("Congratulations"); gameLevel++; if (gameLevel == 6) { MessageBox.Show("Congratulations You beat the Game"); } else { NewGame(); } } } else { ((Brick)b).Hit(); } } break; } } } } }