示例#1
0
            public void Start()
            {
                gameState.SetStartTime(DateTime.Now);

                Gamer.WriteGameLog("Starting the game. Played by " + gameState.GetPlayedBy() + ".");
                GameTimeCycle();

                // Take the snapshot when the game is starting. Can be used when the
                // player loses in the first level.
                gameSaveSnapshots.SetSnapshot(gameSaver.SaveGame(gameState));

                playThread.Start();
            }
示例#2
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();
            }