Пример #1
0
        // session load/save stuff
        /// Start a new session, using the data in the given save game.
        /// <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, MainGameScreen introScreen)
        {
            // check the parameters
            if (saveGameDescription == null)
            {
                throw new ArgumentNullException("saveGameDescription");
            }
            if (screenManager == null)
            {
                throw new ArgumentNullException("screenManager");
            }
            if (introScreen == null)
            {
                throw new ArgumentNullException("gameplayScreen");
            }

            // end any existing session
            EndSession();

            // create the new session
            singleton = new Session(screenManager);

            PuzzleEngine.MainScreen.CreditsPanel.LoadContent(screenManager.SessionContent);
            StorageManager.Instance.LoadSession(saveGameDescription.FileName);
        }
Пример #2
0
        /// Delete the save game specified by the description.
        /// <param name="saveGameDescription">The description of the save game.</param>
        public static void DeleteSaveGame(SaveGameDescription saveGameDescription)
        {
            // check the parameters
            if (saveGameDescription == null)
            {
                throw new ArgumentNullException("saveGameDescription");
            }

            // get the storage device and load the session
            StorageManager.Instance.DeleteSaveGame(saveGameDescription);
        }
Пример #3
0
 public static void QuickSave()
 {
     if (PuzzleEngine.MainScreen.SlotPanel.CurrentSlot.SaveGameDescription == null)
     {
         SaveGameDescription sgd = new SaveGameDescription();
         sgd.SaveSlot = PuzzleEngine.MainScreen.SlotPanel.CurrentSlotIdx + 1;
         SaveSession(sgd);
     }
     else
     {
         SaveSession(PuzzleEngine.MainScreen.SlotPanel.CurrentSlot.SaveGameDescription);
     }
 }
Пример #4
0
 /// Save the current state of the session.
 /// <param name="overwriteDescription">
 /// The description of the save game to over-write, if any.
 public static void SaveSession(SaveGameDescription overwriteDescription)
 {
     StorageManager.Instance.SaveSession(overwriteDescription);
 }
Пример #5
0
        private void saveGame()
        {
            try
            {
                // open the container
                using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForDomain())
                {
                    string filename;
                    string descriptionFilename;

                    // get the filenames
                    if (overwriteDescription == null ||
                        overwriteDescription.FileName == null ||
                        overwriteDescription.FileName == "")
                    {
                        filename            = "SaveGame" + overwriteDescription.SaveSlot + ".xml";
                        descriptionFilename = "SaveGameDescription" + overwriteDescription.SaveSlot + ".xml";
                    }
                    else
                    {
                        filename            = overwriteDescription.FileName;
                        descriptionFilename = "SaveGameDescription" + Path.GetFileNameWithoutExtension(overwriteDescription.FileName).Substring(8) + ".xml";
                    }

                    if (isoStore.FileExists(filename))
                    {
                        isoStore.DeleteFile(filename);
                    }

                    using (Stream stream = isoStore.CreateFile(filename))
                    {
                        serializerPlayerSaveData.Serialize(stream, new PlayerSaveData(Session.Player, PuzzleEngine.CurrentPuzzleSet));
                    }

                    // create the save game description
                    SaveGameDescription description = new SaveGameDescription();
                    description.FileName      = Path.GetFileName(filename);
                    description.PuzzlesSolved = PuzzleEngine.CurrentPuzzleSet.Statistics.PuzzlesSolved;
                    description.PuzzlesTotal  = PuzzleEngine.CurrentPuzzleSet.Puzzles.Count;
                    description.SolveTime     = PuzzleEngine.CurrentPuzzleSet.Statistics.SecondsTaken;
                    description.PuzzleSetName = PuzzleEngine.CurrentPuzzleSet.Name;
                    if (SignInManager.Instance.SignedIn)
                    {
                        description.Gamertag = SignInManager.Instance.GamerTag;
                    }
                    else
                    {
                        description.Gamertag = "Save_" + overwriteDescription.SaveSlot;
                    }
                    description.TimeStamp = DateTime.Now;
                    description.SaveSlot  = overwriteDescription.SaveSlot;

                    using (Stream stream = isoStore.CreateFile(descriptionFilename))
                    {
                        serializerSaveGameDescription.Serialize(stream, description);
                    }
                }
            }
            catch (Exception)
            {
//                Debug.WriteLine($"StorageManager#saveGame Exception: {e}");
            }
        }
Пример #6
0
 public void DeleteSaveGame(SaveGameDescription description)
 {
     deleteDescription = description;
     state             = StorageState.ReadyToDelete;
 }
Пример #7
0
 public void SaveSession(SaveGameDescription description)
 {
     overwriteDescription = description;
     state = StorageState.ReadyToSave;
 }