Example #1
0
        protected void RowRemovedHandler(object sender, RowRemovedEventArgs e)
        {
            var score = e.RowCount;

            if (score == 4)
            {
                score = 8;
            }
            Scoreboard.IncrementScore(score);
        }
Example #2
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));
        }
Example #3
0
 protected void OnRowRemoved(RowRemovedEventArgs e)
 => RowRemoved?.Invoke(this, e);