public void Init()
 {
     ActiveShape = ShapeFactory.CreateRandom(GameMode);
     NextShape   = ShapeFactory.CreateRandom(GameMode);
     LevelNr     = 1;
     Score       = 0;
     Lives       = 2;
     CountDown   = new CountDown(3000, 1000);
     SetRandomBG();
     Grid.Instance = new Grid();
 }
 void LoseLife()
 {
     Lives--;
     if (Lives < 0)
     {
         GameOver();
     }
     else
     {
         Grid.Instance = new Grid();
         ActiveShape   = ShapeFactory.CreateRandom(GameMode);
         NextShape     = ShapeFactory.CreateRandom(GameMode);
     }
 }
        public void Update(GameTime gameTime)
        {
            switch (State)
            {
            case eLevelState.Playing:
                ActiveShape.Update(gameTime);
                if (ActiveShape.IsDisposed)
                {
                    ActiveShape = NextShape;
                    NextShape   = ShapeFactory.CreateRandom(GameMode);
                    if (ActiveShape.CollidesWithOtherBlocks())
                    {
                        LoseLife();
                    }
                }

                // Upgrade level when applicable
                if (Score >= LevelUpLookup[LevelNr])
                {
                    LevelNr++;
                    FallDelayInMS -= LevelDelayDecrementer;
                    Engine.Instance.Audio.PlaySound("levelUp");
                }

                if (Engine.Instance.KB.KeyIsReleased(Keys.Escape))
                {
                    State = eLevelState.QuitConfirm;
                }
                if (Engine.Instance.KB.KeyIsReleased(Keys.B))
                {
                    SetRandomBG();
                }
                break;

            case eLevelState.CountingDown:
                CountDown.Update(gameTime);
                if (CountDown.IsInterval)
                {
                    if (CountDown.TimeLeftSec > 0)
                    {
                        Engine.Instance.Audio.PlaySound("countdown");
                    }
                    else
                    {
                        Engine.Instance.Audio.PlaySound("countdownFinished");
                        State = eLevelState.Playing;
                    }
                }
                break;

            case eLevelState.QuitConfirm:
                if (Engine.Instance.KB.KeyIsReleased(Keys.Y))
                {
                    Engine.Instance.ActiveState = new MainMenu();
                }
                else if (Engine.Instance.KB.KeyIsReleased(Keys.N))
                {
                    State = eLevelState.Playing;
                }
                break;

            default:
                throw new CaseStatementMissingException();
            }
        }