Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 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);
        }