예제 #1
0
파일: Session.cs 프로젝트: frank44/pewpew
        /// <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();
        }
예제 #2
0
파일: Session.cs 프로젝트: frank44/pewpew
        /// <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();
                }
            }
        }