public void Start() { Clear(); NextPolyomino = new Tetromono(); Place(currentPolyomino); scoreBoard.Reset(); IsStarted = true; GameStarted?.Invoke(); }
bool PlaceNextPolyomino() { currentPolyomino = NextPolyomino; if (Place(currentPolyomino)) { NextPolyomino = new Tetromono(); return(true); } return(false); }
bool Turn(Tetromono currentPolyomino, bool clockwise = true) { var cellsClone = CellsClone; if (currentPolyomino.Turn(cellsClone, clockwise)) { CellsClone = cellsClone; return(true); } return(false); }
bool Move(Point <int> position, Tetromono polyomino) { var cellsClone = CellsClone; if (polyomino.Move(cellsClone, position)) { CellsClone = cellsClone; return(true); } return(false); }
public bool Place(PolyominoIndex[,] cellsClone, Point <int> position) { var placeablePoints = PlaceablePoints(shape, cellsClone, position); if (placeablePoints == null) { return(false); } placeablePoints.ForEach(point => cellsClone.Set(Tetromono.GetPosition(position, point), Index)); Position = position; return(true); }
bool Place(Tetromono polyomino) { var position = new Point <int> { X = (Size.Width - polyomino.Size.Width) / 2, Y = 0 }; var cellsClone = CellsClone; if (polyomino.Place(cellsClone, position)) { CellsClone = cellsClone; return(true); } return(false); }
public bool Place(Tetromono polyomino) { Contract.Assert(polyomino.Size.Width <= Size.Width && polyomino.Size.Height <= Size.Height); Clear(); var position = new Point<int>().Add(Size.Subtract(polyomino.Size).Divide(2)); var cellsClone = CellsClone; if (polyomino.Place(cellsClone, position)) { CellsClone = cellsClone; return true; } return false; }
public bool Turn(PolyominoIndex[,] cellsClone, bool clockwise = true) { Erase(cellsClone); var newShape = Turn(clockwise); var placeablePoints = PlaceablePoints(newShape, cellsClone, Position); if (placeablePoints == null) { return(false); } placeablePoints.ForEach(point => cellsClone.Set(Tetromono.GetPosition(Position, point), Index)); shape = newShape; return(true); }
public bool Place(Tetromono polyomino) { Contract.Assert(polyomino.Size.Width <= Size.Width && polyomino.Size.Height <= Size.Height); Clear(); var position = new Point <int>().Add(Size.Subtract(polyomino.Size).Divide(2)); var cellsClone = CellsClone; if (polyomino.Place(cellsClone, position)) { CellsClone = cellsClone; return(true); } return(false); }
bool Place(Tetromono polyomino) { var position = new Point<int> { X = (Size.Width - polyomino.Size.Width) / 2, Y = 0 }; var cellsClone = CellsClone; if (polyomino.Place(cellsClone, position)) { CellsClone = cellsClone; return true; } return false; }
bool Turn(Tetromono currentPolyomino, bool clockwise = true) { var cellsClone = CellsClone; if (currentPolyomino.Turn(cellsClone, clockwise)) { CellsClone = cellsClone; return true; } return false; }
bool MoveRight(Tetromono polyomino) { return Move(new Point<int> { X = polyomino.Position.X + 1, Y = polyomino.Position.Y }, polyomino); }
bool Move(Point<int> position, Tetromono polyomino) { var cellsClone = CellsClone; if (polyomino.Move(cellsClone, position)) { CellsClone = cellsClone; return true; } return false; }
bool PlaceNextPolyomino() { currentPolyomino = NextPolyomino; if (Place(currentPolyomino)) { NextPolyomino = new Tetromono(); return true; } return false; }
bool MoveRight(Tetromono polyomino) { return(Move(new Point <int> { X = polyomino.Position.X + 1, Y = polyomino.Position.Y }, polyomino)); }
bool Down(Tetromono polyomino) { return(Move(new Point <int> { X = polyomino.Position.X, Y = polyomino.Position.Y + 1 }, polyomino)); }
bool Down(Tetromono polyomino) { return Move(new Point<int> { X = polyomino.Position.X, Y = polyomino.Position.Y + 1 }, polyomino); }