#region File Description //----------------------------------------------------------------------------- // Armor.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; #endregion namespace RolePlayingGameData { /// /// Equipment that can be equipped on a FightingCharacter /// to improve their defense. /// public class Armor : Equipment { #region Slot /// /// Slots that a piece of armor may fill on a character. /// /// Only one piece may fill a slot at the same time. public enum ArmorSlot { Helmet, Shield, Torso, Boots, }; /// /// The slot that this armor fills. /// private ArmorSlot slot; /// /// The slot that this armor fills. /// public ArmorSlot Slot { get { return slot; } set { slot = value; } } #endregion #region Description Data /// /// Builds and returns a string describing the power of this armor. /// public override string GetPowerText() { return "Weapon Defense: " + OwnerHealthDefenseRange.ToString() + "\nMagic Defense: " + OwnerMagicDefenseRange.ToString(); } #endregion #region Owner Defense Data /// /// The range of health defense provided by this armor to its owner. /// private Int32Range ownerHealthDefenseRange; /// /// The range of health defense provided by this armor to its owner. /// public Int32Range OwnerHealthDefenseRange { get { return ownerHealthDefenseRange; } set { ownerHealthDefenseRange = value; } } /// /// The range of magic defense provided by this armor to its owner. /// private Int32Range ownerMagicDefenseRange; /// /// The range of magic defense provided by this armor to its owner. /// public Int32Range OwnerMagicDefenseRange { get { return ownerMagicDefenseRange; } set { ownerMagicDefenseRange = value; } } #endregion #region Content Type Reader /// /// Read the Weapon type from the content pipeline. /// public class ArmorReader : ContentTypeReader { protected override Armor Read(ContentReader input, Armor existingInstance) { Armor armor = existingInstance; if (armor == null) { armor = new Armor(); } // read the gear settings input.ReadRawObject(armor as Equipment); // read armor settings armor.Slot = (ArmorSlot)input.ReadInt32(); armor.OwnerHealthDefenseRange = input.ReadObject(); armor.OwnerMagicDefenseRange = input.ReadObject(); return armor; } } #endregion } }