Beispiel #1
0
 // Registers the current location of the tetro blocks
 public void BeginMutation()
 {
     _mutationState = new GridMutation();
     foreach (Block b in Blocks)
     {
         _mutationState.AddSource(b.X, b.Y);
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private GridMutation ClearTetro(Tetro tetro)
        {
            var m = new GridMutation();

            foreach (DrawablePoint b in tetro.Blocks)
            {
                m.AddSource(b.X + _x + 2, b.Y + 4);
            }

            return(m);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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));
        }