/// <summary>
        /// Gets the highscores, and resets them when erroneous or missing.
        /// </summary>
        /// <param name="difficulty">Easy, Medium, or Hard. (string)</param>
        /// <param name="difficultyHighScore">outputs High Score variable (string)</param>
        /// <param name="lblHighScoreDifficulty">Name of the label to set (Control)</param>
        public void GetHighScores(string difficulty, out string difficultyHighScore, Control lblHighScoreDifficulty)
        {
            double score;
            string scoreStr;

            // If no save file exists, create a new one with score = -1
            if (!File.Exists(difficulty + "HighScore.txt"))
            {
                StreamWriter HS;
                HS = File.CreateText(difficulty + "HighScore.txt");
                HS.WriteLine(-1);
                Thread.Sleep(50);
                HS.Close();
            }

            // else if file is empty, add new score = -2
            else if (new FileInfo(difficulty + "HighScore.txt").Length == 0)
            {
                StreamWriter HS;
                HS = File.AppendText(difficulty + "HighScore.txt");
                HS.WriteLine(-1);
                Thread.Sleep(50);
                HS.Close();
            }

            // if file contains non-numeric data, create new file with score = -3
            StreamReader HSR;

            HSR      = File.OpenText(difficulty + "HighScore.txt");
            scoreStr = HSR.ReadLine();
            Thread.Sleep(50);
            HSR.Close();
            try
            {
                score = double.Parse(scoreStr);
            }
            catch
            {
                StreamWriter HS;
                HS = File.CreateText(difficulty + "HighScore.txt");
                HS.WriteLine(-1);
                Thread.Sleep(50);
                HS.Close();
                score = -3;
            }

            // if score <= 0, display "N/A" as the high score.
            if (score <= 0)
            {
                difficultyHighScore         = "-1";
                lblHighScoreDifficulty.Text = "N/A";
            }

            // if score > 0, save as difficultyHighScore.
            else
            {
                difficultyHighScore         = score.ToString();
                lblHighScoreDifficulty.Text = score.ToString();
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: radtek/autoxx
        public static void Run()
        {
            while (true)
            {
                try
                {
                    //BTC.Do();
                    BCH.Do();
                    ETH.Do();
                    ETC.Do();
                    LTC.Do();

                    EOS.Do();
                    XRP.Do();
                    OMG.Do();
                    DASH.Do();
                    ZEC.Do();
                    Thread.Sleep(1000 * 5);

                    // 创新
                    ITC.Do();
                    NAS.Do();
                    RUFF.Do();
                    ZIL.Do();
                    DTA.Do();
                    Thread.Sleep(1000 * 5);

                    LET.Do();
                    HT.Do();
                    THETA.Do();
                    HSR.Do();
                    QTUM.Do();
                    Thread.Sleep(1000 * 5);

                    SNT.Do();
                    IOST.Do();
                    NEO.Do();
                    STORJ.Do();
                    GNT.Do();
                    Thread.Sleep(1000 * 5);

                    CVC.Do();
                    SMT.Do();
                    VEN.Do();
                    ELF.Do();
                    XEM.Do();
                    Thread.Sleep(1000 * 5);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }