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 Font
	{
		Texture2D texture;

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

		public void DrawFont ( SpriteBatch spriteBatch, int value, float x, float y, Color color, bool fillZero )
		{
			string str = ( !fillZero ) ? value.ToString () : String.Format ( "{0:00000000}", value );
			DrawFont ( spriteBatch, str, x, y, color );
		}

		public void DrawFont ( SpriteBatch spriteBatch, string value, float x, float y, Color color )
		{
			string str = value.ToString ();
			float basex = x;
			foreach ( char ch in str )
			{
				int index = ( int ) ( ch - '0' );
				spriteBatch.Draw ( texture, new Vector2 ( basex, y ),
					new Rectangle ( 0, texture.Height / 10 * index, texture.Width, texture.Height / 10 ),
					color );
				basex += texture.Width;
			}
		}
	}
}