Beispiel #1
0
        /// <summary>
        /// Start a new session based on the data provided.
        /// </summary>
        public static void StartSession(StatisticsManager statisticsManager, 
            ScreenManager screenManager, GameplayScreen gameplayScreen)
        {
            // check the parameters
            if (statisticsManager == null)
            {
                throw new ArgumentNullException("statisticsManager");
            }
            if (statisticsManager.LevelIndex < 0 || statisticsManager.LevelIndex >= Game.totalStages.Length)
            {
                throw new ArgumentNullException("levelIndex");
            }
            if (screenManager == null)
            {
                throw new ArgumentNullException("screenManager");
            }
            if (gameplayScreen == null)
            {
                throw new ArgumentNullException("gameplayScreen");
            }

            // end any existing session
            EndSession();

            // create a new singleton
            singleton = new Session(screenManager, gameplayScreen);

            // load the singleton's stats with the provided stats
            singleton.statisticsManager = statisticsManager;
            singleton.lastSavedStats = new StatisticsManager(statisticsManager);

            // set up the initial level
            LoadLevel();

            // set up the HUD of the game.
            HUD = new HUD();
        }
Beispiel #2
0
        /// <summary>
        /// End the current session.
        /// </summary>
        public static void EndSession()
        {
            // exit the gameplay screen
            // -- store the gameplay session, for re-entrance
            if (singleton != null)
            {
                GameplayScreen gameplayScreen = singleton.gameplayScreen;
                singleton.gameplayScreen = null;

                // clear the singleton
                singleton = null;

                if (gameplayScreen != null)
                {
                    gameplayScreen.ExitScreen();
                }
            }
        }