#region File Description //----------------------------------------------------------------------------- // Weapon.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; #endregion namespace RolePlayingGameData { /// /// Equipment that can be equipped on a FightingCharacter /// to improve their physical damage. /// public class Weapon : Equipment { #region Description Data /// /// Builds and returns a string describing the power of this weapon. /// public override string GetPowerText() { return "Weapon Attack: " + TargetDamageRange.ToString(); } #endregion #region Target Damage Data /// /// The range of health damage applied by this weapon to its target. /// /// Damage range values are positive, and will be subtracted. private Int32Range targetDamageRange; /// /// The range of health damage applied by this weapon to its target. /// /// Damage range values are positive, and will be subtracted. public Int32Range TargetDamageRange { get { return targetDamageRange; } set { targetDamageRange = value; } } #endregion #region Sound Effects Data /// /// The name of the sound effect cue played when the weapon is swung. /// private string swingCueName; /// /// The name of the sound effect cue played when the weapon is swung. /// public string SwingCueName { get { return swingCueName; } set { swingCueName = value; } } /// /// The name of the sound effect cue played when the weapon hits its target. /// private string hitCueName; /// /// The name of the sound effect cue played when the weapon hits its target. /// public string HitCueName { get { return hitCueName; } set { hitCueName = value; } } /// /// The name of the sound effect cue played when the weapon is blocked. /// private string blockCueName; /// /// The name of the sound effect cue played when the weapon is blocked. /// public string BlockCueName { get { return blockCueName; } set { blockCueName = value; } } #endregion #region Graphics Data /// /// The overlay sprite for this weapon. /// private AnimatingSprite overlay; /// /// The overlay sprite for this weapon. /// public AnimatingSprite Overlay { get { return overlay; } set { overlay = value; } } #endregion #region Content Type Reader /// /// Read the Weapon type from the content pipeline. /// public class WeaponReader : ContentTypeReader { /// /// Read the Weapon type from the content pipeline. /// protected override Weapon Read(ContentReader input, Weapon existingInstance) { Weapon weapon = existingInstance; if (weapon == null) { weapon = new Weapon(); } // read the gear settings input.ReadRawObject(weapon as Equipment); // read the weapon settings weapon.TargetDamageRange = input.ReadObject(); weapon.SwingCueName = input.ReadString(); weapon.HitCueName = input.ReadString(); weapon.BlockCueName = input.ReadString(); weapon.Overlay = input.ReadObject(); weapon.Overlay.SourceOffset = new Vector2( weapon.Overlay.FrameDimensions.X / 2, weapon.Overlay.FrameDimensions.Y); return weapon; } } #endregion } }