#region File Description
//-----------------------------------------------------------------------------
// CharacterLevelDescription.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
{
///
/// The requirements and rewards for each level for a character class.
///
public class CharacterLevelDescription
{
#region Experience Requirements
///
/// The amount of additional experience necessary to achieve this level.
///
private int experiencePoints;
///
/// The amount of additional experience necessary to achieve this level.
///
public int ExperiencePoints
{
get { return experiencePoints; }
set { experiencePoints = value; }
}
#endregion
#region Spell Rewards
///
/// The content names of the spells given to the character
/// when it reaches this level.
///
private List spellContentNames = new List();
///
/// The content names of the spells given to the character
/// when it reaches this level.
///
public List SpellContentNames
{
get { return spellContentNames; }
set { spellContentNames = value; }
}
///
/// Spells given to the character when it reaches this level.
///
private List spells = new List();
///
/// Spells given to the character when it reaches this level.
///
[ContentSerializerIgnore]
public List Spells
{
get { return spells; }
set { spells = value; }
}
#endregion
#region Content Type Reader
///
/// Read a CharacterLevelDescription object from the content pipeline.
///
public class CharacterLevelDescriptionReader :
ContentTypeReader
{
///
/// Read a CharacterLevelDescription object from the content pipeline.
///
protected override CharacterLevelDescription Read(ContentReader input,
CharacterLevelDescription existingInstance)
{
CharacterLevelDescription desc = existingInstance;
if (desc == null)
{
desc = new CharacterLevelDescription();
}
desc.ExperiencePoints = input.ReadInt32();
desc.SpellContentNames.AddRange(input.ReadObject>());
// load all of the spells immediately
foreach (string spellContentName in desc.SpellContentNames)
{
desc.spells.Add(input.ContentManager.Load(
System.IO.Path.Combine("Spells", spellContentName)));
}
return desc;
}
}
#endregion
}
}