public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            KeyboardState       originalKeyboardState  = Keyboard.GetState();
            KeyboardStateCustom keyboardStateCustom    = KeyboardStateCustom.getKeyboardState(originalKeyboardState);
            KeyboardStateCustom oldKeyboardStateCustom = KeyboardStateCustom.getKeyboardState(oldKeyboardState);


            foreach (KeyValuePair <int, GameObject> keyValuePair in TheGame.Instance.gameObjects)
            {
                GameObject gameObject = keyValuePair.Value;
                //if (gameObject == TheGame.Instance.player1) continue;

                if (!gameObject.isInitialized)
                {
                    gameObject.LoadContent(graphicsContentLoader);
                }
                gameObject.Update(gameTime);
            }

            if (TheGame.Instance.playerMe != null)
            {
                TheGame.Instance.playerMe.UpdateControl(keyboardStateCustom);
            }


            oldKeyboardState = originalKeyboardState;
        }
        public override void Update(GameTime gameTime)
        {
            TheGame.Instance.Update(gameTime);

            if (lookForLevelStartTimeAndSaveItInAVariable)
            {
                startLevelTime = gameTime.TotalGameTime.TotalSeconds;
                lookForLevelStartTimeAndSaveItInAVariable = false;
            }



            KeyboardState       originalKeyboardState  = Keyboard.GetState();
            KeyboardStateCustom keyboardStateCustom    = KeyboardStateCustom.getKeyboardState(originalKeyboardState);
            KeyboardStateCustom oldKeyboardStateCustom = KeyboardStateCustom.getKeyboardState(oldKeyboardState);

            // Allows the game to exit

            // TODO: Add your update logic here


//#if DEBUG
            if (originalKeyboardState.IsKeyDown(Keys.Delete) && !oldKeyboardState.IsKeyDown(Keys.Delete))
            {
                TheGame.Instance.isDebug = !TheGame.Instance.isDebug;
            }
            if (originalKeyboardState.IsKeyDown(Keys.PageDown) && !oldKeyboardState.IsKeyDown(Keys.PageDown))
            {
                int id = getLevelIdForLevel(currentLevel);
                if (id > 0)
                {
                    startNthlevel(id - 1);
                }
            }
            if (originalKeyboardState.IsKeyDown(Keys.PageUp) && !oldKeyboardState.IsKeyDown(Keys.PageUp))
            {
                int id = getLevelIdForLevel(currentLevel);
                if (id < Levels.Count)
                {
                    startNthlevel(id + 1);
                }
            }
//#endif

            /*
             * if (originalKeyboardState.IsKeyDown(Keys.R) && !oldKeyboardState.IsKeyDown(Keys.R)) //reset
             * {
             *  int id = getLevelIdForLevel(currentLevel);
             *  startNthlevel(id);
             * }*/

            if (TheGame.Instance.gameState == GameState.FinishLevel)
            {
                levelScreen.Update(gameTime);
                levelScreen.UpdateControl(originalKeyboardState);

                if (levelScreen.ShouldNavigateForward())
                {
                    levelScreen.Reset();
                    TheGame.Instance.gameState = GameState.Game;

                    //load the next level
                    bool thisOneFound = false;
                    bool didItFind    = false;
                    foreach (Level level in Levels)
                    {
                        //if (level.Id == currentLevel.Id)
                        if (level == currentLevel)
                        {
                            thisOneFound = true;
                        }
                        else
                        {
                            if (thisOneFound == true)
                            {
                                currentLevel = level;
                                didItFind    = true;
                                break;
                            }
                        }
                    }

                    if (didItFind == false)
                    {
                        TheGame.Instance.gameState = GameState.Finished;
                        TheGame.Instance.playSound("Win");
                    }
                    else
                    {
                        initLevel(currentLevel);
                    }
                }
            }
            else if (TheGame.Instance.gameState == GameState.Game)
            {
                foreach (KeyValuePair <int, GameObject> keyValuePair in TheGame.Instance.gameObjects)
                {
                    GameObject gameObject = keyValuePair.Value;
                    if (!gameObject.isInitialized)
                    {
                        gameObject.LoadContent(graphicsContentLoader);
                    }
                    gameObject.Update(gameTime);
                }

                //update player controls
                TheGame.Instance.player1.UpdateControl(keyboardStateCustom);
                if (TheGame.Instance.player2 != null)
                {
                    TheGame.Instance.player2.UpdateControl(keyboardStateCustom);
                }


                currentLevel.Update(gameTime);
                currentLevel.UpdateControl(originalKeyboardState);

                if (currentLevel.isComplete())
                {
                    endLevelTime        = gameTime.TotalGameTime.TotalSeconds;
                    levelScreen.Seconds = (int)Math.Round(endLevelTime - startLevelTime);
                    levelScreen.Level   = getLevelIdForLevel(currentLevel);

                    timesForEachLevel[levelScreen.Level] = levelScreen.Seconds;
                    TheGame.Instance.gameState           = GameState.FinishLevel;
                    //levelScreen.Level = currentLevel.Id;
                }
                else
                {
                    foreach (Player player in TheGame.Instance.players)
                    {
                        //fix the player to the map player
                        if (player.getCollisionRectangle().X < 0)
                        {
                            player.setPosX(0);
                        }
                        if (player.getCollisionRectangle().X + player.getCollisionRectangle().Width > TheGame.Instance.map.Size.X)
                        {
                            player.setPosX(TheGame.Instance.map.Size.X - player.getCollisionRectangle().Width);
                        }

                        //VIEWPORT stuff.
                        if (player.getCollisionRectangle().X + player.getCollisionRectangle().Width > TheGame.Instance.Width * 2)
                        {
                            levelScreen.setPos(new Vector2(TheGame.Instance.Width * 2, 0));
                            TheGame.Instance.platform.setPosX(TheGame.Instance.Width * 2);
                            TheGame.Instance.map.Pos = new Vector2(TheGame.Instance.Width * 2, 0);
                        }
                        else if (player.getCollisionRectangle().X + player.getCollisionRectangle().Width > TheGame.Instance.Width)
                        {
                            levelScreen.setPos(new Vector2(TheGame.Instance.Width, 0));
                            TheGame.Instance.platform.setPosX(TheGame.Instance.Width);
                            TheGame.Instance.map.Pos = new Vector2(TheGame.Instance.Width, 0);
                        }


                        // @TODO: fix this

                        if (player.getCollisionRectangle().X < TheGame.Instance.Width)
                        {
                            levelScreen.setPos(new Vector2(0, 0));
                            TheGame.Instance.platform.setPosX(0);
                            TheGame.Instance.map.Pos = new Vector2(0, 0);
                        }
                    }
                }
            }
            else if (TheGame.Instance.gameState == GameState.Finished)
            {
                if (originalKeyboardState.IsKeyDown(Keys.Enter) && !oldKeyboardState.IsKeyDown(Keys.Enter))
                {
                    FinalGameScreenFinishedNextActionExecute();
                }
            }

            if (keyboardStateCustom.IsKeyDown(KeysMe.PauseGame) && !oldKeyboardStateCustom.IsKeyDown(KeysMe.PauseGame) && TheGame.Instance.gameState == GameState.Game)
            {
                TheGame.Instance.gameState = GameState.Paused;
            }
            else if (keyboardStateCustom.IsKeyDown(KeysMe.PauseGame) && !oldKeyboardStateCustom.IsKeyDown(KeysMe.PauseGame) && TheGame.Instance.gameState == GameState.Paused)
            {
                TheGame.Instance.gameState = GameState.Game;
            }

            oldKeyboardState = originalKeyboardState;
        }