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

namespace SpaceWinnie
{
	public enum ItemType
	{ 
		Shield = 0,
		SpeedDown,
		SpeedUp,
		Star,
		Reverse,
	}

	public class Item : GameObject
	{
		static Model [] itemModels;
		ItemType itemType;

		public Item ( Main main, ItemType itemType, float x, float z )
			: base ( main )
		{
			this.x = x;
			this.z = z;
			this.itemType = itemType;

			if ( itemModels == null )
			{
				itemModels = new Model [ 5 ];
				itemModels [ 0 ] = Main.Content.Load<Model> ( "item_shield" );
				itemModels [ 1 ] = Main.Content.Load<Model> ( "item_speeddown" );
				itemModels [ 2 ] = Main.Content.Load<Model> ( "item_speedup" );
				itemModels [ 3 ] = Main.Content.Load<Model> ( "item_star" );
				itemModels [ 4 ] = Main.Content.Load<Model> ( "item_reverse" );

			}
		}

		public override void Update ( GameTime gameTime )
		{
			z += accel;
			rot += gameTime.ElapsedGameTime.Milliseconds / 200.0f;
		}

		public override void Draw ( GameTime gameTime )
		{
			foreach ( ModelMesh m in itemModels [ ( int ) itemType ].Meshes )
			{
				foreach ( BasicEffect b in m.Effects )
				{
					b.EnableDefaultLighting ();
					b.World = Matrix.CreateRotationX ( 3.14f / 2 ) * Matrix.CreateRotationY ( rot ) * Matrix.CreateScale ( 0.01f ) * Matrix.CreateTranslation ( x, 0, z );
					b.View = Main.Camera.ViewMatrix;
					b.Projection = Main.Camera.ProjectionMatrix;
				}

				m.Draw ();
			}
		}
	}
}