Beispiel #1
0
        public void ProcessInput(UserInput input)
        {
            switch (input)
            {
            case UserInput.Down:
                if (tryMove(1, 0, active))
                {
                    active.X++;
                }
                break;

            case UserInput.Left:
                if (tryMove(0, -1, active))
                {
                    active.Y--;
                }
                break;

            case UserInput.Right:
                if (tryMove(0, 1, active))
                {
                    active.Y++;
                }
                break;

            case UserInput.Lock:
                while (tryMove(1, 0, active))
                {
                    active.X++;
                }
                lockActive();
                break;

            case UserInput.RotateClockwise:
                doRotate(false);
                break;

            case UserInput.RotateCClockwise:
                doRotate(true);
                break;

            case UserInput.Hold:
                if (hold == null)
                {
                    hold   = active;
                    active = next;
                    next   = Tetromino.getRandom();
                    TetrominoLockedEventArgs largs = new TetrominoLockedEventArgs();
                    largs.Next = next;
                    TetrominoLocked(this, largs);
                }
                else
                {
                    Tetromino temp = hold;
                    hold   = active;
                    active = temp;
                }
                ghost    = new Tetromino(active);
                active.X = 0;
                active.Y = 3;
                TetrominoHeldEventArgs args = new TetrominoHeldEventArgs();
                args.Hold = hold;
                TetrominoHeld(this, args);
                break;
            }
            dueLock = false;
            evaluateLock();
            HasChanged = true;
        }
Beispiel #2
0
        public void ProcessInput(UserInput input)
        {
            switch (input)
            {
                case UserInput.Down:
                    if (tryMove(1, 0, active))
                    {
                        active.X++;
                    }
                    break;

                case UserInput.Left:
                    if (tryMove(0, -1, active))
                    {
                        active.Y--;
                    }
                    break;

                case UserInput.Right:
                    if (tryMove(0, 1, active))
                    {
                        active.Y++;
                    }
                    break;

                case UserInput.Lock:
                    while (tryMove(1, 0, active))
                    {
                        active.X++;
                    }
                    lockActive();
                    break;

                case UserInput.RotateClockwise:
                    doRotate(false);
                    break;

                case UserInput.RotateCClockwise:
                    doRotate(true);
                    break;

                case UserInput.Hold:
                    if (hold == null)
                    {
                        hold = active;
                        active = next;
                        next = Tetromino.getRandom();
                        TetrominoLockedEventArgs largs = new TetrominoLockedEventArgs();
                        largs.Next = next;
                        TetrominoLocked(this, largs);
                    }
                    else
                    {
                        Tetromino temp = hold;
                        hold = active;
                        active = temp;
                    }
                    ghost = new Tetromino(active);
                    active.X = 0;
                    active.Y = 3;
                    TetrominoHeldEventArgs args = new TetrominoHeldEventArgs();
                    args.Hold = hold;
                    TetrominoHeld(this, args);
                    break;
            }
            dueLock = false;
            evaluateLock();
            HasChanged = true;
        }