using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ShootingHero.Utilities
{
	public class PlayerAnimation
	{
		Texture2D texture;
		int index;
		Timer timer = new Timer ( 100 );
		bool isSuperMode;

		public Texture2D Texture { get { return texture; } set { texture = value; } }
		public bool IsSuperMode { get { return isSuperMode; } set { isSuperMode = value; } }

		public PlayerAnimation ( Texture2D texture )
		{
			this.texture = texture;
		}

		public void Update ( GameTime gameTime )
		{
			timer.Update ( gameTime );
			if ( timer.CheckTimer )
			{
				index++;
				if ( index >= 4 )
					index = 0;
				timer.Reset ();
			}
		}

		public void DrawAnimation ( SpriteBatch spriteBatch, Vector2 vector )
		{
			spriteBatch.Draw ( texture, vector,
				new Rectangle ( index * texture.Width / 4, ( !isSuperMode ) ? 0 : texture.Height / 2,
					texture.Width / 4, texture.Height / 2 ),
				Color.White );
		}
	}
}
