public bool IsValidMove(Move move) { var tempMove = ActiveBlock.Clone(); tempMove.Move(move); return(!CheckBlock(tempMove)); }
private void CreateNewBlock() { activeBlock = new ActiveBlock(board); if (activeBlock.cannotBeSpawned) { board.SetAllBlocksColor(Square.deadColor); activeBlock.ForcePlace(); SoundManager.PlayBoofSound(); board.Reset(); activeBlock = null; } }
void setBounds(int x, int z, ActiveBlock b) { bool up, down, left, right; up = (z == 0) ? true : (path[x, (z - 1)]); down = (z == 1) ? true : (path[x, (z + 1)]); left = (x == 0) ? true : (path[(x - 1), z]); right = (x == 1) ? true : (path[(x + 1), z]); b.putBounds(up, down, left, right); }
private void MoveActiveBlockDown() { bool hasMovedDown = activeBlock.Move(0, 1); if (hasMovedDown) { blockFreezeMovesCtr = 0; } else { blockFreezeMovesCtr++; if (blockFreezeMovesCtr >= numMovesBeforeBlockFreeze) { activeBlock.Freeze(); board.ClearFilledRows(); KeyListener.keyQueue.Clear(); blockFreezeMovesCtr = 0; activeBlock = null; SoundManager.PlayBoofSound(); } } }
public void PopIndent() { ActiveBlock.PopIndent(); }
public void PushIndent(uint indent = 4u) { ActiveBlock.PushIndent(indent); }
public void ResetNewLine() { ActiveBlock.ResetNewLine(); }
public void NeedNewLine() { ActiveBlock.NeedNewLine(); }
public void NewLineIfNeeded() { ActiveBlock.NewLineIfNeeded(); }
public void WriteLineIndent(string msg, params object[] args) { ActiveBlock.WriteLineIndent(msg, args); }
public void PushBlock(Block block) { block.Parent = ActiveBlock; ActiveBlock.AddBlock(block); ActiveBlock = block; }
public void AddBlock(Block block) { ActiveBlock.AddBlock(block); }
public override void checkPath() { int count = 0; bool playerFound = false; int boundX = -1; int boundZ = -1; ActiveBlock current = null; for (int i = 0; i < blocks.Length; i++) { int x = -1; int z = -1; if (blocks[i].isOnTop()) { count++; float posX = blocks[i].getPos().x; if (posX < 0) { x = 0; } else { x = 1; } float posZ = blocks[i].getPos().z; if (posZ < 0) { z = 1; } else { z = 0; } if (x >= 0 && z >= 0) { path[x, z] = blocks[i].active; } if (blocks[i].isPlayer()) { playerFound = true; playerPos.x = x; playerPos.y = z; char f = '0'; char s = '0'; switch (x) { case 0: f = 'L'; break; case 1: f = 'R'; break; } switch (z) { case 0: s = 'B'; break; case 1: s = 'F'; break; } playerLayers = "" + f + ":" + s; boundX = x; boundZ = z; current = blocks[i]; } } } if (!playerFound) { playerLayers = "0:0"; playerPos.x = -1; playerPos.y = -1; } else { setBounds(boundX, boundZ, current); } }
public void WriteStartBraceIndent() { ActiveBlock.WriteStartBraceIndent(); }
public void Write(string msg, params object[] args) { ActiveBlock.Write(msg, args); }
public void WriteCloseBraceIndent() { ActiveBlock.WriteCloseBraceIndent(); }
public bool Move(Move move) { // move must be set if (move == Engine.Move.None) { return(true); } // must have active block if (ActiveBlock == null) { return(false); } // implement fall if (move == Engine.Move.Fall) { var collisionHeight = int.MaxValue; foreach (var coord in ActiveBlock.GetCoords()) { var steps = 0; for (var y = coord.Row - 1; y >= 0; y--) { if (GameBoard[y][coord.Column] == false) { steps++; } else { break; } } collisionHeight = Math.Min(steps, collisionHeight); } ActiveBlock.Position.Row -= collisionHeight; EventHandler?.OnMove(ActiveBlock, move); LockBlock(); CheckBoard(); IsSoftDrop = false; return(true); } var tempMove = ActiveBlock.Clone().Move(move); var validMove = CheckBlock(tempMove); // try to solve rotation offset if (validMove == false && (move == Engine.Move.RotateLeft || move == Engine.Move.RotateRight)) { var solved = _TrySolveRotation(ref tempMove); if (solved != null) { tempMove = solved; validMove = true; } } // if un valid move down lock block if (validMove == false && move == Engine.Move.Down) { LockBlock(); CheckBoard(); IsSoftDrop = false; return(true); } // move is un valid if (validMove == false) { EventHandler?.OnUnvalidMove(move); return(false); } // apply move ActiveBlock = tempMove; IsSoftDrop = _IsSoftDrop(ActiveBlock); EventHandler?.OnMove(ActiveBlock, move); return(true); }