Beispiel #1
0
        public void updateTotalLabelScore(int i, int totalScore)
        {
            Yahtzee formYahtzee = Globals.formYahtzee;
            string  targetLabel;

            targetLabel = "lblTotalScore" + (i + 1);
            Control[] labels2 = formYahtzee.Controls.Find(targetLabel, true);
            if (labels2.Length == 1)
            {
                lblScore = (Label)labels2[0];
            }

            lblScore.Text = totalScore.ToString();
        }
Beispiel #2
0
        public void UpdateTotaalScore()
        {
            Yahtzee formYahtzee = Globals.formYahtzee;
            //Label lblScore = null;
            string targetLabel;

            for (int i = 0; i < 2; i++)
            {
                int totalScore = 0;
                for (int j = 0; j < 6; j++)
                {
                    targetLabel = "lblScore" + (i + 1) + (j + 1);
                    Control[] labels = formYahtzee.Controls.Find(targetLabel, true);
                    if (labels.Length == 1)
                    {
                        lblScore = (Label)labels[0];                                             //   formYahtzee.updateScores( player1Scores ,  player2Scores)
                    }
                    else
                    {
                        MessageBox.Show("werkt niet");
                    }
                    totalScore += Int32.Parse(lblScore.Text);
                }

                targetLabel = "lblTotalScore" + (i + 1);
                Control[] labels2 = formYahtzee.Controls.Find(targetLabel, true);
                if (labels2.Length == 1)
                {
                    lblScore = (Label)labels2[0];
                }
                else
                {
                    MessageBox.Show("werkt niet");
                }

                mScoreboardControl[i].model.TotalScore = totalScore;
                lblScore.Text = mScoreboardControl[i].model.TotalScore.ToString();
            }
        }
Beispiel #3
0
        public void OnClick(object sender, EventArgs e)
        {
            Button  clickedButton = (Button)sender;
            Yahtzee formYahtzee   = Globals.formYahtzee;
            Label   lblScore      = null;

            int aantal         = 0;
            int btnScoreWaarde = (clickedButton.Name[clickedButton.Name.Length - 1] - 48);      //ASCII code voor 1 is 49(dus -48)
            //string btnYahtzeeName = clickedButton.Name.ToString();

            Boolean yahtzeeWorp       = true; //  wordt op false gezet zodra er een dobbelsteen verschillend is
            int     yahtzeeWorpWaarde = 0;

            clickedButton.Enabled = false;

            for (int i = 0; i < formYahtzee.mAantalTeerlingen; i++)
            {
                if (formYahtzee.mTeerlingenControl[i].model.AantalOgen == btnScoreWaarde)
                {
                    aantal++;
                }

                if (i == 0)    // eerste dobbelsteen
                {
                    yahtzeeWorpWaarde = formYahtzee.mTeerlingenControl[i].model.AantalOgen;
                }
                else
                {
                    if (formYahtzee.mTeerlingenControl[i].model.AantalOgen != yahtzeeWorpWaarde)
                    {
                        yahtzeeWorp = false;
                    }
                }
            }
            if (yahtzeeWorp && (btnScoreWaarde == 7))
            {
                MessageBox.Show("Yahtzee");
            }


            //string targetLabel = "lblScore" + suffix;
            string targetLabel = clickedButton.Name.Replace("btnName", "lblScore");

            Control[] labels = formYahtzee.Controls.Find(targetLabel, true);
            if (labels.Length == 1)
            {
                lblScore = (Label)labels[0];                                             //   formYahtzee.updateScores( player1Scores ,  player2Scores)
            }
            else
            {
                MessageBox.Show("werkt niet");
            }


            lblScore.Text = (aantal * btnScoreWaarde).ToString();
            if (yahtzeeWorp && (btnScoreWaarde == 7))
            {
                lblScore.Text = "50";
            }
            formYahtzee.UpdateTotaalScore();

            //MessageBox.Show(""+ btnScoreWaarde);
        }