private async void stopGame() { // stop game is a simpilar method, except it only runs once the spellCounter reaches 10 // 10 represents the number of words the user spelt wrong! resetDif = 0; spellCounter = 0; start = false; introTxtBlock.Text = " Game Stopped"; rdmWordsTxtBlock.Text = "Well Done! Scored: " + spellScore; if (loginPage.gameName == "" || loginPage.gamePassword == "") { usernameDb = userGuest; passwordDb = guestPassword; } else { usernameDb = loginPage.gameName; passwordDb = loginPage.gamePassword; } AddScore item = new AddScore { Username = usernameDb, Password = passwordDb, Highscore = spellScore }; await App.MobileService.GetTable <AddScore>().InsertAsync(item); spellScore = 0; scoreTxtBlock.Text = "Score: " + spellScore; resetBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed; }
private async void resetBtn_Click(object sender, RoutedEventArgs e) { resetDif = 0; //resets difficulty spellCounter = 0; // resets counter to 0 so game wont end start = false; // set to false to stop the buttons making words cycle introTxtBlock.Text = "Game Stopped and Reset."; rdmWordsTxtBlock.Text = "Well Done! Scored: " + spellScore; // here is the database code.. //if the user didnt selected a name or password on login page //this means they must be playing as guest! // else set the database variables to the text the user entered if (loginPage.gameName == "" || loginPage.gamePassword == "") { usernameDb = userGuest; passwordDb = guestPassword; } else { usernameDb = loginPage.gameName; passwordDb = loginPage.gamePassword; } // inserts into the azure database AddScore item = new AddScore { Username = usernameDb, Password = passwordDb, Highscore = spellScore }; await App.MobileService.GetTable <AddScore>().InsertAsync(item); //then resets the score for next game spellScore = 0; scoreTxtBlock.Text = "Score: " + spellScore; resetBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed; }