#region File Description //----------------------------------------------------------------------------- // PartySaveData.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using System.Collections.Generic; using RolePlayingGameData; #endregion namespace RolePlaying { /// /// Serializable data for the state of the party. /// public class PartySaveData { /// /// The serializable data for all party members. /// public List players = new List(); /// /// The asset names of all party gear. /// public List> inventory = new List>(); /// /// The amount of gold held by the party. /// public int partyGold; /// /// The names of the monsters killed so far during the active quest. /// /// /// Dictionaries don't serialize easily, so the party data is stored separately. /// public List monsterKillNames = new List(); /// /// The kill-counts of the monsters killed so far during the active quest. /// /// /// Dictionaries don't serialize easily, so the party data is stored separately. /// public List monsterKillCounts = new List(); #region Initialization /// /// Creates a new PartyData object. /// public PartySaveData() { } /// /// Creates a new PartyData object from the given Party object. /// public PartySaveData(Party party) : this() { // check the parameter if (party == null) { throw new ArgumentNullException("party"); } // create and add the serializable player data foreach (Player player in party.Players) { players.Add(new PlayerSaveData(player)); } // add the items inventory.AddRange(party.Inventory); // store the amount of gold held by the party partyGold = party.PartyGold; // add the monster kill data for the active quest foreach (string monsterName in party.MonsterKills.Keys) { monsterKillNames.Add(monsterName); monsterKillCounts.Add(party.MonsterKills[monsterName]); } } #endregion } }