Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void rectClick(object sender, MouseButtonEventArgs e)
- {
- // If game is paused, prevent action
- if (pause == true)
- {
- return;
- }
- // This variable contains the object that was clicked on
- var mouseWasDownOn = e.Source as FrameworkElement;
- // This hides the rectangle, revealing the image
- mouseWasDownOn.Visibility = Visibility.Hidden;
- MessageBox.Show("");
- // If an image is already revealed
- // This happens if no picture has been clicked
- if (firstImage == null)
- {
- firstImage = e.Source as FrameworkElement;
- }
- // This happens if an image is open
- else
- {
- secondImage = e.Source as FrameworkElement;
- samePicture = comparePicture(firstImage, secondImage);
- // If you clicked on same pictures
- if (samePicture)
- {
- points = points + 1;
- // Checks when the game is over
- if (points > 7)
- {
- MessageBox.Show("You've won! ");
- var currentValue = DateTime.Now - this.TimerStart;
- int x = (int)currentValue.Seconds;
- MessageBox.Show("You took " + x + " seconds to finish the game!");
- HighScore score = new HighScore() { Score = points, Name = nameBox.Text };
- highScore.Add(score);
- MessageBox.Show("Feel free to retry the game if you want! ");
- }
- }
- else {
- if (difficulty == 1)
- {
- mouseWasDownOn.Visibility = Visibility.Hidden;
- Thread.Sleep(2000);
- }
- else if (difficulty == 2)
- {
- mouseWasDownOn.Visibility = Visibility.Hidden;
- Thread.Sleep(1000);
- }
- else if (difficulty == 3)
- {
- mouseWasDownOn.Visibility = Visibility.Hidden;
- Thread.Sleep(200);
- }
- firstImage.Visibility = Visibility.Visible;
- secondImage.Visibility = Visibility.Visible;
- }
- firstImage = null;
- secondImage = null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement