/******************************************************************************************************************/ /// <summary> /// All Button Actions in the following section are used exclusively for the game page. /// </summary> /*BUTTONS FOR GAME PAGE *******************************************************************************************/ //logs player out. Saves score value if score is higher then current bestScore. Brings user to main screen. private void button_game_logout_Click(object sender, EventArgs e) { phm = new PlayerHistoryManager(activePlayer.GetUserName()); //On logout, checks if session should replace any values in user's scoreHistory. activePlayer.SetScoreHistory(phm.UserHistoryUpdate(currentLevel, activePlayer.GetScoreHistory())); //Updates the file regardless if scores changed or not. activePlayer.UpdatePlayerInfo(); //Sends high score from scoreHistory to user's best score. If high score is > best score, //best score is overwritten, and file is updated. activePlayer.SetBestScore(activePlayer.GetScoreHistory()[0]); MessageBox.Show("THANK YOU!"); MessageBox.Show("\t\t\tYour new History is:\n" + phm.ProduceUserHistory(activePlayer.GetScoreHistory())); //Reset the level for the next player who logs in. currentLevel = 2; label_game_score.Text = "SCORE/LEVEL : " + currentLevel.ToString(); panel_TitleScreen.Visible = true; panel_Game.Visible = false; tracker.LogEndMessage(); }
//Shows User their Current Score, as well as their top 10 sessions. Updates do not happen here. That is when the player logs out. private void button_game_viewUserHistory_Click(object sender, EventArgs e) { tracker.LogUserHistoryCheckMessage(); string display = String.Format( "===========================================\n" + "||\t\tCURRENT SESSION SCORE: {0}\t\t||\n", currentLevel); //manages scores of player history phm = new PlayerHistoryManager(activePlayer.GetUserName()); display += phm.ProduceUserHistory(activePlayer.GetScoreHistory()); MessageBox.Show(display); }