예제 #1
0
 private void IsLabelHit()
 {
     //Stop Timers
     TimerDown.Stop();
     TimerRemaining.Stop();
     // User Message
     MessageBox.Show("You hit a barrier and lost");
     // Exit App
     Application.Exit();
 }
예제 #2
0
        private void IsGolden_Apple_Hit()
        {
            // Set collision to true
            collision = true;
            // Set Golden Apple True
            Golden_Apple = true;
            // Increment Score
            current_score = current_score + 1000;
            // Display score in Label
            LabelScore.Text = current_score.ToString();
            // Set collision to false
            collision = false;
            // Play end of game sound
            PlayGoldenAppleSound();
            // Stop Timers
            TimerDown.Stop();
            TimerRemaining.Stop();
            // Show message
            MessageBox.Show("Well done you completed the game and scored " + current_score.ToString());
            // New instance of save file
            SaveFileDialog Score_Save = new SaveFileDialog();

            // Write File Name
            Score_Save.FileName = "Score";
            // Filter extension
            Score_Save.Filter = "Text File |*.txt";
            // Dialog Title
            Score_Save.Title = "Save score file";
            // Loop to make sure user saves file
            if (Score_Save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Set Path
                string path = Score_Save.FileName;
                // New BinaryWriter
                StreamWriter BW = new StreamWriter(File.Create(path));
                // Write Line and values
                BW.Write("User scored {0} points in {1} seconds on Apple Runner", current_score, CalculateTimeElapsed(userTime: time_Spent));
                // Dispose
                BW.Dispose();
            }
            // Exit
            Application.Exit();
        }