Exemple #1
0
 int KeyboardUpdate()
 {
     if (Console.KeyAvailable)
     {
         game.DrawMessage("");
         Console.SetCursorPosition(0, 0);
         // Read one key
         ConsoleKeyInfo cki = Console.ReadKey(true);
         if (cki.Key == ConsoleKey.W || cki.Key == ConsoleKey.UpArrow || cki.Key == ConsoleKey.NumPad8)
         {
             return(2);
         }
         else if (cki.Key == ConsoleKey.S || cki.Key == ConsoleKey.DownArrow || cki.Key == ConsoleKey.NumPad2)
         {
             return(0);
         }
         else if (cki.Key == ConsoleKey.A || cki.Key == ConsoleKey.LeftArrow || cki.Key == ConsoleKey.NumPad4)
         {
             return(1);
         }
         else if (cki.Key == ConsoleKey.D || cki.Key == ConsoleKey.RightArrow || cki.Key == ConsoleKey.NumPad6)
         {
             return(3);
         }
         else if (cki.Key == ConsoleKey.F || cki.Key == ConsoleKey.Add)
         {
             game.Event_cheat();
             return(-1);
         }
         else if (cki.Key == ConsoleKey.M)
         {
             game.Event_mute();
             return(-1);
         }
         else if (cki.Key == ConsoleKey.R)
         {
             game.Event_restart();
             return(-1);
         }
         else if (cki.Key == ConsoleKey.O)
         {
             Util.Event_options();
             return(-1);
         }
         else if (cki.Key == ConsoleKey.H)
         {
             Util.Event_help();
             return(-1);
         }
         else if (cki.Key == ConsoleKey.C)
         {
             game.Event_clear();
             return(-1);
         }
         else if (cki.Key == ConsoleKey.V)
         {
             game.Event_victory();
             return(-1);
         }
     }
     return(-1);
 }