private void IsLabelHit()
 {
     //Stop Timers
     TimerDown.Stop();
     TimerRemaining.Stop();
     // User Message
     MessageBox.Show("You hit a barrier and lost");
     // Exit App
     Application.Exit();
 }
        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();
        }
Exemple #3
0
        private void TimerDown_Tick(object sender, EventArgs e)
        {
            counterdown++;
            if (counterdown == 6)
            {
                TimerDown.Stop();
                TimerUp.Enabled = true;
                counterdown     = 0;
            }
            string winner = Winner();

            if (winner == "player")
            {
                PicBoxPlayerPokemonChoice.Location = new Point(PicBoxPlayerPokemonChoice.Location.X, PicBoxPlayerPokemonChoice.Location.Y + 5);
            }
            if (winner == "opponent")
            {
                PicBoxOpponentPokemon.Location = new Point(PicBoxOpponentPokemon.Location.X, PicBoxOpponentPokemon.Location.Y + 5);
            }
        }
        private void TimerDown_Tick(object sender, EventArgs e)
        {
            //  'Uses TimerCountDown variable to minus 1 at a rate of every second to give the illusion of a countdown, Default Value is 50 in the form which means it counts down from 50
            timercountdown = timercountdown - 1;
            //  'Outputs Timer Countdown to Label
            LabelTimeLeft.Text = timercountdown.ToString();
            //'Stops timerdown when countdown reaches 0 and disables it
            if (timercountdown == 0)
            {
                TimerDown.Enabled = false;
                TimerDown.Stop();
            }

            // 'Stops timerdown when Golden_Apple = True, also disables timer
            if (Golden_Apple == true)
            {
                TimerDown.Enabled = false;
                TimerDown.Stop();
            }
        }