Beispiel #1
0
            // uncomment this for random delay between game actions
            //readonly static int[] gamePlayTimeCycles = { 10000, 5000, 20000, 15000, 25000 };

            public static void Play()
            {
                // New game played by Vinny
                Game game = new Game("Vinny");
                GameSaveSnapshots gameSaveSnapshots = new GameSaveSnapshots();

                game.Start();
                Thread.Sleep(getNextGamePlayTimeCycle());
                game.Pause();
                Thread.Sleep(getNextGamePlayTimeCycle());
                game.Resume();
                Thread.Sleep(getNextGamePlayTimeCycle());
                // Pause and exit the game
                GameStateMemento gameStateMemento = game.PauseAndExit();

                gameSaveSnapshots.SetSnapshot(gameStateMemento);
                Thread.Sleep(getNextGamePlayTimeCycle());

                // Resume old game by Sony.
                game = new Game("Sony", gameSaveSnapshots.GetSnapshot());
                game.Resume();
                Thread.Sleep(getNextGamePlayTimeCycle());
                game.Pause();
                Thread.Sleep(getNextGamePlayTimeCycle());
                // Terminate
                game.Exit();

                // New game played by Anny. The game will end itself without any interruptions
                game = new Game("Anny");
                game.Start();
                Console.ReadKey();
            }
Beispiel #2
0
            public Game()
            {
                gameState = new GameState(new Random().Next().ToString(), 1, 0, 0);

                gameSaver             = new GameSaver();
                gameSaveSnapshots     = new GameSaveSnapshots();
                random_gameTimeCycles = new Random();

                playThread = new Thread(new ThreadStart(play));
            }