private static void GameEndField(System.Timers.Timer t, System.Timers.Timer v) { v.Stop(); t.Stop(); field1.ClearField(); Console.ForegroundColor = ConsoleColor.White; Console.Clear(); Console.WriteLine("\n\n\n Game Over"); Console.WriteLine(" :(\n"); Console.WriteLine(" time spent(m.s.ms): " + (int)(totaltime / 60000) + "." + (int)((totaltime / 1000) % 60) + "." + totaltime % 1000 + "\n"); Console.WriteLine(" orbs collected: " + field1.Orbs + "\n"); Console.WriteLine(" total points: " + (int)(field1.Orbs * 233 + 60000 * clearedfields / Math.Sqrt(totaltime)) + "\n\n"); Console.WriteLine(" press N to add your score to the Hall of fame"); Console.WriteLine(" press R to retry"); Console.WriteLine(" M to return to main menu"); Console.WriteLine(" ESC to exit the game"); clearedfields = 0; var ch = Console.ReadKey(true).Key; //var ch = Console.Read(); switch (ch) { case ConsoleKey.R: //case 'r': startgame = true; field1.Orbs = 0; endgame = false; Console.Clear(); break; case ConsoleKey.M: //case 'm': endgame = false; startgame = false; mainmenu = true; break; case ConsoleKey.N: //System.IO.StreamWriter file = new System.IO.StreamWriter(@"Records.txt"); //FileStream stream = new FileStream(@"Records.txt", FileMode.Open, FileAccess.Write, FileShare.None); string line = InputBox.Show(); //TextWriter writer = new StreamWriter(stream); line += " - " + (int)(field1.Orbs * 233 + 60000 * clearedfields / Math.Sqrt(totaltime)) + "\n"; File.AppendAllText("Records.txt", line); //writer.Write(line); //writer.Close(); endgame = false; startgame = false; mainmenu = true; break; case ConsoleKey.Escape: //case 'e': Environment.Exit(0); break; } //endgame = false; //Console.Clear(); }
void GameEndField() { field1.ClearField(); t.Stop(); v.Stop(); label1.Text = ""; label1.Text = "\n\n\n Game Over" + " :(\n" + " time spent(m.s.ms): " + (int)(totaltime / 60000) + "." + (int)((totaltime / 1000) % 60) + "." + totaltime % 1000 + "\n" + " orbs collected: " + field1.Orbs + "\n" + " total points: " + (int)(field1.Orbs * 233 + 60000 * clearedfields / Math.Sqrt(totaltime)) + "\n\n" + " press ESC to exit the game\n R to quit to main menu"; clearedfields = 0; }