Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Animation"/> class.
 /// </summary>
 /// <param name="animation">
 /// The animation.
 /// </param>
 private Animation(Animation animation)
 {
     this.frames = animation.frames;
     this.FramesPerSecond = 5;
 }
Example #2
0
        /// <summary>
        /// Makes a sprite from the given string.
        /// </summary>
        /// <param name="faction"> "Ally" or "Enemy". </param>
        /// <param name="spriteSheet"> The name of the sprite sheet. </param>
        /// <param name="spriteHeight"> The height of each sprite. </param>
        /// <param name="spriteWidth"> The width of each sprite. </param>
        /// <returns>
        /// An AnimatedSprite based on the spritesheet.
        /// </returns>
        private AnimatedSprite MakeSprite(string faction, string spriteSheet, int spriteHeight, int spriteWidth)
        {
            var animations = new Dictionary<AnimationKey, Animation>();

            var animation = new Animation(4, spriteHeight, spriteWidth, 0, 0);
            animations.Add(AnimationKey.Idle, animation);

            animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth);
            animations.Add(AnimationKey.Selected, animation);

            animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 2);
            animations.Add(AnimationKey.Left, animation);

            animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 3);
            animations.Add(AnimationKey.Down, animation);

            animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 4);
            animations.Add(AnimationKey.Up, animation);

            animation = new Animation(4, spriteHeight, spriteWidth, 0, spriteWidth * 5);
            animations.Add(AnimationKey.Right, animation);

            var sprite = new AnimatedSprite(
                this.Content.Load<Texture2D>(@"Textures\Sprites\" + faction + "\\" + spriteSheet),
                animations);

            return sprite;
        }
Example #3
0
        /// <summary>
        /// Clones the animation.
        /// </summary>
        /// <returns>
        /// The cloned animation as an object.
        /// </returns>
        public object Clone()
        {
            var animationClone = new Animation(this);
            animationClone.frameWidth = this.frameWidth;
            animationClone.frameHeight = this.frameHeight;
            animationClone.Reset();

            return animationClone;
        }