Example #1
0
        static void TestInitt()
        {
            Console.SetCursorPosition(0, 26);
            Console.WriteLine("Game Over!");
            MaxScore mxscore = new MaxScore();

            mxscore.TestMaxScore();
            Console.ReadLine();
        }
Example #2
0
        static void WriteMaxScore()
        {
            MaxScore mxscore = null;

            mxscore = MaxScore.GetMaxScore();
            int maxscore = mxscore.MyScore;

            Console.SetCursorPosition(51, 1);
            Console.WriteLine("Max score: " + maxscore);
        }
Example #3
0
        static void ReadKeys()
        {
            ConsoleKeyInfo s;

            if (Console.KeyAvailable)
            {
                s = Console.ReadKey(true);
                switch (s.Key)
                {
                case ConsoleKey.UpArrow:
                    if (current != direction.DOWN)
                    {
                        current = direction.UP;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (current != direction.UP)
                    {
                        current = direction.DOWN;
                    }
                    break;

                case ConsoleKey.LeftArrow:
                    if (current != direction.RIGHT)
                    {
                        current = direction.LEFT;
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (current != direction.LEFT)
                    {
                        current = direction.RIGHT;
                    }
                    break;

                case ConsoleKey.P:
                {
                    MaxScore mxscore = new MaxScore();
                    mxscore.TestMaxScore();
                    Environment.Exit(0);
                }
                break;

                default:
                    break;
                }
            }
        }
Example #4
0
        public void TestMaxScore()
        {
            Program prog  = new Program();
            int     score = prog.ReturnScore();

            MaxScore _maxscore = null;

            _maxscore = MaxScore.GetMaxScore();

            if (score > _maxscore.MyScore)
            {
                _maxscore.MyScore = score;
                _maxscore.Save();
            }
        }
Example #5
0
        public static MaxScore GetMaxScore()
        {
            MaxScore maxscore = null;
            string   filename = "settings.xml";

            if (File.Exists(filename))
            {
                using (FileStream fs = new FileStream(filename, FileMode.Open))
                {
                    XmlSerializer xser = new XmlSerializer(typeof(MaxScore));
                    maxscore = (MaxScore)xser.Deserialize(fs);
                    fs.Close();
                }
            }
            else
            {
                maxscore = new MaxScore();
            }
            return(maxscore);
        }