コード例 #1
0
        /// <summary>
        /// race ends
        /// </summary>
        public void UpdateLogic()
        {
            if (moving == 1)
            {
                Gl.glTranslatef(0, 0, 0.35f);
            }
            else
            if (moving == -1)
            {
                Gl.glTranslatef(0, 0, -0.35f);
            }
            count++;
            if (Controller.FinishedRace == true && mostrado == 0)
            {
                int             result;
                MainBetterClass obj = new MainBetterClass();
                mostrado = 1;
                moving   = 0;
                //Display Result
                MessageBox.Show("The winner was the: " + lblPrimero.Text + " (car no: " + lblbetno.Text + ")");
                //Update Amount Remaining and wining status
                if (lblPrimero.Text == "Blue car")
                {
                    result = obj.whowon(betno, 1);
                }
                else if (lblPrimero.Text == "Red car")
                {
                    result = obj.whowon(betno, 2);
                }
                else if (lblPrimero.Text == "Green car")
                {
                    result = obj.whowon(betno, 3);
                }
                else
                {
                    result = obj.whowon(betno, 4);
                }
                if (result == 0)
                {
                    joewins = true;
                }
                else if (result == 1)
                {
                    bobwins = true;
                }
                else if (result == 2)
                {
                    aiwins = true;
                }
                //function to update textboxes for betting amount left and status of betters
                changeText();
                //set old betno and betvalue to 0
                for (int i = 0; i < 3; i++)
                {
                    betno[i]    = 0;
                    betValue[i] = 0;
                }
            }

            if (count == 10)
            {
                if (Controller.StartedRace == true && mostrado == 0)
                {
                    int   primero            = control.GetFirstPlace();
                    float distanciaRecorrida = control.GetDistanceInMeters(primero);
                    lblDistancia.Text = Convert.ToString((int)distanciaRecorrida);
                    switch (primero)
                    {
                    case 0:
                    {
                        lblPrimero.Text      = "Blue car";
                        lblbetno.Text        = "1";
                        lblPrimero.ForeColor = Color.Blue;
                        break;
                    }

                    case 1:
                    {
                        lblPrimero.Text      = "Red car";
                        lblbetno.Text        = "2";
                        lblPrimero.ForeColor = Color.Red;
                        break;
                    }

                    case 2:
                    {
                        lblPrimero.Text      = "Green car";
                        lblbetno.Text        = "3";
                        lblPrimero.ForeColor = Color.Green;
                        break;
                    }

                    case 3:
                    {
                        lblPrimero.Text      = "Gold car";
                        lblbetno.Text        = "4";
                        lblPrimero.ForeColor = Color.Goldenrod;
                        break;
                    }
                    }
                }
                count = 0;
            }
        }
コード例 #2
0
        //change bet values placed with winners and win amount , losers and lost amount
        public void changeText()
        {
            MainBetterClass better = new MainBetterClass();

            if (joewins == true)
            {
                joe_total   = Convert.ToInt32(joe_total + betValue[0]);
                txtJoe.Text = better.getName(0) + " won and now has " + joe_total;
                joewins     = false;
            }
            else
            {
                joe_total = Convert.ToInt32(joe_total - betValue[0]);
                if (joe_total <= 0)
                {
                    txtJoe.Text      = "Busted";
                    txtJoe.ForeColor = Color.Red;
                    rbJoe.Enabled    = false;
                    bustCount++;
                }
                else
                {
                    txtJoe.Text = better.getName(0) + " lost and now has" + joe_total;
                }
            }
            if (bobwins == true)
            {
                bob_total   = Convert.ToInt32(bob_total + betValue[1]);
                txtBob.Text = better.getName(1) + " won and now has " + bob_total;
                bobwins     = false;
            }
            else
            {
                bob_total = Convert.ToInt32(bob_total - betValue[1]);
                if (bob_total <= 0)
                {
                    txtBob.Text      = "Busted";
                    rbBob.Enabled    = false;
                    txtBob.ForeColor = Color.Red;
                    bustCount++;
                }
                else
                {
                    txtBob.Text = better.getName(1) + " lost and now has " + bob_total;
                }
            }
            if (aiwins == true)
            {
                ai_total   = Convert.ToInt32(ai_total + betValue[2]);
                txtAI.Text = better.getName(2) + " won and now has " + ai_total;
                aiwins     = false;
            }
            else
            {
                ai_total = Convert.ToInt32(ai_total - betValue[2]);
                if (ai_total <= 0)
                {
                    txtAI.Text      = "Busted";
                    rbAI.Enabled    = false;
                    txtAI.ForeColor = Color.Red;
                    bustCount++;
                }
                else
                {
                    txtAI.Text = better.getName(2) + " lost and now has " + ai_total;
                }
            }
            if (bustCount > 1)
            {
                MessageBox.Show("Game Over");
            }
        }