public LevelState()
        {
            currentSeed = Game1.rand.Next();

            state = LoadingState.LevelLoading;

            pushMessageQueue  = new Queue <string>(5);
            messageQueueState = PushMessageQueueState.Wait;

            PresentationParameters pp = AnimationLib.GraphicsDevice.PresentationParameters;

            textureScreen        = new RenderTarget2D(AnimationLib.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, AnimationLib.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24);
            halfTextureScreen    = new RenderTarget2D(AnimationLib.GraphicsDevice, pp.BackBufferWidth / 2, pp.BackBufferHeight / 2, false, AnimationLib.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24);
            quarterTextureScreen = new RenderTarget2D(AnimationLib.GraphicsDevice, pp.BackBufferWidth / 4, pp.BackBufferHeight / 4, false, AnimationLib.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24);

            new Thread(loadLevel).Start();
        }
        private void gameLogicUpdate(Microsoft.Xna.Framework.GameTime currentTime)
        {
            if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.PauseButton) && !player1Dead)
            {
                state = LoadingState.LevelPaused;
                pauseDialogMinimumTime = 0;
                pauseMenuItem          = 0;
                AudioLib.playSoundEffect("monitorOpening");
            }

            if (GameCampaign.Player_Ammunition < 0)
            {
                GameCampaign.Player_Ammunition = 0;
            }
            if (GameCampaign.Player2_Ammunition < 0)
            {
                GameCampaign.Player2_Ammunition = 0;
            }

            if (GameCampaign.Player_Ammunition > 100)
            {
                GameCampaign.Player_Ammunition = 100;
            }
            if (GameCampaign.Player2_Ammunition > 100)
            {
                GameCampaign.Player2_Ammunition = 100;
            }

            if (messageQueueState == PushMessageQueueState.Wait)
            {
                if (pushMessageQueue.Count > 0)
                {
                    messageQueueState = PushMessageQueueState.FadeIn;
                    queueTimer        = 0;
                }
            }
            else if (messageQueueState == PushMessageQueueState.ShowMessage)
            {
                queueTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (queueTimer > 1000f + (25 * pushMessageQueue.Peek().Length))
                {
                    messageQueueState = PushMessageQueueState.FadeOut;
                    queueTimer        = 0;
                }
            }
            else if (messageQueueState == PushMessageQueueState.FadeIn)
            {
                queueTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (queueTimer > 200f)
                {
                    messageQueueState = PushMessageQueueState.ShowMessage;
                    queueTimer        = 0;
                }
            }
            else if (messageQueueState == PushMessageQueueState.FadeOut)
            {
                queueTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (queueTimer > 200f)
                {
                    messageQueueState = PushMessageQueueState.Wait;
                    queueTimer        = 0;
                    pushMessageQueue.Dequeue();
                }
            }

            for (int i = 0; i < entityList.Count; i++)
            {
                if (Vector2.Distance(cameraFocus.CenterPoint, entityList[i].CenterPoint) < 800 || entityList[i] is Player)
                {
                    entityList[i].update(currentTime);
                }
            }

            elapsedLevelTime += currentTime.ElapsedGameTime.Milliseconds;

            particleSet.update(currentTime);

#if WINDOWS
            entityList.RemoveAll(en => en.Remove_From_List == true);
#elif XBOX
            XboxTools.RemoveAll(entityList, XboxTools.IsEntityToBeRemoved);
            XboxTools.RemoveAll(acidSpitters, XboxTools.IsEntityToBeRemoved);
#endif

            if (cameraFocus != null)
            {
                int pointX = (int)cameraFocus.CenterPoint.X;
                int pointY = (int)cameraFocus.CenterPoint.Y;

                camera = Matrix.CreateTranslation(new Vector3((pointX * -1) + (GlobalGameConstants.GameResolutionWidth / 2), (pointY * -1) + (GlobalGameConstants.GameResolutionHeight / 2), 0.0f));
                //camera = Matrix.CreateScale(0.1f);
            }

            gui.update(currentTime);

            if (player1Dead)
            {
                fadeOutTime += currentTime.ElapsedGameTime.Milliseconds;

                gui.BlackFadeOverlay = fadeOutTime / fadeOutDuration;

                if (fadeOutTime >= fadeOutDuration)
                {
                    BackGroundAudio.stopAllSongs();
                    isComplete = true;
                }
            }

            if (endFlagReached)
            {
                BackGroundAudio.stopAllSongs();
                isComplete = true;
            }

#if DEBUG
            if (InputDevice2.IsAnyControllerButtonDown(InputDevice2.PlayerButton.SwitchItem2) != InputDevice2.PlayerPad.NoPad)
            {
                showStats = true;
            }
            else
            {
                showStats = false;
            }
#endif
        }