示例#1
0
        private void ClickImage(object sender, EventArgs e)
        {
            if (!salliClick)
            {
                return;
            }
            var pic = (PictureBox)sender;

            if (arvaus == null)
            {
                arvaus    = pic;
                pic.Image = (Image)pic.Tag;
                return;
            }
            label2.Text = Convert.ToString(Convert.ToInt32(label2.Text) - 5);
            pic.Image   = (Image)pic.Tag;

            if (pic.Image == arvaus.Image && pic != arvaus)
            {
                pic.Visible = arvaus.Visible = false;
                {
                    arvaus = pic;
                }
                label2.Text = Convert.ToString(Convert.ToInt32(label2.Text) + 15);
                HideImages();
            }
            else
            {
                salliClick = false;
                clickAjastin.Start();
            }
            arvaus = null;

            if (PictureBoxes.Any(p => p.Visible))
            {
                return;
            }
            {
                StopGameTimer();

                int loop = 0;

                DialogResult dialogResult = MessageBox.Show("Voitit! Haluatko jatkaa pelaamista?", "Voitit!", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    loop++;
                    kierros++;
                }
                else if (dialogResult == DialogResult.No)
                {
                    System.Windows.Forms.Application.ExitThread();
                }
                label5.Text = kierros.ToString();
                ResetImages();
                label2.Text = "0";
            }
        }
示例#2
0
        private void ClickImage(object sender, EventArgs e)
        {
            if (!allowClick)
            {
                return;
            }
            guessCount++;
            var pic = (PictureBox)sender;

            DisplayGuessCount(); //Calls method to display guessCount
            DisplayAccuracy();   //Calls method to display the percent accuracy

            if (firstGuess == null)
            {
                firstGuess = pic;
                pic.Image  = (Image)pic.Tag;
                return;
            }
            pic.Image = (Image)pic.Tag;


            if (pic.Image == firstGuess.Image && pic != firstGuess)
            {
                correctGuessCount++;                                    //adds 1 to correct guess count
                label4.Text     = correctGuessCount.ToString();
                scoreLabel.Text = (correctGuessCount * 100).ToString(); //displays and calculates score

                pic.Visible = firstGuess.Visible = false;

                {
                    firstGuess = pic;
                }

                HideImages();
            }
            else
            {
                allowClick = false;
                clickTimer.Start();
            }

            firstGuess = null;

            //Checks for any visible pictures, returns if yes, else stops timer & displays Win
            if (PictureBoxes.Any(p => p.Visible))
            {
                return;
            }
            else
            {
                timer.Stop();        //Stops timer when all heross are correctly paired
                MessageBoxWinGame(); //Calls method when all heros are correctly paired
            }
        }
示例#3
0
        private void ClickImage(object sender, EventArgs e)
        {
            if (!allowClick)
            {
                return;
            }
            guessCount++;
            var pic = (PictureBox)sender;

            //label2.Text = guessCount.ToString();
            DisplayGuessCount();
            DisplayAccuracy();

            if (firstGuess == null)
            {
                firstGuess = pic;
                pic.Image  = (Image)pic.Tag;
                return;
            }
            pic.Image = (Image)pic.Tag;


            if (pic.Image == firstGuess.Image && pic != firstGuess)
            {
                correctGuessCount++;
                label4.Text     = correctGuessCount.ToString();
                scoreLabel.Text = (correctGuessCount * 100).ToString();
                pic.Visible     = firstGuess.Visible = false;

                {
                    firstGuess = pic;
                }

                HideImages();
            }
            else
            {
                allowClick = false;
                clickTimer.Start();
            }


            firstGuess = null;
            if (PictureBoxes.Any(p => p.Visible))
            {
                return;
            }
            else
            {
                timer.Stop(); MessageBoxWinGame();
            }
        }
示例#4
0
        /// <summary>
        /// Click van image op picturebox zodat image wordt gedraaid
        /// Als geen paar hebt dan image weer verbergen
        /// Als ze gelijk zijn verwijder dan de image van het speelveld
        /// </summary>
        private void clickImage(object sender, EventArgs e)
        {
            if (!allowClick)
            {
                return;
            }
            var pic = (PictureBox)sender;

            if (firstGuess == null)
            {
                firstGuess = pic;
                pic.Image  = (Image)pic.Tag;
                return;
            }
            pic.Image = (Image)pic.Tag;
            if (pic.Image == firstGuess.Image && pic != firstGuess)
            {
                pic.Visible = firstGuess.Visible = false;
                {
                    firstGuess = pic;
                }
                hideImages();
            }
            else
            {
                allowClick = false;
                clickTimer.Start();
            }
            firstGuess = null;
            if (PictureBoxes.Any(p => p.Visible))
            {
                return;
            }
            timer.Stop();
            MessageBox.Show("Gefeliciteerd.", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"../../Resources/scoreboard.txt", true))
            {
                file.WriteLine(naam + "  :  " + lblTime.Text + " time");
            }
            resetImages();
        }
示例#5
0
        private void ClickImage(object sender, EventArgs e)
        {
            if (!allowClick)
            {
                return;
            }

            var pic = (PictureBox)sender;

            if (firstGuess == null)
            {
                firstGuess = pic;
                pic.Image  = (Image)pic.Tag;
                return;
            }
            pic.Image = (Image)pic.Tag;
            if (pic.Image == firstGuess.Image && pic != firstGuess)
            {
                pic.Visible = firstGuess.Visible = false;
                {
                    firstGuess = pic;
                }

                HideImages();
            }
            else
            {
                allowClick = false;
                clickTimer.Start();
            }
            firstGuess = null;
            if (PictureBoxes.Any(p => p.Visible))
            {
                return;
            }

            MessageBox.Show("You won!", "Victory", MessageBoxButtons.OK);
            ResetImages();
            allowClick = false;
        }
示例#6
0
        /// <summary>
        /// Click van image op picturebox zodat image wordt gedraaid
        /// Als geen paar hebt dan image weer verbergen
        /// Als ze gelijk zijn verwijder dan de image van het speelveld
        /// </summary>
        private void clickImage(object sender, EventArgs e)
        {
            if (!allowClick)
            {
                return;
            }
            var pic = (PictureBox)sender;

            if (firstGuess == null)
            {
                firstGuess = pic;
                pic.Image  = (Image)pic.Tag;
                return;
            }
            pic.Image = (Image)pic.Tag;
            string picloc = pic.ImageLocation;

            string[] picloca = picloc.Split('/');
            if (picloca[picloca.Length - 1][1] == 'o')
            {
                if (pic.Image == firstGuess.Image && pic != firstGuess)
                {
                    pic.Visible    = firstGuess.Visible = false;
                    pic.Tag        = null;
                    firstGuess.Tag = null;
                    {
                        firstGuess = pic;
                    }
                    if (this.turn == 0)
                    {
                        scoreP1++;
                        lblScoreP1.Text = naamP1 + ": " + scoreP1;
                    }
                    else
                    {
                        scoreP2++;
                        lblScoreP2.Text = naamP2 + ": " + scoreP2;
                    }
                    hideImages();
                }
                else
                {
                    if (turn > 0)
                    {
                        turn--;
                    }
                    else
                    {
                        turn++;
                    }
                    switchTurns();
                    allowClick = false;
                    clickTimer.Start();
                }
            }
            else if (pic.ImageLocation == firstGuess.ImageLocation && pic != firstGuess)
            {
                pic.Visible    = firstGuess.Visible = false;
                pic.Tag        = null;
                firstGuess.Tag = null;
                {
                    firstGuess = pic;
                }
                if (this.turn == 0)
                {
                    scoreP1++;
                    lblScoreP1.Text = naamP1 + ": " + scoreP1;
                }
                else
                {
                    scoreP2++;
                    lblScoreP2.Text = naamP2 + ": " + scoreP2;
                }
                hideImages();
            }
            else
            {
                if (turn > 0)
                {
                    turn--;
                }
                else
                {
                    turn++;
                }
                switchTurns();
                allowClick = false;
                clickTimer.Start();
            }
            firstGuess = null;
            if (PictureBoxes.Any(p => p.Visible))
            {
                return;
            }
            String winPlayer = "";

            if (scoreP1 > scoreP2)
            {
                winPlayer    = naamP1;
                WinningScore = scoreP1;
            }
            else
            {
                winPlayer    = naamP2;
                WinningScore = scoreP2;
            }

            var path = Path.Combine(Directory.GetCurrentDirectory(), "../../Resources/VICTORY.wav");

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer(path);
            sp.Play();

            MessageBox.Show("Gefeliciteerd " + winPlayer + " heeft gewonnen!", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            using (StreamWriter file =
                       new StreamWriter(Directory.GetCurrentDirectory() + "../../../Resources/scoreboardMulti.txt", true))
            {
                file.WriteLine(winPlayer + ":   " + WinningScore + " points");
            }
            scoreGame scoreGame = new scoreGame();

            scoreGame.Show();
        }