/// <summary> /// The constructor is private: loading screens should /// be activated via the static Load method instead. /// </summary> private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow, GameScreen[] screensToLoad) { this.loadingIsSlow = loadingIsSlow; this.screensToLoad = screensToLoad; TransitionOnTime = TimeSpan.FromSeconds(1.0); }
/// <summary> /// Activates the loading screen. /// </summary> public static void Load(ScreenManager screenManager, bool loadingIsSlow, params GameScreen[] screensToLoad) { // Tell all the current screens to transition off. foreach (GameScreen screen in screenManager.GetScreens()) screen.ExitScreen(); // Create and activate the loading screen. LoadingScreen loadingScreen = new LoadingScreen(screenManager, loadingIsSlow, screensToLoad); screenManager.AddScreen(loadingScreen); }
/// <summary> /// Create a new game. /// </summary> public Game() { // initialize the graphics system graphics = new GraphicsDeviceManager(this); // configure the content manager Content.RootDirectory = "Content"; // add a gamer-services component, which is required for the storage APIs Components.Add(new GamerServicesComponent(this)); // add the screen manager screenManager = new ScreenManager(this); Components.Add(screenManager); }
/// <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; }
/// <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(); }