static void TestInitt() { Console.SetCursorPosition(0, 26); Console.WriteLine("Game Over!"); MaxScore mxscore = new MaxScore(); mxscore.TestMaxScore(); Console.ReadLine(); }
static void WriteMaxScore() { MaxScore mxscore = null; mxscore = MaxScore.GetMaxScore(); int maxscore = mxscore.MyScore; Console.SetCursorPosition(51, 1); Console.WriteLine("Max score: " + maxscore); }
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; } } }
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(); } }
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); }