Ejemplo n.º 1
0
        public static void DrawBorders(this SadConsole.Console currentWindow, int width, int height, string cornerGlyph, string horizontalBorderGlyph, string verticalBorderGlyph, Color borderColor)
        {
            for (int rowIndex = 0; rowIndex < height; rowIndex++)
            {
                for (int colIndex = 0; colIndex < width; colIndex++)
                {
                    // Drawing Corners
                    if ((rowIndex == 0 && colIndex == 0) ||
                        (rowIndex == height - 1 && colIndex == 0) ||
                        (rowIndex == height - 1 && colIndex == width - 1) ||
                        (rowIndex == 0 && colIndex == width - 1))
                    {
                        currentWindow.Print(colIndex, rowIndex, cornerGlyph, borderColor);
                    }

                    if (rowIndex > 0 && rowIndex < height - 1 && (colIndex == 0 || colIndex == width - 1))
                    {
                        currentWindow.Print(colIndex, rowIndex, horizontalBorderGlyph, borderColor);
                    }

                    if (colIndex > 0 && colIndex < width - 1 && (rowIndex == 0 || rowIndex == height - 1))
                    {
                        currentWindow.Print(colIndex, rowIndex, verticalBorderGlyph, borderColor);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void Update(GameTime gameTime)
        {
            if (!_lfsr.Finished)
            {
                Coords coordinate = _lfsr.Coordinate;

                int x = (int)coordinate.X;
                int y = (int)coordinate.Y;

                byte r = (byte)_random.Next(25, 256);
                byte g = (byte)_random.Next(25, 256);
                byte b = (byte)_random.Next(25, 256);

                if (x >= 0 && x < Width)
                {
                    if (y >= 0 && y < Height)
                    {
                        _gameConsole.Print(x, y, "X", new Color(r, g, b), Color.Black);
                    }
                }

                _lfsr.Next();
            }
            else
            {
                _gameConsole.Print(0, 0, "Finished!", Color.White, Color.Blue);
            }
        }
Ejemplo n.º 3
0
        public void Draw(SadConsole.Console console)
        {
            var nextY = 4;

            foreach (var value in Enum.GetValues(typeof(GameAction)))
            {
                var control = (GameAction)value;
                this.PrintBinding(console, control, Options.KeyBindings[control], nextY);
                nextY++;
            }

            if (IsBindingKey)
            {
                this.DrawBox(new Rectangle(1, 1, this.Width - 2, 3), BackgroundCell, BackgroundCell);
                var currentKey = this.controls[this.selectedIndex];
                console.Print(2, 2, $"Rebinding ", SelectedColour);
                console.Print(2 + "Rebinding".Length + 1, 2, currentKey.ToString(), SelectedValueColour);
                console.Print(2 + "Rebinding".Length + currentKey.ToString().Length + 1, 2, $" => {Options.KeyBindings[currentKey]}", SelectedColour);
                console.Print(2, 3, $"Press key or {Options.KeyBindings[GameAction.OpenMenu]} to cancel", SelectedColour);
            }
            else
            {
                console.Print(2, 2, $"{Options.KeyBindings[GameAction.MoveUp]}/{Options.KeyBindings[GameAction.MoveDown]} to move, {Options.KeyBindings[GameAction.SkipTurn]} to rebind, {Options.KeyBindings[GameAction.OpenMenu]} to go back", Palette.OffWhite);
            }
        }
Ejemplo n.º 4
0
        private void PrintBinding(SadConsole.Console console, GameAction control, Key boundKey, int y)
        {
            var selectedItem = this.controls[this.selectedIndex];
            var nameColour   = control == selectedItem ? SelectedColour : UnselectedColour;
            var keyColour    = control == selectedItem ? SelectedValueColour : UnselectedValueColour;

            console.Print(2, y, $"{control.ToString()}: ", nameColour);
            console.Print(2 + control.ToString().Length + 2, y, boundKey.ToString(), keyColour);
        }
Ejemplo n.º 5
0
        public override void Draw(Console console, TimeSpan delta)
        {
            for (int y = 0; y < game.Map.Length; y++)
            {
                for (int x = 0; x < game.Map[y].Length; x++)
                {
                    {
                        console.Print(x + 1, y + 1, game.Map[y][x].ToString());
                    }
                }
            }

            console.Print((int)game.Player.Position.Y + 1, (int)game.Player.Position.X + 1, "P");
        }
Ejemplo n.º 6
0
        public static void DrawRectangle(this SadConsole.Console console, int x, int y, int width, int height, string cornerGlyph, string horizontalGlyph, string verticalGlyph)
        {
            int _x;
            int _y;

            // top
            for (_x = x + 1; _x < (x + width) - 1; _x++)
            {
                console.Print(_x, y, horizontalGlyph);
            }
            // draw top corners
            console.Print(x, y, cornerGlyph);
            console.Print(x + width - 1, y, cornerGlyph);

            // bottom
            for (_x = x + 1; _x < (x + width) - 1; _x++)
            {
                console.Print(_x, height + y, horizontalGlyph);
            }
            // draw bottom corners
            console.Print(x, height + y, cornerGlyph);
            console.Print(x + width - 1, height + y, cornerGlyph);

            // left
            for (_y = y + 1; _y < (y + height); _y++)
            {
                console.Print(x, _y, verticalGlyph);
            }

            // right
            for (_y = y + 1; _y < (y + height); _y++)
            {
                console.Print(x + width - 1, _y, verticalGlyph);
            }
        }
Ejemplo n.º 7
0
        private void PrintOption(SadConsole.Console target, int x, int y, string caption, bool isEnabled, string onLabel, string offLabel)
        {
            target.Print(x, y, caption, Palette.Blue);

            if (isEnabled)
            {
                target.Print(x + caption.Length + 1, y, $"[{onLabel}]", EnabledColour);
                target.Print(x + caption.Length + onLabel.Length + 4, y, offLabel, DisabledColour);
            }
            else
            {
                target.Print(x + caption.Length + 1, y, onLabel, DisabledColour);
                target.Print(x + caption.Length + onLabel.Length + 2, y, $"[{offLabel}]", EnabledColour);
            }
        }
Ejemplo n.º 8
0
        // Prints a continuous text, breaking at word-boundaries instead of mid-word,
        // and taking into account the border and padding around the edge of the window.
        private int PrettyPrint(SadConsole.Console console, int x, int y, string text, Color colour)
        {
            var       words  = text.Split(' ');
            const int StartX = 2;              // border + padding
            var       maxX   = this.Width - 2; // border + padding

            var currentX = x;
            var currentY = y;

            foreach (var word in words)
            {
                var stopX = currentX + 1 + word.Length;
                if (stopX > maxX)
                {
                    currentY += 1;
                    currentX  = StartX;
                }

                var toPrint = $"{word} ";
                console.Print(currentX, currentY, toPrint, colour);
                currentX += toPrint.Length;
            }

            return(currentY);
        }
Ejemplo n.º 9
0
        // Can be improved
        public static void DrawButton(this SadConsole.Console console, int x, int y, string text, string key, Color keyColor, bool windowCentered)
        {
            var bracketA = new SadConsole.ColoredString("[");

            bracketA.SetForeground(console.DefaultForeground);
            var bracketB = new SadConsole.ColoredString("] ");

            bracketB.SetForeground(console.DefaultForeground);

            var prefix = new SadConsole.ColoredString($"{key}");

            prefix.SetForeground(keyColor);

            var suffix = new SadConsole.ColoredString($"{text}");

            suffix.SetForeground(console.DefaultForeground);

            var button = new SadConsole.ColoredString("");

            button.SetForeground(console.DefaultForeground);
            button.SetBackground(console.DefaultBackground);

            button += bracketA + prefix + bracketB + suffix;

            int _x = windowCentered ? (console.Width / 2 - (button.Count / 2)) : x;

            console.Print(_x, y, button);
        }
        public override void Draw(Console console, TimeSpan delta)
        {
            var fElapsedTime = delta.TotalSeconds;

            var status = $"X={game.Player.Position.X:000.00}, Y={game.Player.Position.Y:000.00}, A={game.Player.Angle:000.00} FPS={1.0f / fElapsedTime:000.00} Frame={frame++}";

            console.Print(0, 0, status);
        }
Ejemplo n.º 11
0
        public static void DrawHeader(this SadConsole.Console console, int y, string title, Color foregroundColor, Color backgroundColor)
        {
            var str = new SadConsole.ColoredString();

            str.String = title;
            str.SetForeground(foregroundColor);
            str.SetBackground(backgroundColor);
            console.Print(console.Width / 2 - (str.Count / 2), y, str);
        }
Ejemplo n.º 12
0
        private void ShowSelectedCube(SadConsole.Console console)
        {
            console.Print(2, 2, cubeShown.Title, Palette.LightRed);
            var lastY = this.PrettyPrint(console, 2, 4, cubeShown.Text, Palette.OffWhite);

            if (cubeShown.FloorNumber == 1)
            {
                lastY = this.PrettyPrint(console, 2, lastY + 2, "Our engineers outfitted you with a prototype combat shield that recharges instantly, but it needs space to work - any nearby entities will prevent it from recharging.", Palette.OffWhite);

                var signature = "-The Khalifa";
                console.Print(console.Width - 2 - signature.Length, lastY + 2, signature, Palette.OffWhite);
            }
            else if (cubeShown == DataCube.EndGameCube)
            {
                console.Print(2, lastY + 2, "Congratulations on completing the game!", Palette.White);
                console.Print(2, lastY + 4, "Thanks for playing! If you have any feedback,", Palette.Blue);
                console.Print(2, lastY + 5, "please send it to @nightblade99 on Twitter!", Palette.Blue);
            }
        }
Ejemplo n.º 13
0
        static void Init()
        {
            var console = new Console(80, 25);

            console.FillWithRandomGarbage();
            console.Fill(new Rectangle(3, 3, 23, 3), Color.Violet, Color.Black, 0, 0);
            console.Print(4, 4, "Hello from SadConsole");

            SadConsole.Global.CurrentScreen = console;
        }
Ejemplo n.º 14
0
 public void LogMessage(string message)
 {
     messageConsole.ShiftUp();
     messageConsole.Fill(
         new Microsoft.Xna.Framework.Rectangle(0, 0, messageConsole.Width, 1),
         Microsoft.Xna.Framework.Color.DimGray,
         null,
         null);
     messageConsole.Print(0, 1, $"> {message}");
 }
Ejemplo n.º 15
0
        public void Draw(SadConsole.Console console)
        {
            if (this.cubeShown == null)
            {
                this.ShowCubesList(console);
            }
            else
            {
                this.ShowSelectedCube(console);
            }

            if (cubeShown != DataCube.EndGameCube)
            {
                console.Print(2, console.Height - 4, $"[{Options.KeyBindings[GameAction.OpenMenu]}] Go back", Palette.White);
            }
            else
            {
                console.Print(2, console.Height - 4, $"[{Options.KeyBindings[GameAction.OpenMenu]}] Quit to title", Palette.White);
            }
        }
Ejemplo n.º 16
0
        public virtual void Draw(int x, int y, SadConsole.Console console)
        {
            var lBracketGlyph = new SadConsole.ColoredString("[", NameColor, Constants.Theme.BackgroundColor);
            var rBracketGlyph = new SadConsole.ColoredString("]", NameColor, Constants.Theme.BackgroundColor);
            var keyString     = new SadConsole.ColoredString(KeyToString(), KeyColor, Constants.Theme.BackgroundColor);

            var key = new SadConsole.ColoredString("");

            key += lBracketGlyph + keyString + rBracketGlyph;

            console.Print(x, y, key);
        }
Ejemplo n.º 17
0
        public override void ProcessMouse(SadConsole.Console console, MouseConsoleState state, out bool handled)
        {
            if (state.Mouse.IsOnScreen)
            {
                console.Print(0, 0, "cellposition X : " + state.CellPosition.X + " ; Y : " + state.CellPosition.Y);
                //console.SetBackground(state.CellPosition.X, state.CellPosition.Y, Color.HotPink);
                var child = console.Children[0];
                child.Position = state.CellPosition;
                //console.Clear();
            }

            handled = false;
        }
Ejemplo n.º 18
0
        public static void DrawSeparator(this SadConsole.Console console, int y, string corner, Color c)
        {
            StringBuilder separator = new StringBuilder();

            separator.Append(corner);
            for (int i = 1; i < console.Width - 1; i++)
            {
                separator.Append("-");
            }
            separator.Append(corner);

            console.Print(0, y, separator.ToString(), c);
        }
Ejemplo n.º 19
0
        private static Console ShowMenu(Console console, string header, List <string> options, int width, int screenWidth, int screenHeight, Color backgroundColor)
        {
            if (options.Count > 26)
            {
                throw new ArgumentException("Cannot have a menu with more than 26 options");
            }

            var wrappedHeader = WrapText(header, width);
            var headerHeight  = (wrappedHeader.Length + 49) / 50;
            var height        = options.Count + headerHeight;

            var window = new Console(width, height);

            window.DefaultBackground = backgroundColor;
            window.DefaultForeground = Color.White;
            window.Print(0, 0, wrappedHeader, window.DefaultForeground);

            var y           = headerHeight;
            var letterIndex = (int)'a';

            foreach (var option in options)
            {
                var text = $"({(char)letterIndex}) {option}";
                window.Print(0, y, text, window.DefaultForeground);

                y++;
                letterIndex++;
            }

            var windowX = screenWidth / 2 - width / 2;
            var windowY = screenHeight / 2 - height / 2;

            window.Position = new Point(windowX, windowY);
            console.Children.Add(window);

            return(window);
        }
Ejemplo n.º 20
0
        private void ShowCubesList(SadConsole.Console console)
        {
            // Print data cubes in order of floor acquired, so the user sees any gaps.
            // Because of padding/border, print floor Bn on (x, y=n).
            var cubesByFloor = new Dictionary <int, DataCube>();

            for (var floor = DataCube.FirstDataCubeFloor; floor < DataCube.FirstDataCubeFloor + DataCube.NumCubes; floor++)
            {
                var cube = player.DataCubes.SingleOrDefault(d => d.FloorNumber == floor);
                if (cube != null)
                {
                    console.Print(2, floor + 1, $"[{cube.FloorNumber}] {cube.Title}", Palette.White);
                }
            }
        }
Ejemplo n.º 21
0
        private static void OnInitialize()
        {
            var console = new SadConsole.Console(80, 25);

            console.FillWithRandomGarbage();
            _ = console.Fill(new Rectangle(3, 3, 23, 3), Color.Violet, Color.Black, 0, 0);
            console.Print(4, 4, "Hello world!");
            console.IsFocused        = true;
            console.Cursor.IsVisible = true;

            // Add the custom keyboard handler.
            console.Components.Add(new MyKeyboardComponent());

            // Focus the screen to the default console.
            SadConsole.Global.CurrentScreen = console;
        }
        public override void ProcessKeyboard(Console console, Keyboard info, out bool handled)
        {
            game.Keys.ForwardPressed  = info.IsKeyDown(Keys.W);
            game.Keys.BackwardPressed = info.IsKeyDown(Keys.S);

            game.Keys.LeftPressed  = info.IsKeyDown(Keys.A);
            game.Keys.RightPressed = info.IsKeyDown(Keys.D);

            game.Keys.StrafeLeftPressed  = info.IsKeyDown(Keys.Q);
            game.Keys.StrafeRightPressed = info.IsKeyDown(Keys.E);

            if (info.IsKeyDown(Keys.Space))
            {
                console.Print(1, 1, "SPACE");
            }
            handled = true;
        }
        public void Draw(SadConsole.Console console)
        {
            console.Print(2, 2, "[D] Review data cubes", Palette.White);
            console.Print(2, 3, "[O] Options", Palette.White);
            console.Print(2, 4, "[S] Save game", Palette.White);

            if (this.justSaved)
            {
                console.Print(2, 6, "Game saved!", Palette.Blue);
            }

            console.Print(2, console.Height - 4, "[ESC] Back to game", Palette.White);
            console.Print(2, console.Height - 3, "[Q] Quit", Palette.White);
        }
Ejemplo n.º 24
0
        public void ShowCharacterScreen(Console console, Entity player, int characterScreenWidth, int characterScreenHeight, int screenWidth, int screenHeight)
        {
            if (_characterScreen == null)
            {
                _characterScreen = new Console(characterScreenWidth, characterScreenHeight);
                _characterScreen.DefaultBackground = Color.DarkGray;
                _characterScreen.DefaultForeground = Color.White;

                _characterScreen.Print(0, 1, "Character Information");
                _characterScreen.Print(0, 2, $"Level: {player.Get<LevelComponent>().CurrentLevel}");
                _characterScreen.Print(0, 3, $"Experience: {player.Get<LevelComponent>().CurrentXp}");
                _characterScreen.Print(0, 4, $"Experience to Level: {player.Get<LevelComponent>().ExperienceToNextLevel}");
                _characterScreen.Print(0, 6, $"Maximum HP: {player.Get<FighterComponent>().MaxHp}");
                _characterScreen.Print(0, 7, $"Attack: {player.Get<FighterComponent>().Power}");
                _characterScreen.Print(0, 8, $"Defense: {player.Get<FighterComponent>().Defense}");


                var windowX = screenWidth / 2 - characterScreenWidth / 2;
                var windowY = screenHeight / 2 - characterScreenHeight / 2;

                _characterScreen.Position = new Point(windowX, windowY);
                console.Children.Add(_characterScreen);
            }
        }
Ejemplo n.º 25
0
 public static void DrawHeaderInsideSeparators(this SadConsole.Console console, int y, string title, string corner, Color c)
 {
     DrawSeparator(console, y, corner, console.DefaultForeground);
     console.Print(console.GetWindowXCenter() - (title.Length / 2), y + 1, title, c);
     DrawSeparator(console, y + 2, corner, console.DefaultForeground);
 }
Ejemplo n.º 26
0
        public override void Draw(Console console, TimeSpan delta)
        {
            for (var x = 0; x < console.Width; x++)
            {
                // For each column, calculate the projected ray angle into world space
                var rayAngle = game.Player.Angle - game.Player.FOV / 2.0f + x / (float)console.Width * game.Player.FOV;

                // Find distance to wall
                var stepSize       = 0.1f;            // Increment size for ray casting, decrease to increase
                var distanceToWall = 0.0f;            //                                      resolution

                var wallHit  = false;                 // Set when ray hits wall block
                var boundary = false;                 // Set when ray hits boundary between two wall blocks

                var eyeX = (float)Math.Sin(rayAngle); // Unit vector for ray in player space
                var eyeY = (float)Math.Cos(rayAngle);

                // Incrementally cast ray from player, along ray angle, testing for
                // intersection with a block
                while (!wallHit && distanceToWall < game.RenderDepth)
                {
                    distanceToWall += stepSize;
                    var testX = (int)(game.Player.Position.X + eyeX * distanceToWall);
                    var testY = (int)(game.Player.Position.Y + eyeY * distanceToWall);

                    // Test if ray is out of bounds
                    if (testX < 0 || testX >= game.Map[0].Length || testY < 0 || testY >= game.Map[0].Length)
                    {
                        wallHit        = true; // Just set distance to maximum depth
                        distanceToWall = game.RenderDepth;
                    }
                    else
                    {
                        // Ray is inbounds so test to see if the ray cell is a wall block
                        if (game.Map[testX][testY] == '#')
                        {
                            // Ray has hit wall
                            wallHit = true;

                            // To highlight tile boundaries, cast a ray from each corner
                            // of the tile, to the player. The more coincident this ray
                            // is to the rendering ray, the closer we are to a tile
                            // boundary, which we'll shade to add detail to the walls
                            var p = new List <Vector2>();

                            // Test each corner of hit tile, storing the distance from
                            // the player, and the calculated dot product of the two rays
                            for (var tx = 0; tx < 2; tx++)
                            {
                                for (var ty = 0; ty < 2; ty++)
                                {
                                    // Angle of corner to eye
                                    var vx  = (float)testX + tx - game.Player.Position.X;
                                    var vy  = (float)testY + ty - game.Player.Position.Y;
                                    var d   = (float)Math.Sqrt(vx * vx + vy * vy);
                                    var dot = eyeX * vx / d + eyeY * vy / d;
                                    p.Add(new Vector2(d, dot));
                                }
                            }

                            // Sort Pairs from closest to farthest
                            p = p.OrderBy(tuple => tuple.X).ToList();

                            // First two/three are closest (we will never see all four)
                            var fBound = 0.01f;
                            if (Math.Acos(p[0].Y) < fBound)
                            {
                                boundary = true;
                            }
                            if (Math.Acos(p[1].Y) < fBound)
                            {
                                boundary = true;
                            }
                            if (Math.Acos(p[2].Y) < fBound)
                            {
                                boundary = true;
                            }
                        }
                    }
                }

                // Calculate distance to ceiling and floor
                var nCeiling = (int)((float)(console.Height / 2.0) - console.Height / distanceToWall);
                var nFloor   = console.Height - nCeiling;

                // Shader walls based on distance
                char nShade;
                if (distanceToWall <= game.RenderDepth / 4.0f)
                {
                    nShade = (char)219;                                             // '█'; // Very close
                }
                else if (distanceToWall < game.RenderDepth / 3.0f)
                {
                    nShade = (char)178;                                                 //'▓';
                }
                else if (distanceToWall < game.RenderDepth / 2.0f)
                {
                    nShade = (char)177;                                                 // '▒';
                }
                else if (distanceToWall < game.RenderDepth)
                {
                    nShade = (char)176;                                          // '░';
                }
                else
                {
                    nShade = ' ';  // Too far away
                }
                if (boundary)
                {
                    nShade = ' ';           // Black it out
                }
                for (var y = 0; y < console.Height; y++)
                {
                    // Each Row
                    if (y <= nCeiling)
                    {
                        console.Print(x, y, " ");
                    }
                    else if (y > nCeiling && y <= nFloor)
                    {
                        console.Print(x, y, nShade.ToString());
                    }
                    else // Floor
                    {
                        // Shade floor based on distance
                        var b = 1.0f - (y - console.Height / 2.0f) / (console.Height / 2.0f);
                        if (b < 0.25)
                        {
                            nShade = '#';
                        }
                        else if (b < 0.5)
                        {
                            nShade = 'x';
                        }
                        else if (b < 0.75)
                        {
                            nShade = '.';
                        }
                        else if (b < 0.9)
                        {
                            nShade = '-';
                        }
                        else
                        {
                            nShade = ' ';
                        }
                        console.Print(x, y, nShade.ToString());
                    }
                }
            }
        }
Ejemplo n.º 27
0
        public static void DrawRectangleTitled(this SadConsole.Console console, int x, int y, int width, int height, string cornerGlyph, string horizontalGlyph, string verticalGlyph, string separatorCornerGlyph, SadConsole.ColoredString title, bool centeredTitle)
        {
            int _x;
            int _y;

            // top
            for (_x = x + 1; _x < (x + width) - 1; _x++)
            {
                console.Print(_x, y, horizontalGlyph);
            }
            // draw top corners
            console.Print(x, y, cornerGlyph);
            console.Print(x + width - 1, y, cornerGlyph);

            // bottom
            for (_x = x + 1; _x < (x + width) - 1; _x++)
            {
                console.Print(_x, height + y, horizontalGlyph);
            }
            // draw bottom corners
            console.Print(x, height + y, cornerGlyph);
            console.Print(x + width - 1, height + y, cornerGlyph);

            // left
            for (_y = y + 1; _y < (y + height); _y++)
            {
                console.Print(x, _y, verticalGlyph);
            }

            // right
            for (_y = y + 1; _y < (y + height); _y++)
            {
                console.Print(x + width - 1, _y, verticalGlyph);
            }

            // draw title separator. simply draws on top of already drawn glyphs
            for (_x = x + 1; _x < (x + width) - 1; _x++)
            {
                console.Print(_x, y + 2, horizontalGlyph);
            }
            // draw separator corners
            console.Print(x, y + 2, separatorCornerGlyph);
            console.Print(x + width - 1, y + 2, separatorCornerGlyph);

            // draw the box title
            if (centeredTitle)
            {
                console.Print((width / 2) - (title.String.Length / 2), y + 1, title);
            }
            else
            {
                console.Print(2, y + 1, title);
            }
        }
Ejemplo n.º 28
0
        private Polynomino()
        {
            SadConsole.Game.Create(width, height);
            SadConsole.Game.OnInitialize = () => {
                PolynominoBuilder polyBuilder = new PolynominoBuilder();
                polynominoes = polyBuilder.Build(10);

                console                  = new Console(width, height);
                console.IsFocused        = true;
                console.Cursor.IsEnabled = false;

                SadConsole.Global.CurrentScreen = console;

                start = DateTime.UtcNow.Subtract(TimeSpan.FromMilliseconds(millisecondDelay));
            };

            SadConsole.Game.OnUpdate = (gameTime) => {
                if (start.AddMilliseconds(millisecondDelay) < DateTime.UtcNow)
                {
                    currentPolyIndex++;
                    if (currentPolyIndex >= polynominoes[currentRank].Count)
                    {
                        currentRank++;
                        if (currentRank > polynominoes.Count)
                        {
                            currentRank = 1;
                            console.Clear();
                            workingX = 1;
                            workingY = 1;
                        }
                        currentPolyIndex = 0;
                    }

                    foreground = Color.White.GetRandomColor(rng);

                    string   polyString = polynominoes[currentRank][currentPolyIndex];
                    string[] outputs    = polyString.Split('\n');

                    // figure out if new row start is needed
                    int spaceLeft     = width - 2 - workingX;
                    int outputsLength = outputs.Max(s => s.Length);
                    if (spaceLeft < outputsLength)
                    {
                        workingX = 1;
                        workingY = maxY + 1;
                    }

                    // See if a new wipe needs to happen
                    if (workingY + outputs.Length >= height - 1)
                    {
                        console.Clear();
                        workingX = 1;
                        workingY = 1;
                        maxY     = 1;
                    }

                    maxY = Math.Max(maxY, workingY + outputs.Length);

                    int y = workingY;
                    foreach (string line in outputs)
                    {
                        console.Print(workingX, y, line, foreground);
                        y++;
                    }
                    workingX += outputsLength + 1;

                    start = DateTime.UtcNow;
                }
            };

            SadConsole.Game.Instance.Run();
            SadConsole.Game.Instance.Dispose();
        }
Ejemplo n.º 29
0
 public virtual void Draw(SadConsole.Console console)
 {
     console.Print(X, Y, KeyString);
 }