Ejemplo n.º 1
0
        private static void Draw(IConsoleBuffer border, IConsoleBuffer board, IConsoleBuffer nextPiecePanel, IConsoleBuffer scorePanel, string lastCommand)
        {
            frame.Fill(ConsoleColor.DarkGray);

            for (var i = 0; i < PADDING; ++i)
            {
                var j = 2 * i;
                border.Stroke(
                    i, i,
                    border.Width - j, border.Height - j,
                    DoubleLight,
                    ConsoleColor.Gray);
            }

            board.Fill(ConsoleColor.Black);
            board.DrawPuzzle(0, 0, game);
            board.DrawPuzzle(game.CursorX, game.CursorY, game.Current);

            nextPiecePanel.Draw(0, 0, "Next", ConsoleColor.Black);
            nextPiecePanel.DrawPuzzle(2, 1, game.Next);

            var score = game.Score.ToString(CultureInfo.CurrentCulture);

            scorePanel.Draw(0, 0, $"Score", ConsoleColor.Black);
            scorePanel.Draw(2, 1, score, ConsoleColor.White);
            scorePanel.Draw(0, 2, lastCommand, ConsoleColor.Black);

            frame.Flush();
        }
Ejemplo n.º 2
0
        public static void Stroke(this IConsoleBuffer buffer, int x, int y, int width, int height, char vertSideToken, char horizSideToken, char ulToken, char urToken, char llToken, char lrToken, ConsoleColor f, ConsoleColor b)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            var right  = x + width - 1;
            var bottom = y + height - 1;

            buffer.Draw(x, y, ulToken, f, b);
            buffer.Draw(right, y, urToken, f, b);
            buffer.Draw(x, bottom, llToken, f, b);
            buffer.Draw(right, bottom, lrToken, f, b);

            for (var dx = x + 1; dx < right; ++dx)
            {
                buffer.Draw(dx, y, horizSideToken, f, b);
                buffer.Draw(dx, bottom, horizSideToken, f, b);
            }

            for (var dy = y + 1; dy < bottom; ++dy)
            {
                buffer.Draw(x, dy, vertSideToken, f, b);
                buffer.Draw(right, dy, vertSideToken, f, b);
            }
        }
Ejemplo n.º 3
0
        public static void Draw(this IConsoleBuffer buffer, int x, int y, char c, ConsoleColor f)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            buffer.Draw(x, y, c, f, buffer.GetBackgroundColor(x, y));
        }
Ejemplo n.º 4
0
        public static void Fill(this IConsoleBuffer buffer, int x, int y, int width, int height, ConsoleColor b)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            for (var dx = 0; dx < width; ++dx)
            {
                for (var dy = 0; dy < height; ++dy)
                {
                    buffer.Draw(x + dx, y + dy, ' ', ConsoleColor.Gray, b);
                }
            }
        }
Ejemplo n.º 5
0
        public static void Draw(this IConsoleBuffer buffer, int x, int y, string s, ConsoleColor f)
        {
            if (buffer is null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (s is null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            for (var dx = 0; dx < s.Length; ++dx)
            {
                buffer.Draw(x + dx, y, s[dx], f);
            }
        }
Ejemplo n.º 6
0
        public static void DrawPuzzle(this IConsoleBuffer buf, int x, int y, Puzzle p)
        {
            if (buf is null)
            {
                throw new ArgumentNullException(nameof(buf));
            }

            if (p is null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            for (var dx = 0; dx < p.Width; ++dx)
            {
                for (var dy = 0; dy < p.Height; ++dy)
                {
                    if (p[dx, dy] != Puzzle.EmptyTile)
                    {
                        buf.Draw(x + dx, y + dy, '#', (ConsoleColor)(p[dx, dy] + 8), (ConsoleColor)p[dx, dy]);
                    }
                }
            }
        }
 public void Draw(int x, int y, char c, ConsoleColor f, ConsoleColor b)
 {
     parent.Draw(this.x + x, this.y + y, c, f, b);
 }