예제 #1
0
        public void CheckHighScore(GameWindow gw)
        {
            int currentScore = Settings.Score;

            // check if the current score is a high score and if it is, write it down and update the label
            if (gw.radioBtnEasy.Checked == true)
            {
                if (currentScore > ScoreReader.ReadScore()["easyScore"])
                {
                    ScoreWriter.WriteEasyScore(currentScore);
                    gw.lblEasyHighScore.Text = "Easy: " + currentScore;
                }
            }
            else if (gw.radioBtnMedium.Checked == true)
            {
                if (currentScore > ScoreReader.ReadScore()["mediumScore"])
                {
                    ScoreWriter.WriteMediumScore(currentScore);
                    gw.lblMediumHighScore.Text = "Medium: " + currentScore;
                }
            }
            else if (gw.radioBtnHard.Checked == true)
            {
                if (currentScore > ScoreReader.ReadScore()["hardScore"])
                {
                    ScoreWriter.WriteHardScore(currentScore);
                    gw.lblHardHighScore.Text = "Hard: " + currentScore;
                }
            }
            // update the highest score label in case the current high score is the biggest of them all
            gw.lblHighestScore.Text = "Highest Score: " + Math.Max(ScoreReader.ReadScore()["easyScore"], Math.Max(ScoreReader.ReadScore()["mediumScore"], ScoreReader.ReadScore()["hardScore"]));
        }
예제 #2
0
        // ScoreReader sr = new ScoreReader();

        public static void WriteEasyScore(int score)
        {
            int    mediumScore = ScoreReader.ReadScore()["mediumScore"];
            int    hardScore   = ScoreReader.ReadScore()["hardScore"];
            string path        = Environment.CurrentDirectory + @"\Score.txt";

            using (StreamWriter sw = File.CreateText(path))
            {
                sw.Write("{0} {1} {2}", score, mediumScore, hardScore);
            }
        }
예제 #3
0
        public void InitializeGame(GameWindow gw)
        {
            gw.backgroundSoundtrack.PlayLooping();
            //set settings to default
            new Settings();
            new Difficulty(100, 16);
            new ScoreReader();
            gw.lblScore.Text           = "Score: " + Settings.Score;
            gw.lblEasyHighScore.Text   = "Easy: " + ScoreReader.ReadScore()["easyScore"];
            gw.lblMediumHighScore.Text = "Medium: " + ScoreReader.ReadScore()["mediumScore"];
            gw.lblHardHighScore.Text   = "Hard: " + ScoreReader.ReadScore()["hardScore"];
            gw.lblHighestScore.Text    = "Highest Score: " + Math.Max(ScoreReader.ReadScore()["easyScore"], Math.Max(ScoreReader.ReadScore()["mediumScore"], ScoreReader.ReadScore()["hardScore"]));

            //Set game speed and start the timer
            gw.gameTimer.Interval = 1000 / Difficulty.GameSpeed;
            gw.gameTimer.Tick    += gw.UpdateScreen;
            gw.gameTimer.Start();

            StartGame(gw);
        }