// Registers the current location of the tetro blocks and returns // Tetro mutation with the old block locations and the new block locations public GridMutation EndMupation() { foreach (Block b in Blocks) { _mutationState.AddTarget(b); } return(_mutationState); }
public GridMutation WriteText(int x, int y, string text) { var m = new GridMutation(); for (int i = 0; i < text.Length; i++) { m.AddTarget(new DrawablePoint(x + i, y, text[i])); } return(m); }
public GridMutation WriteText(int x, int y, string text) { Figlet figlet = new Figlet(); StyledString f = figlet.ToAscii(text); var mutation = new GridMutation(); for (int _y = 0; _y < f.CharacterGeometry.GetLength(0); _y++) { for (int _x = 0; _x < f.CharacterGeometry.GetLength(1); _x++) { mutation.AddTarget(new DrawablePoint(_x + x, _y + y, f.CharacterGeometry[_y, _x])); } } return(mutation); }
public void RemoveFullRowsIfAny() { // Check for full rows var rowsToRemove = new List <int>(); for (int y = Y; y <= H + Y; y++) { var row = _blocks.Where(b => b.Y == y); int count = row.Count(); if (count == W) { rowsToRemove.Add(y); } } var mutation = new GridMutation(); // If full rows remove the blocks foreach (int row in rowsToRemove) { // Select blocks to remove var blocksToRemove = new List <Block>(); foreach (Block b in _blocks.Where(b => b.Y == row)) { blocksToRemove.Add(b); } // Remove blocks foreach (Block b in blocksToRemove) { _blocks.Remove(b); mutation.AddSource(b); } // Shift upper blocks down foreach (Block b in _blocks.Where(_b => _b.Y < row)) { mutation.AddSource(new Point(b.X, b.Y)); ++b.Y; mutation.AddTarget(b); } } _renderer.Render(mutation); OnRowRemoved(RowRemovedEventArgs.Create(rowsToRemove.Count)); }