using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace TankAttack
{
	/// <summary>
	/// This is a game component that implements IUpdateable.
	/// </summary>
	public class ModelManager : Microsoft.Xna.Framework.DrawableGameComponent
	{
		public enum RenderState { Idle, IntroScreen, SetupLevel, RenderLevel, DestroyLevel, LevelCompleteScreen, GameOverScreen };
		List<Tank> tankmodels;
		Level CurrentLevel;
		Ground ground;
		SteelWall steelwall;
		//  BrickWall brickwall;
		Model steelwallmodel;//, brickwallmodel;

		// private SpriteFont Font1;
		KeyboardState kb;
		int face;

		public ModelManager(Game game)
			: base(game)
		{
			// TODO: Construct any child components here
			face = 0;
			RenderState = RenderState.Idle;
		}

		/// <summary>
		/// Allows the game component to perform any initialization it needs to before starting
		/// to run.  This is where it can query for any required services and load content.
		/// </summary>
		public override void Initialize()
		{
			// TODO: Add your initialization code here
			base.Initialize();
		}
		protected override void LoadContent()
		{
			//tankmodels.Add(new TankHuman(Game.Content.Load<Model>(@"Models\olifantRed")));
			//ground.Model = Game.Content.Load<Model>("Models/ground");
			steelwallmodel = Content.Load<Model>(@"Models/steelwall");
			base.LoadContent();
		}

		/// <summary>
		/// Allows the game component to update itself.
		/// </summary>
		/// <param name="gameTime">Provides a snapshot of timing values.</param>
		public override void Update(GameTime gameTime)
		{
			// TODO: Add your update code here
			switch (RenderState)
			{
				case RenderState.Idle:
					break;
				case RenderState.IntroScreen:
					break;
				case RenderState.SetupLevel:
					tankmodels = new List<Tank>();
					aLevel = new Level(1, GameConstants.lvl1map, GameConstants.lvl1enemy);
					ground = new Ground();
					break;
				case RenderState.RenderLevel:
					break;
				case RenderState.DestroyLevel:
					break;
				case RenderState.LevelCompleteScreen:
					break;
				case RenderState.GameOverScreen:
					break;
			}
			

			//kb = Keyboard.GetState();
			//for (int i = 0; i < tankmodels.Count; i++)
			//{
			//    if (tankmodels.ElementAt(i).returnType() == 0)
			//    {
			//        if (kb.IsKeyDown(Keys.Up))
			//        {                       
			//            tankmodels[i].moveUp(face);
			//            face = 0;
			//        }
			//        if (kb.IsKeyDown(Keys.Down))
			//        {
			//            tankmodels[i].moveDown(face);
			//            face = 1;
			//        }
			//        if (kb.IsKeyDown(Keys.Left))
			//        {
			//           // models[i].rotateLeft();
			//            tankmodels[i].moveLeft(face);
			//            face = 2;
			//        }
			//        if (kb.IsKeyDown(Keys.Right))
			//        {
			//			tankmodels[i].moveRight(face);
			//			face = 3;
			//        }
			//    }
			//}
			base.Update(gameTime);
		}

		public override void Draw(GameTime gameTime)
		{

			//ground.DrawTerrain(ground.Model, ((TankAttackGame)Game).camera);
			//foreach (Tank tm in tankmodels)
			//{                
			//    tm.Draw(((TankAttackGame)Game).camera);

			//}

			//base.Draw(gameTime);
		}
	}
}