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

namespace SpaceWinnie
{
	public class Stone : GameObject
	{
		static Model stone;

		public Stone ( Main game, float x, float z )
			: base ( game )
		{
			this.x = x;
			this.z = z;
			if ( stone == null )
				stone = game.Content.Load<Model> ( "meteorite" );
		}

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

		public override void Draw ( GameTime gameTime )
		{
			foreach ( ModelMesh m in stone.Meshes )
			{
				foreach ( BasicEffect b in m.Effects )
				{
					//b.EnableDefaultLighting ();
					b.LightingEnabled = true;
					b.DirectionalLight0.Enabled = true;
					b.DirectionalLight0.DiffuseColor = GameState.LightYellowVector;
					b.DirectionalLight1.Enabled = true;
					b.DirectionalLight1.DiffuseColor = GameState.LightYellowVector;
					b.DirectionalLight2.Enabled = true;
					b.DirectionalLight2.DiffuseColor = GameState.LightYellowVector;
					b.World = Matrix.CreateRotationX ( rot ) * Matrix.CreateRotationY ( rot ) * Matrix.CreateScale ( 0.01f ) * Matrix.CreateTranslation ( x, 0, z );
					b.View = Main.Camera.ViewMatrix;
					b.Projection = Main.Camera.ProjectionMatrix;
				}

				m.Draw ();
			}
		}
	}
}