Exemple #1
0
        public InvalidState(ArchiTetris e)
        {
            if (e.lastMove == "left")
            {
                e.currentBlock.setBlocksPos(e.currentBlock.getX() + 1, e.currentBlock.getY());
            }
            else if (e.lastMove == "right")
            {
                e.currentBlock.setBlocksPos(e.currentBlock.getX() - 1, e.currentBlock.getY());
            }
            else if (e.lastMove == "rotate")
            {
                e.currentBlock.rotate(false);
            }
            else if (e.lastMove == "down")
            {
                e.currentBlock.setBlocksPos(e.currentBlock.getX(), e.currentBlock.getY() - 1);
                doneFalling = true;
                if (e.currentBlock.getY() <= 1)
                {
                    e.gameOver = true;
                    e.pause();
                }
            }

            nextState(e);
        }
Exemple #2
0
        public override void nextState(ArchiTetris e)
        {
            e.currentBlock = e.rwl.getBlock();
            e.currentBlock.setBlocksPos(4, 1);
            FallingState newState = new FallingState(e);

            e.bState = newState;
        }
Exemple #3
0
        public override void nextState(ArchiTetris e)
        {
            BoardState   newState;
            FallingState fState = new FallingState(e);

            newState   = (BoardState)fState;
            e.bState   = newState;
            e.lastMove = "";
        }
        public FallingState(ArchiTetris e)
        {
            e.movingFromWait = false;
            e.resetBoard();
            List <KeyValuePair <int, int> > poses = e.currentBlock.getPos();
            WrapperBlock wBlock = (WrapperBlock)e.currentBlock;

            foreach (KeyValuePair <int, int> p in poses)
            {
                e.boardTiles[p.Key, p.Value].BackColor = wBlock.c;
            }
        }
Exemple #5
0
        public override void nextState(ArchiTetris e)
        {
            BoardState   newState;
            FallingState fState = new FallingState(e);

            newState = (BoardState)fState;
            if (doneFalling)
            {
                DoneState dState = new DoneState(e);
                newState = (BoardState)dState;
            }
            e.lastMove = "";
        }
Exemple #6
0
        public override void nextState(ArchiTetris e)
        {
            BoardState newState;

            if (collision)
            {
                InvalidState iState = new InvalidState(e);
                newState = (BoardState)iState;
            }
            else
            {
                ValidState vState = new ValidState(e);
                newState = (BoardState)vState;
            }
        }
Exemple #7
0
        public CheckState(ArchiTetris e)
        {
            List <KeyValuePair <int, int> > poses = e.currentBlock.getPos();

            foreach (KeyValuePair <int, int> pos in poses)
            {
                if (pos.Key < 0 || pos.Key >= 10 || pos.Value < 0 || pos.Value >= 20)
                {
                    collision = true; // sort of a collision, but actually out of bounds
                }
                else if (e.boardArray[pos.Key, pos.Value] != 0)
                {
                    // collision
                    collision = true;
                }
            }
            nextState(e);
        }
Exemple #8
0
        public DoneState(ArchiTetris e)
        {
            // place current block on numArray
            List <KeyValuePair <int, int> > poses = e.currentBlock.getPos();
            WrapperBlock wBlock = (WrapperBlock)e.currentBlock;

            foreach (KeyValuePair <int, int> p in poses)
            {
                e.boardArray[p.Key, p.Value] = e.getColorNum(wBlock.c);
            }

            // check for clearing lines
            for (int j = 19; j > 0; j--)
            {
                bool wholeRow = true;
                for (int i = 0; i < 10; i++)
                {
                    if (e.boardArray[i, j] == 0)
                    {
                        wholeRow = false;
                    }
                }
                if (wholeRow)
                {
                    for (int k = j; k > 1; k--)
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            e.boardArray[i, k] = e.boardArray[i, k - 1];
                        }
                    }
                    for (int i = 0; i < 10; i++)
                    {
                        e.boardArray[i, 0] = 0;
                    }
                }
            }
            e.resetBoard();
            nextState(e);
        }
Exemple #9
0
 public abstract void nextState(ArchiTetris e);
Exemple #10
0
 public WaitingState(ArchiTetris e)
 {
 }
Exemple #11
0
        public override void nextState(ArchiTetris e)
        {
            WaitingState newState = new WaitingState(e);

            e.bState = newState;
        }
Exemple #12
0
 public ReadWriteLock(ArchiTetris e)
 {
     env = e;
 }
Exemple #13
0
 public ValidState(ArchiTetris e)
 {
     nextState(e);
 }
Exemple #14
0
        public override void nextState(ArchiTetris e)
        {
            CheckState newState = new CheckState(e);

            e.bState = newState;
        }