private void TimerTick(object sender, EventArgs e) { int secondsRemaining = (deadline - DateTime.Now).Seconds; OnPropertyChanged("DispatcherTimer"); if (secondsRemaining == 0) { dispatcherTimer.Stop(); dispatcherTimer.IsEnabled = false; Seconds = 59; MessageBoxResult messageBoxResult = MessageBox.Show("Time has expired! You lost! Do you want to start a new game?", "Loose Game", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { ChooseGameWindow chooseGame = new ChooseGameWindow(); ChooseGameViewModel.selectedUser = currentUser; App.Current.MainWindow.Close(); App.Current.MainWindow = chooseGame; chooseGame.Show(); } else { SignIn signIn = new SignIn(); App.Current.MainWindow.Close(); App.Current.MainWindow = signIn; signIn.Show(); } LooseGame(CategoryProperty); } }
private void Reload() { WordIndex++; if (WordIndex < PickedWordsCollection.Count) { //minutes = 1; StartTimer(Seconds); Word = Codification(PickedWordsCollection[WordIndex]); ImagePath = "../Images/Mistakes/Default.png"; Mistakes = 0; Level++; } else { StopTimer(); WinGame(CategoryProperty); MessageBoxResult messageBoxResult = MessageBox.Show("You won! Do you want to start a new game?", "Win Game", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { ChooseGameWindow chooseGame = new ChooseGameWindow(); ChooseGameViewModel.selectedUser = currentUser; App.Current.MainWindow.Close(); App.Current.MainWindow = chooseGame; chooseGame.Show(); } else { SignIn signIn = new SignIn(); App.Current.MainWindow.Close(); App.Current.MainWindow = signIn; signIn.Show(); } } ResetButtons(); }
private void LetterCommandMethod(object param) { Button button = param as Button; buttonsCollection.Add(param as Button); (param as Button).IsEnabled = false; (param as Button).Foreground = Brushes.Red; char buttonContent = button.Content.ToString()[0]; //string cuvant = "VOLVO"; bool foundLetter = false; for (int index = 0; index < PickedWordsCollection[WordIndex].Length; ++index) { if (PickedWordsCollection[WordIndex][index] == buttonContent) { StringBuilder sb = new StringBuilder(Word); sb[index] = buttonContent; Word = sb.ToString(); foundLetter = true; } } if (WordState(Word) == true) { Reload(); } if (foundLetter == false) { mistakes++; if (mistakes <= 6) { Mistakes = mistakes; string path = "../Images/Mistakes/"; string imageName = "Mistake" + mistakes.ToString() + ".png"; ImagePath = path + imageName; } if (mistakes == 6) { StopTimer(); MessageBoxResult messageBoxResult = MessageBox.Show("You lost! Do you want to start a new game?", "Loose Game", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { ChooseGameWindow chooseGame = new ChooseGameWindow(); ChooseGameViewModel.selectedUser = currentUser; App.Current.MainWindow.Close(); App.Current.MainWindow = chooseGame; chooseGame.Show(); } else { SignIn signIn = new SignIn(); App.Current.MainWindow.Close(); App.Current.MainWindow = signIn; signIn.Show(); } LooseGame(CategoryProperty); } } }
private void NewGameMethod(object param) { //GameWindowViewModel gameVM = new GameWindowViewModel(); ChooseGameWindow chooseGame = new ChooseGameWindow(); // chooseGame.DataContext = gameVM; ChooseGameViewModel.selectedUser = SignInViewModel.SignedInUser; App.Current.MainWindow.Close(); App.Current.MainWindow = chooseGame; chooseGame.Show(); }