Example #1
0
        public BugRacerForm()
        {
            InitializeComponent();

            bugsTotalScoresLabels = new Label[] { label11, label14, label17, label20 };
            bugsChanceLabels = new Label[] { label10, label13, label16, label19 };
            gamblerMoneysLabels = new Label[] { label23,label6,label25};

            bugs = new List<Bug>();
            bugs.Add(new Bug("Участник 1",1, 585, pictureBox1,8));
            bugs.Add(new Bug("Участник 2",2, 585, pictureBox2,6));
            bugs.Add(new Bug("Участник 3", 3, 585, pictureBox3,7));
            bugs.Add(new Bug("Участник 4", 4, 585, pictureBox4,5));
            Random n=new Random();
            gamblers = new List<Gambler>();
            gamblers.Add(new Gambler("Игрок 1", 1,n.Next(250,1000) ));
            gamblers.Add(new Gambler("Игрок 2", 2, n.Next(250, 1000)));
            gamblers.Add(new Gambler("Игрок 3", 3, n.Next(250, 1000)));

            currentGambler = gamblers[0];
            currentBug = bugs[0];

            bets = new Dictionary<Gambler, Bet>();

            controller = new GameController(bugs, gamblers);

            controller.finish += HandleFinishEvent;
            start += controller.OnStart;

            timer1.Tick += controller.OnTimer;
            timer1.Enabled = false;
            timer1.Interval = GAME_SPEED;

            UpdateInfo();
        }
Example #2
0
        //Регистрирует участников забега дошедщие до финеша
        //вызываются самими участниками (жуками)
        //точнее обрабатывает событие генерируемое жуками
        public void BugFinishedEventHandle(Bug bug1)
        {
            if (score.WinnerBug==null)
            {
                score.WinnerBug = bug1;
            }
            score.BugsPlaces[bug1] = score.BugsPlaces.Count+1;

            if (score.BugsPlaces.Count == bugs.Count)
            {
                totalizator.RegisterRace(score);
                totalizator.CalculatePrizes(bets);
                totalizator.UpdateChances();

                foreach (var bet in bets)
                {
                    bet.Gambler.TakePrize(score.GamblersPrizes[bet.Gambler]);
                }

                foreach (var bug in bugs)
                {
                    bug.MoveToStart();
                }

                finish(score);
            }
        }
Example #3
0
 //генерация шага для движения в зависимости от жука
 private int GenerateRandIntFor(Bug bug)
 {
     return (int)((r.Next(10) + bug.Professionality + bug.Succsess));
 }
Example #4
0
 private void CurrentBugChanged(object sender, EventArgs e)
 {
     if (radioButton4.Checked)
         currentBug = bugs[0];
     else if (radioButton5.Checked)
         currentBug = bugs[1];
     else if (radioButton6.Checked)
         currentBug = bugs[2];
     else if (radioButton7.Checked)
         currentBug = bugs[3];
 }
Example #5
0
 public Bet(Gambler gambler, Bug bug, int amount)
 {
     Gambler = gambler;
     Bug = bug;
     Amount = amount;
 }