Esempio n. 1
0
        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();
            }
        }