using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace StardustCore.Animations { public class Animation { public Rectangle sourceRectangle; public readonly int frameDuration; public int frameCountUntilNextAnimation; /// /// Constructor that causes the animation frame count to be set to -1; This forces it to never change. /// /// The draw source for this animation. public Animation(Rectangle SourceRectangle) { sourceRectangle = SourceRectangle; frameDuration = -1; } /// /// Constructor. /// /// The draw source for this animation. /// How many on screen frames this animation stays for. Every draw frame decrements an active animation by 1 frame. Set this to -1 to have it be on the screen infinitely. public Animation(Rectangle SourceRectangle,int existForXFrames) { sourceRectangle = SourceRectangle; frameDuration = existForXFrames; } /// /// Decrements the amount of frames this animation is on the screen for by 1. /// public void tickAnimationFrame() { frameCountUntilNextAnimation--; } /// /// This sets the animation frame count to be the max duration. I.E restart the timer. /// public void startAnimation() { frameCountUntilNextAnimation = frameDuration; } } }