private void ResetGame() { ResetButtons(); Mistakes = 0; Level = 1; ImagePath = "../Images/Mistakes/Default.png"; Seconds = 59; StartTimer(Seconds); PickedWordsCollection.Clear(); WordIndex = 0; PickedWordsCollection = PickWords(CategoryProperty); Word = Codification(PickedWordsCollection[WordIndex]); }
private void BackMethod(object param) { Seconds = (deadline - DateTime.Now).Seconds; StopTimer(); MessageBoxResult messageBoxResult = MessageBox.Show("Do you want to save your game?", "Save Game", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { SaveGame(); } else { PickedWordsCollection.Clear(); SignIn signIn = new SignIn(); App.Current.MainWindow.Close(); App.Current.MainWindow = signIn; signIn.Show(); } }
public ObservableCollection <string> PickWords(Category category) { int riversCount = words.Rivers.Count; int carsCount = words.Cars.Count; int moviesCount = words.Movies.Count; int flowersCount = words.Flowers.Count; switch (category) { case Category.AllCategories: int count = 4; for (int index = 0; index < 5; ++index) { int categoryIndex = rand.Next(count); switch (categoryIndex) { case 0: PickedWordsCollection.Add(words.Rivers[rand.Next(riversCount)]); break; case 1: PickedWordsCollection.Add(words.Cars[rand.Next(carsCount)]); break; case 2: PickedWordsCollection.Add(words.Movies[rand.Next(moviesCount)]); break; case 3: PickedWordsCollection.Add(words.Flowers[rand.Next(flowersCount)]); break; default: break; } } break; case Category.Rivers: for (int index = 0; index < 5; index++) { PickedWordsCollection.Add(words.Rivers[rand.Next(riversCount)]); } break; case Category.Cars: for (int index = 0; index <= 4; index++) { PickedWordsCollection.Add(words.Cars[rand.Next(carsCount)]); } break; case Category.Movies: for (int index = 0; index <= 4; index++) { PickedWordsCollection.Add(words.Movies[rand.Next(moviesCount)]); } break; case Category.Flowers: for (int index = 0; index <= 4; index++) { PickedWordsCollection.Add(words.Flowers[rand.Next(flowersCount)]); } break; default: break; } return(PickedWordsCollection); }