// Archontia Anna Tsapanidou, NTU - MSc Computer Games Systems 2008-2009

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;

namespace TankAttack
{
	#region GameObject Class
	abstract class GameObject
    {
		public TankAttackGame game;
		public Model Model;
		protected float WallScale = 5.0f;
		public Vector3 Position;// { get; set; }
		protected Matrix world = Matrix.Identity;
		public Texture2D texture;
		public Color colour;
		public virtual bool Intersect(BoundingSphere bSphere)
		{
			return false;
		}
		public virtual bool Intersect(BoundingBox bBox)
		{
			return false;
		}
		public bool alive;
		public virtual void loseHealth(int amount)
		{
		}
		public virtual int calculateHealth(GameConstants.FirePowerType attacker)
		{
			return -1;
		}
		public virtual void Draw(Camera camera){}
		public virtual Matrix GetWorld()
		{
			return world * rotation;
		}
        public GameObject()
        {
            Model = null;
			alive = true;
            Position = Vector3.Zero;
        }
		Matrix rotation = Matrix.Identity;

	}
	#endregion

	#region Tank Class (derived from GameObject)
	abstract class Tank : GameObject 
    {
        public GameConstants.TankType ttype; // human or CPU
        public GameConstants.FirePowerType fptype; // weak,normal,strong
        public int health;
		public int lives;
		public int points;
		public Model sphereModel;
		public Model bulletModel;
		public BoundingBox boundingBox;
		public Vector3 Direction;
		Vector3 ModelDirection = new Vector3(0, 0, -1);
		public Bullet bullet;
		public InputControl Ctrl;
		public int playerIndex;
		public bool shieldOn;
		public bool frozen;
		public bool alarm;
        public bool cueFlag;
	
		public override bool Intersect(BoundingSphere bSphere)
		{
			return boundingBox.Intersects(bSphere);
		}
		public override bool Intersect(BoundingBox bBox)
		{
			return boundingBox.Intersects(bBox);
		}

        public Tank()
        {
            Position = Vector3.Zero;
            Model = new Model();
            health = 100;
            ttype = GameConstants.TankType.NONE;
            fptype = GameConstants.FirePowerType.NONE;
			Direction = new Vector3(0, 0, -1);
			lives = 1;
			playerIndex = 0;
			points = 0;
			shieldOn = false;
			frozen = false;
			alarm = false;
            cueFlag = false;
        }
        
        public Tank( Model m, 
			         GameConstants.TankType _ttype, 
                     GameConstants.FirePowerType _fptype, 
			         Vector3 _position, 
			         int _lives,
					 int _playerIndex,
					 int _points )
        {
            Model = m;
            health = 100;
			lives = _lives;
			playerIndex = _playerIndex;
			points = _points;
            ttype = _ttype;
            fptype = _fptype;
            Position = _position;
			boundingBox = new BoundingBox(Position - new Vector3(2.0f, 0, 4.8f), Position + new Vector3(2.0f, 0, 4.8f));
			Direction = new Vector3(0, 0, -1.0f);
			shieldOn = false;
			alarm = false;
		}
       
		public virtual void control()
		{
		
		}

		public void loseLife()
		{
			alive = false;
			downgrade();

			if (lives-- > 0)
			{
				health = 100;
			}
			else
			{
				boundingBox.Max = new Vector3(0f, -100f, 0f);
				boundingBox.Min = new Vector3(0f, -100f, 0f);
			}
		}

		public override void loseHealth(int amount)
		{
			if (shieldOn == true)
			{
				return;
			}
			else
			{
				health -= amount;

				if (health <= 0)
				{
					loseLife();
				}
			}
		}

		public void gainHealth(int amount)
		{ 
			int temp = health + amount;
			
			if (temp > 100)
				health = 100;
			else
				health = temp;
		}

		public void upgrade()
		{
			if (fptype != GameConstants.FirePowerType.STRONG)
			{
				fptype++;
			}
		}

		public void downgrade()
		{
			if (fptype != GameConstants.FirePowerType.WEAK)
			{
				fptype--;
			}
		}

        public override void Draw(Camera camera)
        {
			if (alive == false)
				return;
            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(transforms);

			float Angle = (float) Math.Acos(Vector3.Dot(ModelDirection, Direction));

			if (Direction.X != 0)
			{
				Angle *= -Direction.X;
			}

			foreach (ModelMesh mesh in Model.Meshes)
			{
				foreach (BasicEffect be in mesh.Effects)
				{
					be.EnableDefaultLighting();
					be.PreferPerPixelLighting = true;
					be.Alpha = 1.0f;
					be.Projection = camera.projection;
					be.View = camera.view;
					be.World = GetWorld() * Matrix.CreateRotationY(Angle) * mesh.ParentBone.Transform /** Matrix.CreateScale(0.45f) */* Matrix.CreateTranslation(Position);

					mesh.Draw();
				}
			}
        }

        public void rotate(int degrees)
        {
            world *= Matrix.CreateRotationY(MathHelper.ToRadians(degrees));
        }

        public GameConstants.TankType returnType()
        {
			return ttype;
        }

		public override int calculateHealth(GameConstants.FirePowerType attacker)
		{
			if ( attacker == GameConstants.FirePowerType.WEAK)
			{
				if (this.fptype == GameConstants.FirePowerType.WEAK)
					return 25;
				if (this.fptype == GameConstants.FirePowerType.NORMAL)
					return 15;
				if (this.fptype == GameConstants.FirePowerType.STRONG)
					return 5;
			}

			if (attacker == GameConstants.FirePowerType.NORMAL)
			{
				if (this.fptype == GameConstants.FirePowerType.WEAK)
					return 50;
				if (this.fptype == GameConstants.FirePowerType.NORMAL)
					return 25;
				if (this.fptype == GameConstants.FirePowerType.STRONG)
					return 20;
			}
			if (attacker == GameConstants.FirePowerType.STRONG)
			{
				if (this.fptype == GameConstants.FirePowerType.WEAK)
					return 50;
				if (this.fptype == GameConstants.FirePowerType.NORMAL)
					return 25;
				if (this.fptype == GameConstants.FirePowerType.STRONG)
					return 10;
			}
			return 0; // friendly fire
		}
		
		public bool getState()
		{
			return alive;
		}
		public virtual int getScore()
		{
			return -1;
		}
		public virtual void shoot()
        {
			int temp = 0;

			if (this.fptype == GameConstants.FirePowerType.WEAK)
			{
				temp = 1;
			}
			if (this.fptype == GameConstants.FirePowerType.NORMAL)
			{
				temp = 2;
			}
			if (this.fptype == GameConstants.FirePowerType.STRONG)
			{
				temp = 3;
			}

			if (bullet == null)
			{
				bullet = new Bullet(bulletModel, Position + Direction, Direction, temp);
                if (this.ttype == GameConstants.TankType.HUMAN)
                {
                    cueFlag = true;
                }
			}
		}
		public virtual void scoring(int amount)
		{
		
		}
	}
	#endregion

	#region TankHuman Class (derived from Tank)
	class TankHuman : Tank
    {
		public int score;
		public Vector3 spawnPosition;
		public TankHuman()
        {
            Model = new Model();
            health = 100;
            ttype = GameConstants.TankType.HUMAN;
            fptype = GameConstants.FirePowerType.WEAK;
            lives = 3;
            points = 0;
			score = 0;
            playerIndex = 1;
			Position = Vector3.Zero;
			boundingBox = new BoundingBox(Position - new Vector3(2.0f, 0, 4.8f), Position + new Vector3(2.0f, 0, 4.8f));
			Ctrl = null;
		}

        public TankHuman(Model m, 
			             GameConstants.FirePowerType _fptype, 
			             Vector3 _spawnPosition,
						 int _lives, 
						 int _playerIndex,
						 InputControl ctrl)
        {
            Model = m;
            health = 100;
            ttype =  GameConstants.TankType.HUMAN;
            fptype = _fptype;
            lives = _lives;
			playerIndex = _playerIndex;
			points = 0;
			score = 0;
			spawnPosition = _spawnPosition;
            Position = _spawnPosition;
			boundingBox = new BoundingBox(Position - new Vector3(2.0f, 0, 4.8f), Position + new Vector3(2.0f, 0, 4.8f));
			Ctrl = ctrl;
		}

		public override int getScore()
		{
			return score;
		}

		public override void scoring(int amount)
		{
			score += amount;
		}
	}
	#endregion

	#region TankCPU Class (derived from Tank)
	class TankCPU : Tank
	{
		public bool bumped;
		Random random = new Random();
		public TankCPU()
		{
			Model = new Model();
			health = 100;
			ttype = GameConstants.TankType.CPU;
			fptype = GameConstants.FirePowerType.WEAK;
			alive = true;
			playerIndex = 0;
			points = 0;
			lives = 1;
			Position = Vector3.Zero;
			bumped = true;
		}

		public TankCPU(Model m,
					   GameConstants.FirePowerType _fptype,
					   Vector3 _position,
					   int _lives,
					   InputControl ctrl,
						int _points)
		{
			Model = m;
			health = 100;
			ttype = GameConstants.TankType.CPU;
			fptype = _fptype;
			alive = true;
			lives = _lives;
			playerIndex = 0;
			points = _points;
			Position = _position;
			boundingBox = new BoundingBox(Position - new Vector3(2.0f, 0, 4.8f), Position + new Vector3(2.0f, 0, 4.8f));
			Ctrl = ctrl; //DummyControl();
			bumped = true;
		}

		public override void control()
		{
			int temp;

			if (bumped == true)
			{
				if ( random.Next(2) < 1 )
					((AIControl)Ctrl).fire = true;			

				// move towards the centre
				if (Position.X > 0f)
				{
					temp = random.Next(100);
					
					if (temp <= 0 && temp < 25)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.NORTH;
					}
					if (temp >= 25 && temp < 50)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.SOUTH;
					}
					if (temp >= 50 && temp < 60)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.EAST;
					}
					if (temp >= 60 && temp < 100) // increment this
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.WEST;
					}
				}
				
				if (Position.X < 0f )
				{
					temp = random.Next(100);

					if ( temp <= 0 && temp < 20 )
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.NORTH;
					}
					if (temp >=20 && temp < 45 )
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.SOUTH;
					}
					if (temp >= 45 && temp < 75) // increment this
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.EAST;
					}
					if (temp >= 75 && temp < 100)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.WEST;
					}
				}
			}
			/*
			if (alarm == true) // base under attack
			{
				temp = random.Next(100);

				if (random.Next(2) < 1)
					((AIControl)Ctrl).fire = true;

				if (bumped == true)
				{
					if (temp <= 0 && temp < 45)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.NORTH;
					}
					if (temp >= 45 && temp < 55)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.SOUTH;
					}
					if (temp >= 55 && temp < 75)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.EAST;
					}
					if (temp >= 75 && temp < 100)
					{
						((AIControl)Ctrl).moveState = AIControl.MoveState.WEST;
					}
				}
			}
			*/
			if ( random.Next()%10 < 4 )
				((AIControl)Ctrl).fire = true;
		}
	}
	#endregion

	#region Wall Class (derived from GameObject)
	class Wall : GameObject
    {
        public GameConstants.ObjectType type;
        public int health;
		public bool reinforced;
		public BoundingBox boundingBox;
		
		public override bool Intersect(BoundingSphere bSphere)
		{
			return boundingBox.Intersects(bSphere);
		}
		public override bool Intersect(BoundingBox bBox)
		{
			return boundingBox.Intersects(bBox);
		}

        public Wall()
        {
            type = GameConstants.ObjectType.EMPTY;
            Model = null;
			texture = null;
            Position = Vector3.Zero;
            health = 0;
            alive = false;
			reinforced = false;
			texture = null;
			colour = Color.White;
        }

        public bool getState()
        {
            return alive;
        }

        public override void loseHealth(int amount)
        {
            int temp = health - amount;

            if (temp <= 0)
            {
                alive = false; // it's destroyed
            }
            else
            {
                health = temp;
                alive = true; // it's not destryoed
            }
        }
		public override void Draw(Camera camera)
		{
			Matrix[] transforms = new Matrix[Model.Bones.Count];
			Model.CopyAbsoluteBoneTransformsTo(transforms);

			foreach (ModelMesh mesh in Model.Meshes)
			{			
				foreach (BasicEffect be in mesh.Effects)
				{
					if (texture != null)
					{
						be.Texture = texture;
						//be.Texture.GenerateMipMaps(TextureFilter.Anisotropic);
						be.TextureEnabled = true;
					}
					//be.DiffuseColor = colour.ToVector3();
					be.EnableDefaultLighting();
					be.PreferPerPixelLighting = true;
					be.Alpha = 1.0f;
					be.Projection = camera.projection;
					be.View = camera.view;
					be.World = GetWorld() * mesh.ParentBone.Transform * Matrix.CreateScale(WallScale) * Matrix.CreateTranslation(Position);
				}
				
				mesh.Draw();
			}
		}
	}
	#endregion

	#region BrickWall Class (derived from Wall)
	class BrickWall : Wall
    { 
        public BrickWall( Model m, Vector3 _position, Texture2D _texture, Color _colour )
        {
            type = GameConstants.ObjectType.BRICK;
			colour = _colour;
            Model = m;
            Position = _position;
			boundingBox = new BoundingBox(Position - new Vector3(5.0f,0,5.0f), Position + new Vector3(5.0f,0,5.0f));
            health = 100;
			alive = true;
			texture = _texture;
        }

		public override int calculateHealth(GameConstants.FirePowerType attacker)
        {
            return 100;
        }
	}
	#endregion

	#region SteelWall Class (derived from Wall)
	class SteelWall : Wall
    {
		public SteelWall(Model m, Vector3 _position, Texture2D _texture, Color _colour)
        {
            type = GameConstants.ObjectType.STEEL;
			colour = _colour;
            Model = m;
            Position = _position;
			boundingBox = new BoundingBox(Position - new Vector3(5.0f, 0, 5.0f), Position + new Vector3(5.0f, 0, 5.0f));
			health = 100;
			alive = true;
			texture = _texture;
        }
        
        // attackertype
        public override int calculateHealth(GameConstants.FirePowerType attacker)
        {            
            if (attacker == GameConstants.FirePowerType.WEAK)
                return 0;
            else
                return 100;
        }
	}
	#endregion

	#region Base Class (derived from Wall)
	class Base : Wall
    {  
		public Base(Model m, Vector3 _position, GameConstants.ObjectType _type, Texture2D _texture, Color _colour)
        {
            type = _type;
			colour = _colour;
			Model = m;
            Position = _position;
            boundingBox = new BoundingBox(Position - new Vector3(5.0f, 0, 5.0f), Position + new Vector3(5.0f, 0, 5.0f));
			health = 100;            
            reinforced = false;
			alive = true;
			texture = _texture;
        }

		// attackertype
        public override int calculateHealth(GameConstants.FirePowerType attacker)
        {
            if (reinforced == false )
            {
                if (attacker == GameConstants.FirePowerType.WEAK )
                    return 10;

                else if (attacker == GameConstants.FirePowerType.NORMAL)
                    return 20;
                else 
                    return 30;
            }
            else
            {
                if (attacker == GameConstants.FirePowerType.WEAK)
                    return 5;

                else if (attacker == GameConstants.FirePowerType.NORMAL)
                    return 10;
                else
                    return 15;
            }
         }
	}
	#endregion

	#region Border Class (derived from Wall)
	class Border : Wall
	{
		public Border(Model m, Vector3 _position, Texture2D _texture, Color _colour)
        {
            Model = m;
			colour = _colour;
			Position = _position;
			boundingBox = new BoundingBox(Position - new Vector3(5.0f, 0, 5.0f), Position + new Vector3(5.0f, 0, 5.0f));
			alive = true;
			health = 100;
			texture = _texture;
		}
		public override int calculateHealth(GameConstants.FirePowerType attacker)
		{
			return 0;
		}
	}
	#endregion
	
	#region BonusItem Class (derived from GameObject)
	class BonusItem : GameObject 
    {
        public GameConstants.BonusType type;
       	public BoundingBox boundingBox;

        public BonusItem()
        {
            texture = null;
            Model = null;
            Position = Vector3.Zero;
            type = GameConstants.BonusType.NONE;
			boundingBox = new BoundingBox();
        }

        public BonusItem(Model m, GameConstants.BonusType _type, Vector3 _position, Texture2D _texture, Color _colour)
        {          
            Model = m;
			colour = _colour;
            Position = _position;
            type = _type;
			boundingBox = new BoundingBox(Position - new Vector3(2.5f, 0, 2.5f), Position + new Vector3(2.5f, 0, 2.5f));
			texture = _texture;
        }

		public override void Draw(Camera camera)
		{
			Matrix[] transforms = new Matrix[Model.Bones.Count];
			Model.CopyAbsoluteBoneTransformsTo(transforms);

			foreach (ModelMesh mesh in Model.Meshes)
			{
				foreach (BasicEffect be in mesh.Effects)
				{
					be.Texture = texture;
					be.TextureEnabled = true;
					//be.DiffuseColor = colour.ToVector3();
					be.EnableDefaultLighting();
					be.PreferPerPixelLighting = true;
					be.Alpha = 1.0f;
					be.Projection = camera.projection;
					be.View = camera.view;
					be.World = GetWorld() * mesh.ParentBone.Transform * Matrix.CreateScale(WallScale * 0.75f) * Matrix.CreateTranslation(Position);
				}
				mesh.Draw();
			}
		}
	}
	#endregion

	#region Ground Class (derived from GameObject)
	class Ground : GameObject 
    {
		public Ground(Texture2D _texture)
		{
			texture = _texture;
		}
		public void DrawTerrain(Model model, Camera camera)
		{
			foreach (ModelMesh mesh in model.Meshes)
			{
				foreach (BasicEffect be in mesh.Effects)
				{
					be.Texture = texture;
					be.TextureEnabled = true;
					be.EnableDefaultLighting();
					be.PreferPerPixelLighting = true;
					be.Alpha = 1.0f;
					// Use the matrices provided by the game camera
					be.View = camera.view;
					be.Projection = camera.projection;
				}
				mesh.Draw();
			}
		}
	}
	#endregion 

	#region Bullet Class (derived from GameObject)
	class Bullet : GameObject
	{
		public Vector3 trajectory;
		Vector3 ModelDirection = new Vector3(0, 0, -1);
		int bulletEffect;

		public BoundingBox boundingBox;

		public Bullet(Model m, Vector3 _position, Vector3 _trajectory, int _bulletEffect )
        {
            Model = m;
            Position = _position;
			boundingBox = new BoundingBox(Position - new Vector3(0.0f, 0, 2.0f), Position + new Vector3(2.0f, 0, 2.0f));
			trajectory = _trajectory;
			bulletEffect = _bulletEffect;
		}

		public override void Draw(Camera camera)
		{
			Matrix[] transforms = new Matrix[Model.Bones.Count];
			Model.CopyAbsoluteBoneTransformsTo(transforms);

			float Angle = (float)Math.Acos(Vector3.Dot(ModelDirection, trajectory));

			if (trajectory.X != 0)
			{
				Angle *= -trajectory.X;
			}

			foreach (ModelMesh mesh in Model.Meshes)
			{
				foreach (BasicEffect be in mesh.Effects)
				{
					if (bulletEffect == 1)
					{
						be.EnableDefaultLighting();
						be.PreferPerPixelLighting = true;
						be.Alpha = 1.0f;
						be.DiffuseColor = Color.Black.ToVector3();
						be.EmissiveColor = Color.Black.ToVector3();
						be.SpecularColor = Color.Black.ToVector3();
						be.SpecularPower = 16;
						be.Projection = camera.projection;
						be.View = camera.view;
						be.World = GetWorld() * mesh.ParentBone.Transform * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(Angle) * Matrix.CreateScale(GameConstants.bulletScale) * Matrix.CreateTranslation((Position + new Vector3(0, 4, 0)));
					}
					if (bulletEffect == 2)
					{
						be.EnableDefaultLighting();
						be.PreferPerPixelLighting = true;
						be.Alpha = 1.0f;
						be.DiffuseColor = Color.Red.ToVector3();
						be.EmissiveColor = Color.Tomato.ToVector3();
						be.SpecularColor = Color.Orange.ToVector3();
						be.SpecularPower = 16;
						be.Projection = camera.projection;
						be.View = camera.view;
						be.World = GetWorld() * mesh.ParentBone.Transform * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(Angle) * Matrix.CreateScale(GameConstants.bulletScale) * Matrix.CreateTranslation((Position + new Vector3(0, 4, 0)));
					}
					if (bulletEffect == 3)
					{
						be.EnableDefaultLighting();
						be.PreferPerPixelLighting = true;
						be.Alpha = 1.0f;
						be.DiffuseColor = Color.Red.ToVector3();
						be.EmissiveColor = Color.Red.ToVector3();
						be.SpecularColor = Color.Red.ToVector3();
						be.SpecularPower = 16;
						be.Projection = camera.projection;
						be.View = camera.view;
						be.World = GetWorld() * mesh.ParentBone.Transform * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(Angle) * Matrix.CreateScale(GameConstants.bulletScale) * Matrix.CreateTranslation((Position + new Vector3(0, 4, 0)));
					}
				}
				mesh.Draw();
			}
		}
	}
	#endregion

	#region Level Class
	class Level
	{
		public int enemynum { get; set; }
		public int levelnum;
		public int[,] levelmap = new int[GameConstants.BOARDWIDTH, GameConstants.BOARDHEIGHT];
		public List<int> enemyList = new List<int>();
		// public int bonusList[];

		public Level()
		{
			levelnum = 0;
			enemynum = GameConstants.MAXENEMIES;
			foreach (int i in levelmap)
			{
				foreach (int j in levelmap)
				{
					levelmap[i, j] = (int)GameConstants.ObjectType.EMPTY;
				}
			}
			foreach (int i in enemyList)
			{
				enemyList[i] = (int)GameConstants.FirePowerType.NONE;
			}
		}

		public Level(int lvlnumber, int[,] lvlmap, int[] enemymap)
		{
			enemynum = GameConstants.MAXENEMIES;
			levelnum = lvlnumber;
			levelmap = lvlmap;
			enemyList.AddRange(enemymap);
		}
	}
	#endregion

	#region GameMenu Class
	class GameMenu
	{
		private static int MAX = 5;
		private int menuItemCount;
		private int curMenuItem;
		private string[] menuItems;
		private Vector2[] pos;
		private double[] scale;
		private Color unselected;
		private Color selected;
		private SpriteFont font;
		public bool menuUp;
		public bool menuDown;

		public GameMenu(Color unselectedColor, Color selectedColor, SpriteFont sp )
		{
			font = sp;
			menuItems = new string[MAX];
		    pos = new Vector2[MAX];
			scale = new double[MAX];
		    unselected = unselectedColor;
		    selected = selectedColor;
		    menuItemCount = 0;
		    curMenuItem = 0;
			menuUp = false;
			menuDown = false;
		}

		public void addMenuItem(string name, Vector2 p)
		{
			if (menuItemCount < MAX)
			{
				menuItems[menuItemCount] = name;
				scale[menuItemCount] = 1.0f;
				pos[menuItemCount++] = p;
			}
		}
		public void selectNext()
		{
			if (curMenuItem < menuItemCount - 1)
			{
				curMenuItem++;
			}
			else
			{
				curMenuItem = 0;
			}
		}

		public void selectPrev()
		{
			if (curMenuItem > 0)
			{
				curMenuItem--;
			}
			else
			{
				curMenuItem = menuItemCount - 1;
			}
		}
		public int getSelectedNum()
		{
			return curMenuItem;
		}

		public string getSelectedName()
		{
			return menuItems[curMenuItem];
		}
		
		public void update(GameTime gameTime)
		{
			for (int x = 0; x < menuItemCount; x++)
			{
				if (x == curMenuItem)
				{
					if (scale[x] < 2.0f)
					{
						scale[x] += 0.04 + 10.0f * gameTime.ElapsedGameTime.Seconds;
					}
				}
				else if (scale[x] > 1.0f && x != curMenuItem)
				{
					scale[x] -= 0.04 + 10.0f * gameTime.ElapsedGameTime.Seconds;
				}
			}
		}
		public void Draw(SpriteBatch spriteBatch)
		{
			spriteBatch.Begin();
			for (int x = 0; x < menuItemCount; x++)
			{
				if (x == curMenuItem)
				{
					Vector2 p = pos[x];
					p.X -= (float)(22 * scale[x] / 2);
					p.Y -= (float)(22 * scale[x] / 2);
					spriteBatch.DrawString(font,
										   menuItems[x],
										   p,
										   selected,
										   0.0f,
										   new Vector2(0, 0),
										   (float)scale[x],
										   SpriteEffects.None,
										   0);
				}
				else
				{
					Vector2 p = pos[x];
					p.X -= (float)(22 * scale[x] / 2);
					p.Y -= (float)(22 * scale[x] / 2);
					spriteBatch.DrawString(font,
										   menuItems[x],
										   p,
										   unselected,
										   0.0f,
										   new Vector2(0, 0),
										   (float)scale[x],
										   SpriteEffects.None,
										   0);
				}
			}
			spriteBatch.End();
		}
	}
	#endregion

}
