示例#1
0
        public void HandleCommand(Command command)
        {
            if (!isRunning)
            {
                return;
            }
            bool stateChanged = false;

            switch (command)
            {
            case Command.ROTATE:
                stateChanged = RotatetTetromino();
                break;

            case Command.MOVE_LEFT:
                stateChanged = MoveTetrominoLeft();
                break;

            case Command.MOVE_RIGHT:
                stateChanged = MoveTetrominoRight();
                break;

            case Command.MOVE_DOWN:
                gravity.Reset();
                stateChanged = MoveTetrominoDown();
                break;

            case Command.FALL:
                stateChanged = MoveTetrominoDown();
                break;

            case Command.DROP:
                bool lastMovedDown;
                do
                {
                    lastMovedDown = MoveTetrominoDown();
                    stateChanged |= lastMovedDown;
                } while (lastMovedDown);
                break;
            }
            if (stateChanged && isRunning)
            {
                OnTetrominoStateChanged?.Invoke(fallingTetromino);
            }
        }
示例#2
0
 [TestMethod] public void ResetPeriodTime()
 {
     clock.Start();
     TestUtil.RunLater(OFFSET, () => {
         Assert.AreEqual(foo, 1);
         clock.Reset();
     });
     TestUtil.RunLater(OFFSET, () => Assert.AreEqual(foo, 1));
     TestUtil.RunLater(PERIOD, () => Assert.AreEqual(foo, 2));
 }