/// <summary> /// Private constructor of a Session object. /// </summary> /// <remarks> /// The lack of public constructors forces the singleton model. /// </remarks> 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; // create the HUD interface this.hud = new Hud(screenManager); this.hud.LoadContent(); }
/// <summary> /// Start a new session, using the data in the given save game. /// </summary> /// <param name="saveGameDescription">The description of the save game.</param> /// <param name="screenManager">The ScreenManager for the new session.</param> public static void LoadSession(SaveGameDescription saveGameDescription, ScreenManager screenManager, GameplayScreen gameplayScreen) { // check the parameters if (saveGameDescription == null) { throw new ArgumentNullException("saveGameDescription"); } if (screenManager == null) { throw new ArgumentNullException("screenManager"); } if (gameplayScreen == null) { throw new ArgumentNullException("gameplayScreen"); } // end any existing session EndSession(); // create the new session singleton = new Session(screenManager, gameplayScreen); // get the storage device and load the session GetStorageDevice( delegate(StorageDevice storageDevice) { LoadSessionResult(storageDevice, saveGameDescription); }); }
/// <summary> /// Start a new session based on the data provided. /// </summary> public static void StartNewSession(GameStartDescription gameStartDescription, ScreenManager screenManager, GameplayScreen gameplayScreen) { // check the parameters if (gameStartDescription == null) { throw new ArgumentNullException("gameStartDescripton"); } 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); // set up the initial map ChangeMap(gameStartDescription.MapContentName, null); // set up the initial party ContentManager content = singleton.screenManager.Game.Content; singleton.party = new Party(gameStartDescription, content); // load the quest line singleton.questLine = content.Load<QuestLine>( Path.Combine(@"Quests\QuestLines", gameStartDescription.QuestLineContentName)).Clone() as QuestLine; }