Exemplo n.º 1
0
        static void ChooseLoadGame(Caretaker caretaker)
        {
            int            CountLine = 0;
            ConsoleKeyInfo key;

            Memento[] arr = caretaker.games.ToArray();
            do
            {
                Console.Clear();
                for (int i = 0; i < arr.Length; i++)
                {
                    if (i == CountLine)
                    {
                        Console.BackgroundColor = ConsoleColor.Yellow;
                    }
                    Console.WriteLine(arr[i].Name, "   ", arr[i].Dimension);
                    Console.BackgroundColor = ConsoleColor.Black;
                }
                key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.UpArrow:
                    if (CountLine > 0)
                    {
                        CountLine--;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (CountLine < arr.Length)
                    {
                        CountLine++;
                    }
                    break;

                case ConsoleKey.Enter:
                    LoadGame(caretaker, arr[CountLine].Name, arr[CountLine].Dimension);
                    break;
                }
            }while (key.Key != ConsoleKey.Escape);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Caretaker caretaker = new Caretaker();

            Menu(null, null, caretaker, false);
        }
Exemplo n.º 3
0
 static void SaveGame(Game game, Caretaker caretaker)
 {
     caretaker.SaveGame(game.CreateMemento());
 }