Esempio n. 1
0
        public void Update(Event ev, TimeSpan gameTime)
        {
            HandleEvent(ev, gameTime);
            if (gameTime - dropTime >= GetGravity())
            {
                HandleEvent(Event.SoftDrop, gameTime);
            }


            if (ev == Event.Quit)
            {
                State = GameState.Quiting;
            }

            if (State == GameState.Clearing && gameTime - clearTime >= ClearDelay)
            {
                UpdateScoreLevel(Board.Clear());
                State = GameState.Running;

                dropTime = gameTime;
                PickTetromino();
            }

            if (State == GameState.Locking && (gameTime - lockTime >= LockDelay || cancelLockDelay))
            {
                canHold         = true;
                cancelLockDelay = false;
                HardDrop();

                Board.Add(CurrentTetromino);
                if (Board.CanClearLines())
                {
                    CurrentTetromino = null;
                    State            = GameState.Clearing;
                    clearTime        = gameTime;
                }
                else
                {
                    State = GameState.Running;
                    PickTetromino();
                }
            }


            if (State == GameState.Running && ShouldLock())
            {
                State    = GameState.Locking;
                lockTime = gameTime;
                canHold  = false;
            }
        }