#region File Description //----------------------------------------------------------------------------- // StoreCategory.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Content; #endregion namespace RolePlayingGameData { /// /// A category of gear for sale in a store. /// public class StoreCategory { /// /// The display name of this store category. /// private string name; /// /// The display name of this store category. /// public string Name { get { return name; } set { name = value; } } /// /// The content names for the gear available in this category. /// private List availableContentNames = new List(); /// /// The content names for the gear available in this category. /// public List AvailableContentNames { get { return availableContentNames; } set { availableContentNames = value; } } /// /// The gear available in this category. /// private List availableGear = new List(); /// /// The gear available in this category. /// [ContentSerializerIgnore] public List AvailableGear { get { return availableGear; } set { availableGear = value; } } #region Content Type Reader /// /// Reads a StoreCategory object from the content pipeline. /// public class StoreCategoryReader : ContentTypeReader { /// /// Reads a StoreCategory object from the content pipeline. /// protected override StoreCategory Read(ContentReader input, StoreCategory existingInstance) { StoreCategory storeCategory = existingInstance; if (storeCategory == null) { storeCategory = new StoreCategory(); } storeCategory.Name = input.ReadString(); storeCategory.AvailableContentNames.AddRange( input.ReadObject>()); // populate the gear list based on the content names foreach (string gearName in storeCategory.AvailableContentNames) { storeCategory.AvailableGear.Add(input.ContentManager.Load( System.IO.Path.Combine("Gear", gearName))); } return storeCategory; } } #endregion } }