예제 #1
0
        public static GameDossier CreateNewGame()
        {
            GameDossier newGame = new GameDossier();

            newGame.Characters.Add(CreateDefaultCharacter());
            return(newGame);
        }
예제 #2
0
        public static void LoadFromSaveFile(SaveGameDescription saveGameDescription, DossierLoadedDelegate dossierLoadedCallback)
        {
            if (saveGameDescription == null)
            {
                throw new ArgumentNullException("saveGameDescription");
            }
            if (dossierLoadedCallback == null)
            {
                throw new ArgumentNullException("dossierLoadedCallback");
            }

            // get the storage device and load the session
            GetStorageDevice(delegate(StorageDevice storageDevice)
            {
                GameDossier loadedDossier = LoadDossierResult(storageDevice, saveGameDescription);
                dossierLoadedCallback(loadedDossier);
            });
        }
예제 #3
0
        /// <summary>
        /// Receives the storage device and starts a new session,
        /// using the data in the given save game.
        /// </summary>
        /// <remarks>The new session is created in LoadSessionResult.</remarks>
        /// <param name="storageDevice">The chosen storage device.</param>
        /// <param name="saveGameDescription">The description of the save game.</param>
        private static GameDossier LoadDossierResult(StorageDevice storageDevice, SaveGameDescription saveGameDescription)
        {
            if (saveGameDescription == null)
            {
                throw new ArgumentNullException("saveGameDescription");
            }

            if (storageDevice == null)
            {
                throw new ArgumentNullException("storageDevice");
            }

            if (!storageDevice.IsConnected)
            {
                throw new InvalidOperationException("Cannot connect to storage device.");
            }

            GameDossier loadedDossier = new GameDossier();

            // open the container
            using (StorageContainer storageContainer = OpenContainer(storageDevice))
            {
                using (Stream stream = storageContainer.OpenFile(saveGameDescription.FileName, FileMode.Open))
                {
                    using (XmlReader xmlReader = XmlReader.Create(stream))
                    {
                        // <Mechadrone1SaveData>
                        xmlReader.ReadStartElement("Mechadrone1SaveData");

                        /*
                         * // read the map information
                         * xmlReader.ReadStartElement("mapData");
                         * string mapAssetName =
                         *  xmlReader.ReadElementString("mapContentName");
                         * PlayerPosition playerPosition = new XmlSerializer(
                         *  typeof(PlayerPosition)).Deserialize(xmlReader)
                         *  as PlayerPosition;
                         * singleton.removedMapChests = new XmlSerializer(
                         *  typeof(List<WorldEntry<Chest>>)).Deserialize(xmlReader)
                         *  as List<WorldEntry<Chest>>;
                         * singleton.removedMapFixedCombats = new XmlSerializer(
                         *  typeof(List<WorldEntry<FixedCombat>>)).Deserialize(xmlReader)
                         *  as List<WorldEntry<FixedCombat>>;
                         * singleton.removedMapPlayerNpcs = new XmlSerializer(
                         *  typeof(List<WorldEntry<Player>>)).Deserialize(xmlReader)
                         *  as List<WorldEntry<Player>>;
                         * singleton.modifiedMapChests = new XmlSerializer(
                         *  typeof(List<ModifiedChestEntry>)).Deserialize(xmlReader)
                         *  as List<ModifiedChestEntry>;
                         * ChangeMap(mapAssetName, null);
                         * TileEngine.PartyLeaderPosition = playerPosition;
                         * xmlReader.ReadEndElement();
                         *
                         * // read the quest information
                         * ContentManager content = Session.ScreenManager.Game.Content;
                         * xmlReader.ReadStartElement("questData");
                         * singleton.questLine = content.Load<QuestLine>(
                         *  xmlReader.ReadElementString("questLineContentName")).Clone()
                         *  as QuestLine;
                         * singleton.currentQuestIndex = Convert.ToInt32(
                         *  xmlReader.ReadElementString("currentQuestIndex"));
                         * for (int i = 0; i < singleton.currentQuestIndex; i++)
                         * {
                         *  singleton.questLine.Quests[i].Stage =
                         *      Quest.QuestStage.Completed;
                         * }
                         * singleton.removedQuestChests = new XmlSerializer(
                         *  typeof(List<WorldEntry<Chest>>)).Deserialize(xmlReader)
                         *  as List<WorldEntry<Chest>>;
                         * singleton.removedQuestFixedCombats = new XmlSerializer(
                         *  typeof(List<WorldEntry<FixedCombat>>)).Deserialize(xmlReader)
                         *  as List<WorldEntry<FixedCombat>>;
                         * singleton.modifiedQuestChests = new XmlSerializer(
                         *  typeof(List<ModifiedChestEntry>)).Deserialize(xmlReader)
                         *  as List<ModifiedChestEntry>;
                         * Quest.QuestStage questStage = (Quest.QuestStage)Enum.Parse(
                         *  typeof(Quest.QuestStage),
                         *  xmlReader.ReadElementString("currentQuestStage"), true);
                         * if ((singleton.questLine != null) && !IsQuestLineComplete)
                         * {
                         *  singleton.quest =
                         *      singleton.questLine.Quests[CurrentQuestIndex];
                         *  singleton.ModifyQuest(singleton.quest);
                         *  singleton.quest.Stage = questStage;
                         * }
                         * xmlReader.ReadEndElement();
                         *
                         * // read the party data
                         * singleton.party = new Party(new XmlSerializer(
                         *  typeof(PartySaveData)).Deserialize(xmlReader)
                         *  as PartySaveData, content);
                         */

                        // </Mechadrone1SaveData>
                        xmlReader.ReadEndElement();
                    }
                }
            }

            return(loadedDossier);
        }
예제 #4
0
 public static GameDossier CreateNewGame()
 {
     GameDossier newGame = new GameDossier();
     newGame.Characters.Add(CreateDefaultCharacter());
     return newGame;
 }
예제 #5
0
        /// <summary>
        /// Receives the storage device and starts a new session, 
        /// using the data in the given save game.
        /// </summary>
        /// <remarks>The new session is created in LoadSessionResult.</remarks>
        /// <param name="storageDevice">The chosen storage device.</param>
        /// <param name="saveGameDescription">The description of the save game.</param>
        private static GameDossier LoadDossierResult(StorageDevice storageDevice, SaveGameDescription saveGameDescription)
        {
            if (saveGameDescription == null)
                throw new ArgumentNullException("saveGameDescription");

            if (storageDevice == null)
                throw new ArgumentNullException("storageDevice");

            if (!storageDevice.IsConnected)
                throw new InvalidOperationException("Cannot connect to storage device.");

            GameDossier loadedDossier = new GameDossier();
            // open the container
            using (StorageContainer storageContainer = OpenContainer(storageDevice))
            {
                using (Stream stream = storageContainer.OpenFile(saveGameDescription.FileName, FileMode.Open))
                {
                    using (XmlReader xmlReader = XmlReader.Create(stream))
                    {
                        // <Mechadrone1SaveData>
                        xmlReader.ReadStartElement("Mechadrone1SaveData");

                        /*
                        // read the map information
                        xmlReader.ReadStartElement("mapData");
                        string mapAssetName =
                            xmlReader.ReadElementString("mapContentName");
                        PlayerPosition playerPosition = new XmlSerializer(
                            typeof(PlayerPosition)).Deserialize(xmlReader)
                            as PlayerPosition;
                        singleton.removedMapChests = new XmlSerializer(
                            typeof(List<WorldEntry<Chest>>)).Deserialize(xmlReader)
                            as List<WorldEntry<Chest>>;
                        singleton.removedMapFixedCombats = new XmlSerializer(
                            typeof(List<WorldEntry<FixedCombat>>)).Deserialize(xmlReader)
                            as List<WorldEntry<FixedCombat>>;
                        singleton.removedMapPlayerNpcs = new XmlSerializer(
                            typeof(List<WorldEntry<Player>>)).Deserialize(xmlReader)
                            as List<WorldEntry<Player>>;
                        singleton.modifiedMapChests = new XmlSerializer(
                            typeof(List<ModifiedChestEntry>)).Deserialize(xmlReader)
                            as List<ModifiedChestEntry>;
                        ChangeMap(mapAssetName, null);
                        TileEngine.PartyLeaderPosition = playerPosition;
                        xmlReader.ReadEndElement();

                        // read the quest information
                        ContentManager content = Session.ScreenManager.Game.Content;
                        xmlReader.ReadStartElement("questData");
                        singleton.questLine = content.Load<QuestLine>(
                            xmlReader.ReadElementString("questLineContentName")).Clone()
                            as QuestLine;
                        singleton.currentQuestIndex = Convert.ToInt32(
                            xmlReader.ReadElementString("currentQuestIndex"));
                        for (int i = 0; i < singleton.currentQuestIndex; i++)
                        {
                            singleton.questLine.Quests[i].Stage =
                                Quest.QuestStage.Completed;
                        }
                        singleton.removedQuestChests = new XmlSerializer(
                            typeof(List<WorldEntry<Chest>>)).Deserialize(xmlReader)
                            as List<WorldEntry<Chest>>;
                        singleton.removedQuestFixedCombats = new XmlSerializer(
                            typeof(List<WorldEntry<FixedCombat>>)).Deserialize(xmlReader)
                            as List<WorldEntry<FixedCombat>>;
                        singleton.modifiedQuestChests = new XmlSerializer(
                            typeof(List<ModifiedChestEntry>)).Deserialize(xmlReader)
                            as List<ModifiedChestEntry>;
                        Quest.QuestStage questStage = (Quest.QuestStage)Enum.Parse(
                            typeof(Quest.QuestStage),
                            xmlReader.ReadElementString("currentQuestStage"), true);
                        if ((singleton.questLine != null) && !IsQuestLineComplete)
                        {
                            singleton.quest =
                                singleton.questLine.Quests[CurrentQuestIndex];
                            singleton.ModifyQuest(singleton.quest);
                            singleton.quest.Stage = questStage;
                        }
                        xmlReader.ReadEndElement();

                        // read the party data
                        singleton.party = new Party(new XmlSerializer(
                            typeof(PartySaveData)).Deserialize(xmlReader)
                            as PartySaveData, content);
                        */

                        // </Mechadrone1SaveData>
                        xmlReader.ReadEndElement();
                    }
                }
            }

            return loadedDossier;
        }