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); }
public override void nextState(ArchiTetris e) { e.currentBlock = e.rwl.getBlock(); e.currentBlock.setBlocksPos(4, 1); FallingState newState = new FallingState(e); e.bState = newState; }
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; } }
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 = ""; }
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; } }
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); }
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); }
public abstract void nextState(ArchiTetris e);
public WaitingState(ArchiTetris e) { }
public override void nextState(ArchiTetris e) { WaitingState newState = new WaitingState(e); e.bState = newState; }
public ReadWriteLock(ArchiTetris e) { env = e; }
public ValidState(ArchiTetris e) { nextState(e); }
public override void nextState(ArchiTetris e) { CheckState newState = new CheckState(e); e.bState = newState; }