public PlayerNameState(GameEngine engine, MainMenuState ms)
        {
            eng = engine;
            mouse = eng.Mouse;
            savedGameStates = new Stack<XmlNodeList>();
            savedGameChoices = new Stack<string>();
            _ms = ms;

            Assembly assembly = Assembly.GetExecutingAssembly();
            
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            lookat = new Vector3(0, 0, 2);
            eye = new Vector3(0, 0, 5);

            _old_state = OpenTK.Input.Keyboard.GetState(); // Get the current state of the keyboard

            eng.StateTextureManager.LoadTexture("menu", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.menu.png"));
            menu = eng.StateTextureManager.GetTexture("menu");

            saveFont = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            saveFont.Options.DropShadowActive = true;

            start_x = saveFont.Measure("Name: ").Width;

            //title = QFont.FromQFontFile("myHappySans.qfont", new QFontLoaderConfiguration(true));
            title = QFont.FromQFontFile("Fonts/myRock.qfont", new QFontLoaderConfiguration(true));
            title.Options.DropShadowActive = true;

            name = "";          

            numOfButtons = savedGameChoices.Count - 1;
        }
        // End Fonts

        public PauseMenuState(GameEngine engine, MainMenuState menustate)
        {
            eng = engine;
            menu = menustate;
            lookat = new Vector3(0, 0, 2);
            eye = new Vector3(0, 0, 5);
//             _p1 = eng.StateTextureManager.GetTexture("p1");
//             _p2 = eng.StateTextureManager.GetTexture("p2");
//             _p3 = eng.StateTextureManager.GetTexture("p3");
//             _p4 = eng.StateTextureManager.GetTexture("p4");

            // QFont
            Assembly assembly = Assembly.GetExecutingAssembly();
            eng.StateTextureManager.LoadTexture("menu", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.menu.png"));
            bg = eng.StateTextureManager.GetTexture("menu");

            _buttons = new List<String>();            
            _buttons.Add("Continue??");
			_buttons.Add("Main Menu");
            _buttons.Add("Quit");
            button = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            button.Options.DropShadowActive = true;
            //title = QFont.FromQFontFile("myHappySans.qfont", new QFontLoaderConfiguration(true));
            title = QFont.FromQFontFile("Fonts/myRock.qfont", new QFontLoaderConfiguration(true));
            title.Options.DropShadowActive = false;
            buttonHighlight = QFont.FromQFontFile("Fonts/myHappySans2.qfont", new QFontLoaderConfiguration(true));
            buttonHighlight.Options.DropShadowActive = true;
            //QFont.CreateTextureFontFiles("Fonts/Rock.TTF", 48, "myRock"); // Use this to create new Fonts that you will texture
            // End QFonts

			// Set the current image to be displayed at 0 which is the first in the sequence
			curFrame = 0.0;


        }
        public override void Update(FrameEventArgs e)
        {
            timeTilMain += e.Time;

			//Minus - Toggle fullscreen
			if(eng.Keyboard[Key.Minus]) {
				eng.toggleFullScreen();
			}

#if DEBUG
			if(eng.Keyboard[Key.Enter]) {
				MainMenuState mms = new MainMenuState(eng);
				mms.loadPlayState(0);
// 				mms.musicFile.Stop();
// 				eng.ChangeState(new PlayState(eng, mms));
// 				eng.GameInProgress = true;
			}
#endif

            if (timeTilMain > 2)
            {
                MainMenuState ms = new MainMenuState(eng);
                //eng.StateTextureManager.Dispose();
                eng.ChangeState(ms);
                //eng.GameInProgress = true;
            }
        }
        public LoadGameState(GameEngine engine, MainMenuState ms)
        {
            eng = engine;
            mouse = eng.Mouse;
            savedGameStates = new Stack<XmlNodeList>();
            savedGameChoices = new Stack<string>();
            _ms = ms;

            Assembly assembly = Assembly.GetExecutingAssembly();
            musicFile = new AudioFile(assembly.GetManifestResourceStream("U5Designs.Resources.Music.Menu.ogg"));
            musicFile.Play();

            // Clear the color to work with the SplashScreen so it doesn't white out
            //GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            lookat = new Vector3(0, 0, 2);
            eye = new Vector3(0, 0, 5);

            _old_state = OpenTK.Input.Keyboard.GetState(); // Get the current state of the keyboard

            eng.StateTextureManager.LoadTexture("menu", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.menu.png"));
            menu = eng.StateTextureManager.GetTexture("menu");

            saveFont = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            saveFont.Options.DropShadowActive = true;

            //title = QFont.FromQFontFile("myHappySans.qfont", new QFontLoaderConfiguration(true));
            title = QFont.FromQFontFile("Fonts/myRock.qfont", new QFontLoaderConfiguration(true));
            title.Options.DropShadowActive = true;

            saveFontHighlighted = QFont.FromQFontFile("Fonts/myHappySans2.qfont", new QFontLoaderConfiguration(true));
            saveFont.Options.DropShadowActive = true;

            //QFont.CreateTextureFontFiles("Fonts/HappySans.ttf", 48, "myHappySans2");

            // Load available saved games
            // Setup saved game data 
            SavedGameDataSetup();

            numOfButtons = savedGameChoices.Count - 1;
        }
        // End Fonts

        public StoryInstructionState(GameEngine engine, MainMenuState menustate)
        {
            cur_page = 0;
            eng = engine;
            menu = menustate;
            lookat = new Vector3(0, 0, 2);
            eye = new Vector3(0, 0, 5);

          
            // QFont
           // Assembly assembly = Assembly.GetExecutingAssembly();
            //eng.StateTextureManager.LoadTexture("menu", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.menu_plain.png"));
            //bg = eng.StateTextureManager.GetTexture("menu");

            _buttons = new List<String>();
			instructions1 = "D - Moves Forward" + Environment.NewLine + "A - Moves Back" + Environment.NewLine + "S - Looks Down";
			instructions2 = "W - Moves Forward" + Environment.NewLine + "A - Moves Left" + Environment.NewLine + "D - Moves Right" + Environment.NewLine +
				"S - Moves Back";
			instructions3 = "Tab - Switch Views" + Environment.NewLine + "Space - Jump" + Environment.NewLine + "Left Mouse - Fire Projectile" + Environment.NewLine +
				"Right Mouse - Spin Attack" + Environment.NewLine + "E - Coconut Grenade" + Environment.NewLine + "ESC - Pause";

//             instructions = "W - Moves Forward in 3D" + Environment.NewLine + "A - Moves Left in 3D" + Environment.NewLine + "D - Moves Right in 3D" + Environment.NewLine +
//                 "    Forward in 2D" + Environment.NewLine + "S - Moves Back in 3D" + Environment.NewLine + "Space - Jump" + Environment.NewLine +
//                 "Left Mouse - Fire Projectile" + Environment.NewLine + "Right Mouse - Spin Attack" + Environment.NewLine + "E - Coconut Grenade" + Environment.NewLine +
//                 "ESC - Pause";
            
            
            //button = QFont.FromQFontFile("Fonts/myStoryWhite.qfont", new QFontLoaderConfiguration(true, false));
            button = QFont.FromQFontFile("Fonts/myStoryBright.qfont", new QFontLoaderConfiguration(true, false));
            
            button.Options.DropShadowActive = false;
            //title = QFont.FromQFontFile("myHappySans.qfont", new QFontLoaderConfiguration(true));
            title = QFont.FromQFontFile("Fonts/myRock.qfont", new QFontLoaderConfiguration(true, false));
            title.Options.DropShadowActive = false;
            //buttonHighlight = QFont.FromQFontFile("Fonts/myHappySans2.qfont", new QFontLoaderConfiguration(true));
            //buttonHighlight.Options.DropShadowActive = true;
            //QFont.CreateTextureFontFiles("Fonts/Rock.TTF", 48, "myRock"); // Use this to create new Fonts that you will texture
            // End QFonts

			// Set the current image to be displayed at 0 which is the first in the sequence
			curFrame = 0.0;
        }
		/// <summary>
		/// PlayState is the state in which the game is actually playing, this should only be called once when a new game is made.
		/// </summary>
		/// <param name="engine">Pointer to the game engine</param>
		public PlayState(GameEngine engine, MainMenuState menustate, int levelID) {
			eng = engine;
			this.menustate = menustate;
            this.levelID = levelID;
            AudioManager.Manager.StopAll();
            AudioManager.Manager = new AudioManager();
			bossMode = false;
			enable3d = false;
			tabDown = false;
			clickdown = false;
			nowBillboarding = false;
			aienabled = true;
			musicenabled = false;

            nextLevelTimer = 0;
            waitingToSwitchLevels = false;           

			pms = new PauseMenuState(eng, menustate);
			effectsList = new List<Effect>(); 
            
		}
        /// <summary>
        /// PlayState is the state in which the game is actually playing, this should only be called once when a new game is made.
        /// </summary>
        /// <param name="engine">Pointer to the game engine</param>
        /// <param name="lvl">the level ID</param>
        public LevelDesignerState(GameEngine engine, MainMenuState menustate, int lvl)
            : base(engine, menustate, lvl)
        {
            //eng.WindowState = WindowState.Normal;
            //eng.WindowBorder = WindowBorder.Fixed;
            current_level = lvl;
            LoadLevel.Load(lvl, this);

            Old_Key_State = Keyboard.GetState();
            //Have to load the next few things here for now because they require the GraphicsContext
            foreach (RenderObject ro in renderList)
            {
                if (ro.is3dGeo)
                {
                    ro.texture.init();
                }
            }

            //HUD Health Bar
            Assembly assembly = Assembly.GetExecutingAssembly();
            eng.StateTextureManager.LoadTexture("Healthbar", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.healthbar_top.png"));
            Healthbar = eng.StateTextureManager.GetTexture("Healthbar");
            eng.StateTextureManager.LoadTexture("bHealth", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.healthbar_bottom.png"));
            bHealth = eng.StateTextureManager.GetTexture("bHealth");

            //initialize camera
            camera = new Camera(eng.ClientRectangle.Width, eng.ClientRectangle.Height, player, this);
            player.cam = camera;



            // undo this when done testing ObjList = LoadLevel.Load(current_level);
            player.inLevelDesignMode = true;
            levelMusic.Stop();

            //Thread t = new Thread(new ThreadStart(CreateLevelDesignForm));
            //t.ApartmentState = ApartmentState.STA;
            //t.Start();
            ObstaclesList = GetItemsFromDir("Obstacles.obstacles.txt");
            EnemiesList = GetItemsFromDir("Enemies.enemies.txt");
            ObjectList.Add(0, ObstaclesList);
            ObjectList.Add(1, EnemiesList);

            _xml_obstacle_list = new Dictionary<int, List<Vector3>>();
            // Add everything from previous list into this list.  Problem is we have no idea what the object is.
            //foreach (GameObject obj in objList)
            //{
            //    if (obj is Obstacle)
            //    {
            //    }
            //}

            _xml_dec_list = new Dictionary<Vector3, int>();
            _xml_enemy_list = new Dictionary<int, List<Vector3>>();
            _xml_sound_list = new Dictionary<string, int>();
            _xml_bg_list = new Dictionary<BackGroundData, int>();
            _xml_boss_area_list = new Dictionary<Vector3, int>();
            _xml_boss_bounds_list = new Dictionary<Vector3, int>();
            _xml_boss_center_list = new Dictionary<Vector3, int>();
            _xml_end_region = new List<Vector3>();

            //StartDesignerThread();
            currentObj = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            currentObj.Options.DropShadowActive = false;
            controls = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            controls.Options.DropShadowActive = false;
            ahSnap = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            ahSnap.Options.DropShadowActive = false;
            whichList = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            whichList.Options.DropShadowActive = false;

            controlsText = new StringBuilder();
            controlsText.AppendLine("WASD - Camera/Character Movement");
            controlsText.AppendLine("Up,Down,Left,Right - Movement selected object");
            controlsText.AppendLine("Mouse Click Left/Right - Select/Add/Remove Objects");
            controlsText.AppendLine("[ ] - Switch Objects");
            controlsText.AppendLine("; - Switch between different objects");
            controlsText.AppendLine("\\ - Switch number of units to move");


        }
 /// <summary>
 /// Called by mouse or keyboard handlers when the user picked a button (by clicking or hitting enter)
 /// </summary>
 internal void handleButtonPress()
 {
     if (lvl == eng.max_level)
     {
         MainMenuState ms = new MainMenuState(eng);
         eng.ChangeState(ms);
     }
     else
     {
         // Go to next level
         MainMenuState ms = new MainMenuState(eng);
         PlayState ps = new PlayState(eng, ms, lvl);
         LoadScreenState ls = new LoadScreenState(eng, ps, lvl);
         eng.ChangeState(ls);
     }
 }
        public GameOverState(MainMenuState prvstate, GameEngine engine, PlayState ps)
        {
            eng = engine;
            menu = prvstate;
            _ps = ps;

            _old_state = OpenTK.Input.Keyboard.GetState();

            lookat = new Vector3(0, 0, 2);
            eye = new Vector3(0, 0, 5);
            xf = 1.0f;
            yf = 1.0f;

            // TO DO: CHANGE THE GAME OVER SCREEN            
            eng.StateTextureManager.RenderSetup();
            Assembly audAssembly = Assembly.GetExecutingAssembly();
            eng.StateTextureManager.LoadTexture("go", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.gameover.png"));
            goBackground = eng.StateTextureManager.GetTexture("go");
            /*
            eng.StateTextureManager.LoadTexture("arrow", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.arrow.png"));
            arrow = eng.StateTextureManager.GetTexture("arrow");
            eng.StateTextureManager.LoadTexture("back2menu", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.btn_backtomenu.png"));
            mainmenu = eng.StateTextureManager.GetTexture("back2menu");
            eng.StateTextureManager.LoadTexture("back2menupress", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.btn_backtomenu_hover.png"));
            menu_pressed = eng.StateTextureManager.GetTexture("back2menupress");
            eng.StateTextureManager.LoadTexture("restartlevel", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.btn_restart.png"));
            restart = eng.StateTextureManager.GetTexture("restartlevel");
            eng.StateTextureManager.LoadTexture("restartlevelpress", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.btn_restart_hover.png"));
            restart_pressed = eng.StateTextureManager.GetTexture("restartlevelpress");
            eng.StateTextureManager.LoadTexture("exitgame", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.btn_exit.png"));
            exit = eng.StateTextureManager.GetTexture("exitgame");
            eng.StateTextureManager.LoadTexture("exitpress", audAssembly.GetManifestResourceStream("U5Designs.Resources.Textures.GameOverTextures.btn_exit_hover.png"));
            exit_pressed = eng.StateTextureManager.GetTexture("exitpress");
             * */

            // QFont
            //Assembly assembly = Assembly.GetExecutingAssembly();
            //eng.StateTextureManager.LoadTexture("menu", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.menu.png"));
            //bg = eng.StateTextureManager.GetTexture("menu");

            _buttons = new List<String>();
            _buttons.Add("Restart Level ??");
            _buttons.Add("Return to Main Menu");
            _buttons.Add("Quit");
            button = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true));
            button.Options.DropShadowActive = true;
            //title = QFont.FromQFontFile("myHappySans.qfont", new QFontLoaderConfiguration(true));
            title = QFont.FromQFontFile("Fonts/myRock.qfont", new QFontLoaderConfiguration(true));
            title.Options.DropShadowActive = false;
            buttonHighlight = QFont.FromQFontFile("Fonts/myHappySans2.qfont", new QFontLoaderConfiguration(true));
            buttonHighlight.Options.DropShadowActive = true;
            //QFont.CreateTextureFontFiles("Fonts/Rock.TTF", 48, "myRock"); // Use this to create new Fonts that you will texture
            // End QFonts

            
            //restart_btn = eng.StateTextureManager.GetTexture("restart");
            
            //quit_btn = eng.StateTextureManager.GetTexture("quit_button");

            arX = -200.0f;
            b1Y = -50.0f;
            b2Y = -100.0f;
            b3Y = -150.0f;

            timeTillNextState = 4;
        }