#region File Description //----------------------------------------------------------------------------- // Animation.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 System.Diagnostics; #endregion namespace RolePlayingGameData { /// /// An animation description for an AnimatingSprite object. /// #if !XBOX [DebuggerDisplay("Name = {Name}")] #endif public class Animation : ContentObject { /// /// The name of the animation. /// private string name; /// /// The name of the animation. /// [ContentSerializer(Optional = true)] public string Name { get { return name; } set { name = value; } } /// /// The first frame of the animation. /// private int startingFrame; /// /// The first frame of the animation. /// public int StartingFrame { get { return startingFrame; } set { startingFrame = value; } } /// /// The last frame of the animation. /// private int endingFrame; /// /// The last frame of the animation. /// public int EndingFrame { get { return endingFrame; } set { endingFrame = value; } } /// /// The interval between frames of the animation. /// private int interval; /// /// The interval between frames of the animation. /// public int Interval { get { return interval; } set { interval = value; } } /// /// If true, the animation loops. /// private bool isLoop; /// /// If true, the animation loops. /// public bool IsLoop { get { return isLoop; } set { isLoop = value; } } #region Constructors /// /// Creates a new Animation object. /// public Animation() { } /// /// Creates a new Animation object by full specification. /// public Animation(string name, int startingFrame, int endingFrame, int interval, bool isLoop) { this.Name = name; this.StartingFrame = startingFrame; this.EndingFrame = endingFrame; this.Interval = interval; this.IsLoop = isLoop; } #endregion #region Content Type Reader /// /// Read an Animation object from the content pipeline. /// public class AnimationReader : ContentTypeReader { /// /// Read an Animation object from the content pipeline. /// protected override Animation Read(ContentReader input, Animation existingInstance) { Animation animation = existingInstance; if (animation == null) { animation = new Animation(); } animation.AssetName = input.AssetName; animation.Name = input.ReadString(); animation.StartingFrame = input.ReadInt32(); animation.EndingFrame = input.ReadInt32(); animation.Interval = input.ReadInt32(); animation.IsLoop = input.ReadBoolean(); return animation; } } #endregion } }