public void DrawExploMap()
        {
            GoRogue.MapViews.ArrayMap <int> wMap = Adventure.Map.ExplorationMap;
            for (var i = 0; i < wMap.Width; i++)
            {
                for (var j = 0; j < wMap.Height; j++)
                {
                    switch (wMap[i, j])
                    {
                    case 0:
                        Cell cell = UnknownAppearance;
                        _mapConsole[i, j].CopyAppearanceFrom(cell);
                        _mapConsole.SetGlyph(i, j, 176);
                        break;

                    case 1:
                    case 2:
                    case -1:
                        DrawMapPoint(i, j, false);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
        private void MakeBasicSurface()
        {
            basicSurface.Print(0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890".Repeat(9));
            basicSurface.SetGlyph(0, 0, 7);
            basicSurface.SetGlyph(1, 0, 8);
            basicSurface.SetGlyph(2, 0, 9);
            basicSurface.SetGlyph(3, 0, 10);
            ColorGradient gradient = new ColorGradient(SadConsole.UI.Themes.Library.Default.Colors.Blue, SadConsole.UI.Themes.Library.Default.Colors.Yellow);

            for (int i = 0; i < 510; i += 10)
            {
                Point point = Point.FromIndex(i, basicSurface.Width);
                basicSurface.Print(point.X, point.Y, gradient.ToColoredString(basicSurface.GetString(i, 10)));
            }

            // Mirror 1
            int startSet1 = new Point(0, 3).ToIndex(34);
            int startSet2 = new Point(0, 6).ToIndex(34);
            int startSet3 = new Point(0, 9).ToIndex(34);

            for (int i = 0; i < 34 * 3; i++)
            {
                basicSurface[startSet1 + i].Mirror     = Mirror.Vertical;
                basicSurface[startSet1 + i].Background = SadConsole.UI.Themes.Library.Default.Colors.PurpleDark;

                basicSurface[startSet2 + i].Mirror     = Mirror.Horizontal;
                basicSurface[startSet2 + i].Background = SadConsole.UI.Themes.Library.Default.Colors.OrangeDark;

                basicSurface[startSet3 + i].Mirror     = Mirror.Horizontal | Mirror.Vertical;
                basicSurface[startSet3 + i].Background = SadConsole.UI.Themes.Library.Default.Colors.GreenDark;
            }
        }
Exemple #3
0
        private static void Init()
        {
            // Any custom loading and prep. We will use a sample console for now
            Console    startingConsole = new Console(Width, Height);
            FontMaster fontMaster      = SadConsole.Global.LoadFont("cp437.font");

            startingConsole.TextSurface.Font = fontMaster.GetFont(SadConsole.Font.FontSizes.One);
            SadRex.Image tempImage = SadRex.Image.Load(TitleContainer.OpenStream("temp.xp"));
            //tempImage.Layers[0].Cells[0].Background and Character
            SadRex.Layer imageLayer = tempImage.Layers[0];
            for (int yPos = 0; yPos < tempImage.Height; yPos++)
            {
                for (int xPos = 0; xPos < tempImage.Width; xPos++)
                {
                    //2-D to 1-D coordinate: (yPos*Width) + xPos
                    SadRex.Cell currentCell = imageLayer.Cells[(yPos * Width) + xPos];
                    startingConsole.SetGlyph(xPos, yPos, currentCell.Character,
                                             new Color(
                                                 currentCell.Foreground.R,
                                                 currentCell.Foreground.G,
                                                 currentCell.Foreground.B),
                                             new Color(currentCell.Background.R,
                                                       currentCell.Background.G,
                                                       currentCell.Background.B));
                }
            }

            /*
             * startingConsole.FillWithRandomGarbage();
             * startingConsole.Fill(new Rectangle(3, 3, 27, 5), null, Color.Black, 0);
             * startingConsole.Print(6, 5, "Hello from SadConsole", ColorAnsi.CyanBright);//*/

            // Set our new console as the thing to render and process
            SadConsole.Global.CurrentScreen = startingConsole;
        }
Exemple #4
0
        private static void Init()
        {
            // Any setup
            if (Settings.UnlimitedFPS)
            {
                SadConsole.Game.Instance.Components.Add(new SadConsole.Game.FPSCounterComponent(SadConsole.Game.Instance));
            }

            // Setup our custom theme.
            Theme.SetupThemes();

            SadConsole.Game.Instance.Window.Title = "DemoProject Core";

            // By default SadConsole adds a blank ready-to-go console to the rendering system.
            // We don't want to use that for the sample project so we'll remove it.

            //Global.MouseState.ProcessMouseWhenOffScreen = true;

            MainConsole = new Container();

            // We'll instead use our demo consoles that show various features of SadConsole.
            Global.CurrentScreen = MainConsole;

            // Initialize the windows
            _characterWindow = new Windows.CharacterViewer();


            Console con = new Console(80, 25);

            con.Print(1, 1, "Hello, welcome to SadConsole", Color.Yellow);
            con.SetForeground(4, 1, Color.Brown);
            con.SetForeground(5, 1, Color.Brown);
            con.SetGlyph(6, 1, '!');
            con.Cursor.Move(1, 20).Print("Printing with cursor");
        }
Exemple #5
0
        private static void Program_WindowResized(object?sender, EventArgs e)
        {
            var windowWidth  = Global.WindowWidth > 0 ? Global.WindowWidth : 1;
            var windowHeight = Global.WindowHeight > 0 ? Global.WindowHeight : 1;

            Global.CurrentScreen.Resize(
                windowWidth / Global.CurrentScreen.Font.Size.X,
                windowHeight / Global.CurrentScreen.Font.Size.Y,
                true);
            _uiConsole.Resize(
                windowWidth / Global.CurrentScreen.Font.Size.X,
                windowHeight / Global.CurrentScreen.Font.Size.Y,
                true);

            for (int y = 0; y < Global.CurrentScreen.Height; y++)
            {
                for (int x = 0; x < Global.CurrentScreen.Width; x++)
                {
                    var index = x + y * Global.CurrentScreen.Width;
                    if (index < Global.CurrentScreen.Font.MaxGlyphIndex)
                    {
                        Global.CurrentScreen.SetGlyph(x, y, index, Color.White, Color.Black, SpriteEffects.None);
                    }
                    if (index >= Global.CurrentScreen.Font.MaxGlyphIndex && index < _cheepicusFont.GetFont(Font.FontSizes.One).MaxGlyphIndex + Global.CurrentScreen.Font.MaxGlyphIndex)
                    {
                        _uiConsole.SetGlyph(x, y, index - Global.CurrentScreen.Font.MaxGlyphIndex, Color.Red, Color.Transparent, SpriteEffects.None);
                    }
                }
            }
        }
Exemple #6
0
        public TextCursorConsole()
            : base(80, 23)
        {
            mouseCursor = new SadConsole.Console(1, 1);
            mouseCursor.SetGlyph(0, 0, 178);
            mouseCursor.UseMouse = false;

            Children.Add(mouseCursor);
        }
Exemple #7
0
        private void DrawCharacter(int x, int y, int character, Color?colour = null)
        {
            if (colour.HasValue)
            {
                mainConsole.SetForeground(x, y, colour.Value);
            }

            mainConsole.SetGlyph(x, y, character);
        }
Exemple #8
0
        void PrintPlayerTropies(Console console, IList <IFigure> trophies, Color fontColor, int row, bool displayTrophiesOnLeftSide)
        {
            int x = displayTrophiesOnLeftSide ? 1 : console.Width - 2;

            foreach (var figure in trophies)
            {
                console.SetGlyph(x, row++, figure.Letter, fontColor);
            }
        }
Exemple #9
0
        public TestPixelOffsetConsole(int width, int height) : base(width, height, Global.Fonts["InventorySprites"].GetFont(Font.FontSizes.One))
        {
            UsePixelPositioning = true;

            RealPositionConsole = new SadConsole.Console(Width, Height, Font);
            RealPositionConsole.SetGlyph(0, 0, 2, Color.OldLace);
            RealPositionConsole.SetGlyph(0, 1, 2, Color.OldLace);
            RealPositionConsole.SetGlyph(1, 0, 2, Color.OldLace);
            RealPositionConsole.SetGlyph(1, 1, 2, Color.OldLace);
            Children.Add(RealPositionConsole);

            ViewPositionConsole = new SadConsole.Console(Width, Height, Font)
            {
                UsePixelPositioning = true
            };
            ViewPositionConsole.SetGlyph(0, 0, 2, Color.Gray);
            ViewPositionConsole.SetGlyph(0, 1, 2, Color.White);
            ViewPositionConsole.SetGlyph(1, 0, 2, Color.Blue);
            ViewPositionConsole.SetGlyph(1, 1, 2, Color.Red);
            Children.Add(ViewPositionConsole);
        }
        void ShowIntro(Console console)
        {
            var y = 1;

            foreach (var line in intro)
            {
                var x = 1;
                foreach (var c in line)
                {
                    int output = 63;

                    Debug.Write($"{(int)c}- {c}");
                    switch ((int)c)
                    {
                    case 9556:
                        output = 201;
                        break;

                    case 9552:
                        output = 205;
                        break;

                    case 9559:
                        output = 187;
                        break;

                    case 9553:
                        output = 186;
                        break;

                    case 9562:
                        output = 200;
                        break;

                    case 9565:
                        output = 188;
                        break;

                    default:
                        output = Convert.ToInt32(Encoding.Convert(Encoding.UTF8, Encoding.ASCII, Encoding.UTF8.GetBytes(new char[] { c }))[0]);
                        break;
                    }

                    console.SetGlyph(x, y, output);
                    x++;
                }

                Debug.WriteLine(string.Empty);

                y++;
            }
        }
Exemple #11
0
        void PrintFigure(Console console, IFigure figure, Color backgroundColor, int currentX, int currentY)
        {
            if (figure is null)
            {
                PrintEmptySquare(backgroundColor, currentX, currentY);
                return;
            }

            for (int y = 0; y < figure.Pattern[piecePattern].GetLength(0); y++)
            {
                for (int x = 0; x < figure.Pattern[piecePattern].GetLength(1); x++)
                {
                    console.SetGlyph(currentX + x, currentY + y, figure.Pattern[piecePattern][y, x],
                                     figure.Color.ToConsoleColor(), backgroundColor);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// Este Método "imprime" para a consola de jogo as jogadas que temos no $GameBoard,
        /// e depois cria as bordas e o tabuleiro de jogo com caractéres ASCII
        /// </summary>
        static void PrintGameConsole()
        {
            // Mostrar os X e O que já tenham sido jogados
            gameConsole.Print(1, 1, $"{Glifo(board.Board[0])} {Glifo(board.Board[1])} {Glifo(board.Board[2])}");
            gameConsole.Print(1, 3, $"{Glifo(board.Board[3])} {Glifo(board.Board[4])} {Glifo(board.Board[5])}");
            gameConsole.Print(1, 5, $"{Glifo(board.Board[6])} {Glifo(board.Board[7])} {Glifo(board.Board[8])}");
            // Linha 1
            gameConsole.SetGlyph(1, 2, 196); // -
            gameConsole.SetGlyph(2, 2, 197); // +
            gameConsole.SetGlyph(3, 2, 196); // -
            gameConsole.SetGlyph(4, 2, 197); // +
            gameConsole.SetGlyph(5, 2, 196); // -
            // Linha 2
            gameConsole.SetGlyph(1, 4, 196); // -
            gameConsole.SetGlyph(2, 4, 197); // +
            gameConsole.SetGlyph(3, 4, 196); // -
            gameConsole.SetGlyph(4, 4, 197); // +
            gameConsole.SetGlyph(5, 4, 196); // -
            // Coluna 1
            gameConsole.SetGlyph(2, 1, 179); // |
            gameConsole.SetGlyph(2, 3, 179); // |
            gameConsole.SetGlyph(2, 5, 179); // |
            // Coluna 2
            gameConsole.SetGlyph(4, 1, 179); // |
            gameConsole.SetGlyph(4, 3, 179); // |
            gameConsole.SetGlyph(4, 5, 179); // |
            // Borda exterior
            gameConsole.SetGlyph(0, 0, 201);
            for (int i = 1; i < 6; i++)
            {
                gameConsole.SetGlyph(i, 0, 205);
            }
            gameConsole.SetGlyph(6, 0, 187);
            gameConsole.SetGlyph(0, 6, 200);
            for (int i = 1; i < 6; i++)
            {
                gameConsole.SetGlyph(i, 6, 205);
            }
            gameConsole.SetGlyph(6, 6, 188);
            for (int i = 1; i < 6; i++)
            {
                gameConsole.SetGlyph(0, i, 186);
            }
            for (int i = 1; i < 6; i++)
            {
                gameConsole.SetGlyph(6, i, 186);
            }
            // Atualizar o ecrã com o marcador
            scoreBoard.Print(1, 1, "SadTacToe");
            for (int i = 0; i < 11; i++)
            {
                scoreBoard.SetGlyph(i, 2, 210);
            }
            scoreBoard.Print(1, 4, "Jogador 1");
            scoreBoard.Print(4, 6, "VS.");
            scoreBoard.Print(1, 8, "Jogador 2");
            scoreBoard.Print(4 - pontosJogador1.ToString().Length, 10, pontosJogador1.ToString());
            scoreBoard.Print(5, 10, "-");
            scoreBoard.Print(7, 10, pontosJogador2.ToString());
            for (int i = 0; i < 11; i++)
            {
                scoreBoard.SetGlyph(i, 12, 210);
            }
            scoreBoard.Print(0, 14, "Agora joga:");
            scoreBoard.Print(1, 15, quemJoga == Jogador.Humano ? "Jogador 1" : "Jogador 2");

            scoreBoard.Print(0, 25, "Tragedia by");
            if (dificuldade == DificuldadeAI.Easy)
            {
                scoreBoard.Print(0, 26, "Joao Ornelas");
                scoreBoard.SetGlyph(5, 27, 2);
            }
            else
            {
                scoreBoard.Print(0, 26, "  Belzebub  ");
                scoreBoard.SetGlyph(5, 27, 1);
            }
        }
Exemple #13
0
        void PrintPlayerName(Console console, string name, Color borderColor, bool doubleBorder)
        {
            int  width                   = console.Width;
            byte topLeftCorner           = 218,
                 topRightCorner          = 191,
                 bottomLeftCorner        = 192,
                 bottomRightCorner       = 217,
                 horizontalBorder        = 196,
                 verticalBorder          = 179;
            byte doubleTopLeftCorner     = 201,
                 doubleTopRightCorner    = 187,
                 doubleBottomLeftCorner  = 200,
                 doubleBottomRightCorner = 188,
                 doubleHorizontalBorder  = 205,
                 doubleVerticalBorder    = 186;
            char glyph;

            for (int rowIndex = 0; rowIndex < headerHeight; rowIndex++)
            {
                for (int colIndex = 0; colIndex < width; colIndex++)
                {
                    glyph = ' ';

                    if (rowIndex == 0)
                    {
                        if (colIndex == 0)
                        {
                            glyph = (char)(doubleBorder ? doubleTopLeftCorner : topLeftCorner);
                        }
                        else if (colIndex == width - 1)
                        {
                            glyph = (char)(doubleBorder ? doubleTopRightCorner : topRightCorner);
                        }
                        else
                        {
                            glyph = (char)(doubleBorder ? doubleHorizontalBorder : horizontalBorder);
                        }
                    }
                    else if (rowIndex == headerHeight - 1)
                    {
                        if (colIndex == 0)
                        {
                            glyph = (char)(doubleBorder ? doubleBottomLeftCorner : bottomLeftCorner);
                        }
                        else if (colIndex == width - 1)
                        {
                            glyph = (char)(doubleBorder ? doubleBottomRightCorner : bottomRightCorner);
                        }
                        else
                        {
                            glyph = (char)(doubleBorder ? doubleHorizontalBorder : horizontalBorder);
                        }
                    }
                    else if (colIndex == 0 || colIndex == width - 1)
                    {
                        glyph = (char)(doubleBorder ? doubleVerticalBorder : verticalBorder);
                    }

                    console.SetGlyph(colIndex, rowIndex, glyph, borderColor);
                }
            }
            console.Print(1, headerHeight / 3, name.Align(HorizontalAlignment.Center, width - 2));
        }