Esempio n. 1
0
 public void SaveCurrentCondition(GameField gf)
 {
     using (FileStream fs = new FileStream("game.txt", FileMode.Create, FileAccess.Write))
     {
         XmlSerializer xs = new XmlSerializer(typeof(GameField));
         xs.Serialize(fs, gf);
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            GameField gameField = new GameField();
            GameSaver gameSaver = new GameSaver();

            while (true)
            {
                ConsoleKeyInfo pressedKey = Console.ReadKey();
                switch (pressedKey.Key)
                {
                    case ConsoleKey.UpArrow:
                        gameField.NextStep(0, -1);
                        break;
                    case ConsoleKey.DownArrow:
                        gameField.NextStep(0, 1);
                        break;
                    case ConsoleKey.LeftArrow:
                        gameField.NextStep(-1, 0);
                        break;
                    case ConsoleKey.RightArrow:
                        gameField.NextStep(1, 0);
                        break;
                    case ConsoleKey.F2:
                        gameSaver.SaveCurrentCondition(gameField);
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.SetCursorPosition(0, 0);
                        Console.WriteLine("SAVED");
                        break;
                    case ConsoleKey.F3:
                        gameField = gameSaver.LoadCurrentCondition();
                        gameField.NextStep(0, 0);
                        break;
                    case ConsoleKey.Escape:
                        return;
                }
            }
        }
Esempio n. 3
0
 public void SetField(GameField aGameField)
 {
     _gameField = aGameField;
 }