private void MoveCycles(object sender, EventArgs e) { if (sender is Timer) { int index = -1; Timer timer = sender as Timer; if (timer == timer1) { index = 0; } else if (timer == timer2) { index = 1; } else if (timer == timer3) { index = 2; } else if (timer == timer4) { index = 3; } if (index != -1) { PictureBox pbox = Cyclez[index].MyPictureBox; if (pbox.Location.X + pbox.Width > Cyclez[index].RaceTrackLength) { if (winnerCycle == null) { winnerCycle = Cyclez[index]; } timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); } else { int jump = new Random().Next(1, 15); pbox.Location = new Point(pbox.Location.X + jump, pbox.Location.Y); } } } if (winnerCycle != null) { MessageBox.Show("Congratulation! " + winnerCycle.CycleName + " Win The Race"); BetSetInfo(); foreach (Punter punter in punters) { if (punter.MyBet != null) { if (punter.MyBet.Cycle == winnerCycle) { punter.Cash += punter.MyBet.Amount; punter.MyText.Text = punter.Name + " Won and now has $" + punter.Cash; punter.Winner = true; } else { punter.Cash -= punter.MyBet.Amount; if (punter.Cash == 0) { punter.MyText.Text = "BUSTED"; punter.Busted = true; punter.MyRadioButton.Enabled = false; } else { punter.MyText.Text = punter.Name + " Lost and now has $" + punter.Cash; } } } } winnerCycle = null; timer1 = timer2 = timer3 = timer4 = null; int count = 0; foreach (Punter punter in punters) { if (punter.Busted) { count++; } if (punter.MyRadioButton.Enabled && punter.MyRadioButton.Checked) { label2.Text = "Max Bet is $" + punter.Cash; numericUpDown1.Maximum = punter.Cash; numericUpDown1.Minimum = 1; } punter.MyBet = null; punter.Winner = false; } if (count == punters.Length) { button1.Text = "Game Over"; } foreach (Greyhound Cycle in Cyclez) { Cycle.MyPictureBox.Location = new Point(12, Cycle.MyPictureBox.Location.Y); } } }