Exemplo n.º 1
0
        public void NextGame()
        {
            try
            {
                if (CurrentGame != null)
                {
                    CurrentGame.DrawRequest     -= GameDrawRequest;
                    CurrentGame.UpdateUIElement -= GameUpdateUIElement;
                    CurrentGame.Finish();
                }

                history.GamesPlayed++;
                CurrentGame = game_manager.GetPuzzle();
                CurrentGame.SynchronizingObject = SynchronizingObject;
                CurrentGame.DrawRequest        += GameDrawRequest;
                CurrentGame.UpdateUIElement    += GameUpdateUIElement;

                CurrentGame.Begin();

                CurrentGame.GameTime = TimeSpan.Zero;
                Status = SessionStatus.Playing;
            }
            catch (Exception e)
            {
                Console.WriteLine("GameSession.NextGame {0}", e);
            }
        }
Exemplo n.º 2
0
        public void End()
        {
            // Making a deep copy of GameSessionHistory type (base class) for serialization
            player_history.SaveGameSession(history.Copy());

            if (CurrentGame != null)
            {
                CurrentGame.DrawRequest     -= GameDrawRequest;
                CurrentGame.UpdateUIElement -= GameUpdateUIElement;
                CurrentGame.Finish();
            }

            EnableTimer = false;
            timer.SynchronizingObject = null;

            paused      = false;
            CurrentGame = null;
            Status      = SessionStatus.Finished;
        }