private void Settings(object sender, RoutedEventArgs routedEventArgs) { // TODO: add settings tab Endscreen win = new Endscreen(); win.Show(); }
/// <summary> /// Card Clicker /// </summary> public void ClickCard(object sender, MouseButtonEventArgs e) { if (_isBusy) { return; } var img = (Image)sender; var card = LiveGame.Grid[img.Name]; img.Source = new BitmapImage( new Uri($"{AppDomain.CurrentDomain.BaseDirectory}/Images/{LiveGame.ThemeName}/{card.Name}.png")); if (card.IsGone || card.IsClicked) { return; } card.IsClicked = true; if (_check == null) { _check = card; _check.IsClicked = true; _clickedCards[0] = img; return; } if (_check.Name == card.Name) { SwitchPlayer(true); card.IsClicked = _check.IsClicked = false; card.IsGone = true; _check.IsGone = true; try { SoundPlayer player = new SoundPlayer(Properties.Resources.Correct); player.Play(); } catch (Exception ex) { MessageBox.Show("Error Message - " + ex.Message); } var x = LiveGame.Grid.Count(pair => pair.Value.IsGone == false); if (x <= 0) { if (sw.IsRunning) { sw.Stop(); } SaveGameManager.Instance.SaveToHighScoreList(new HighScore { PlayerName = LiveGame.Player1Name, Score = LiveGame.ScoreP1 }); if (!LiveGame.SinglePlayer) { SaveGameManager.Instance.SaveToHighScoreList(new HighScore { PlayerName = LiveGame.Player2Name, Score = LiveGame.ScoreP2 }); } Endscreen win = new Endscreen(); win.Show(); } } else //Deselect incorrect cards so they flip back and Flip image back to the card back { SwitchPlayer(); Mouse.OverrideCursor = Cursors.Wait; _isBusy = true; card.IsClicked = false; _check.IsClicked = false; _clickedCards[1] = img; try { SoundPlayer player = new SoundPlayer(Properties.Resources.Wrong); player.Play(); } catch (Exception ex) { MessageBox.Show("Error Message - " + ex.Message); } Task.Delay(TimeSpan.FromSeconds(1)).ContinueWith(t => FlipCard(_clickedCards)); } _check = null; }