Exemplo n.º 1
0
        private int ComputeShadowDistance()
        {
            var min = Playfield.Height;

            // For each row within the piece
            foreach (var(x, y) in GetPieceFieldCoordinates())
            {
                // If a shadow block
                if (UserPiece.IsShadowBlock(x - X, y - Y, Rotation))
                {
                    // Cast down to find nearest intercepting solid row
                    var row = Playfield.CastDown(x, y, true) - 1;

                    //
                    var dist = row - y;

                    // Was underground
                    if (dist < 0)
                    {
                        // How much of a vertical is needed to push up?
                        dist = Playfield.CastUp(x, y, false) - y;
                    }

                    // Store minimum distance found
                    min = Math.Min(min, dist);
                }
            }

            return(min);
        }