Пример #1
0
        /// <summary>
        /// Create a new Party object from serialized party data.
        /// </summary>
        public Party(PartySaveData partyData, ContentManager contentManager, ContentManager staticContent)
        {
            // check the parameters
            if (partyData == null)
            {
                throw new ArgumentNullException("partyData");
            }
            if (contentManager == null)
            {
                throw new ArgumentNullException("contentManager");
            }
            content       = contentManager;
            StaticContent = staticContent;

            // load the players
            foreach (PlayerSaveData playerData in partyData.players)
            {
                Player player =
                    contentManager.Load <Player>(playerData.assetName).Clone() as Player;
                player.CharacterLevel = playerData.characterLevel;
                player.Experience     = playerData.experience;
                player.EquippedEquipment.Clear();
                foreach (string equipmentAssetName in playerData.equipmentAssetNames)
                {
                    player.Equip(contentManager.Load <Equipment>(equipmentAssetName));
                }
                player.StatisticsModifiers = playerData.statisticsModifiers;
                JoinParty(player);
            }

            // load the party inventory
            inventory.Clear();
            inventory.AddRange(partyData.inventory);
            foreach (ContentEntry <Gear> entry in inventory)
            {
                entry.Content = contentManager.Load <Gear>(
                    Path.Combine(@"Gear", entry.ContentName));
            }

            // set the party gold
            partyGold = partyData.partyGold;

            // load the monster kills
            for (int i = 0; i < partyData.monsterKillNames.Count; i++)
            {
                monsterKills.Add(partyData.monsterKillNames[i],
                                 partyData.monsterKillCounts[i]);
            }
        }
Пример #2
0
        /// <summary>
        /// Create a new Party object from serialized party data.
        /// </summary>
        public Party(PartySaveData partyData, ContentManager contentManager)
        {
            // check the parameters
            if (partyData == null)
            {
                throw new ArgumentNullException("partyData");
            }
            if (contentManager == null)
            {
                throw new ArgumentNullException("contentManager");
            }

            // load the players
            foreach (PlayerSaveData playerData in partyData.players)
            {
                Player player =
                    contentManager.Load<Player>(playerData.assetName).Clone() as Player;
                player.CharacterLevel = playerData.characterLevel;
                player.Experience = playerData.experience;
                player.EquippedEquipment.Clear();
                foreach (string equipmentAssetName in playerData.equipmentAssetNames)
                {
                    player.Equip(contentManager.Load<Equipment>(equipmentAssetName));
                }
                player.StatisticsModifiers = playerData.statisticsModifiers;
                JoinParty(player);
            }

            // load the party inventory
            inventory.Clear();
            inventory.AddRange(partyData.inventory);
            foreach (ContentEntry<Gear> entry in inventory)
            {
                entry.Content = contentManager.Load<Gear>(
                    Path.Combine(@"Gear", entry.ContentName));
            }

            // set the party gold
            partyGold = partyData.partyGold;

            // load the monster kills
            for (int i = 0; i < partyData.monsterKillNames.Count; i++)
            {
                monsterKills.Add(partyData.monsterKillNames[i],
                    partyData.monsterKillCounts[i]);
            }
        }