Ejemplo n.º 1
0
        /// <summary>
        /// Private constructor of a Session object.
        /// </summary>
        private Session(ScreenManager screenManager, GameplayScreen gameplayScreen)
        {
            // check the parameter
            if (screenManager == null)
            {
                throw new ArgumentNullException("screenManager");
            }
            if (gameplayScreen == null)
            {
                throw new ArgumentNullException("gameplayScreen");
            }

            // assign the parameter
            this.screenManager = screenManager;
            this.gameplayScreen = gameplayScreen;
        }
Ejemplo n.º 2
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();
        }