Ejemplo n.º 1
0
        private bool IsInSubconsole(IOSystemConfiguration configuration, int x, int y)
        {
            foreach (var config in configuration.GameplayWindowControls)
            {
                if (config.Position.Contains(x, y))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        private void CalculateLines(Size size, IOSystemConfiguration configuration)
        {
            byte connectTop    = 1;
            byte connectRight  = 2;
            byte connectBottom = 4;
            byte connectLeft   = 8;

            var mapping = new Dictionary <byte, char>
            {
                { 0, (char)254 },
                { 1, (char)186 },
                { 2, (char)205 },
                { 3, (char)200 },
                { 4, (char)186 },
                { 5, (char)186 },
                { 6, (char)201 },
                { 7, (char)204 },
                { 8, (char)205 },
                { 9, (char)188 },
                { 10, (char)205 },
                { 11, (char)202 },
                { 12, (char)187 },
                { 13, (char)185 },
                { 14, (char)203 },
                { 15, (char)206 },
            };

            var lines = new bool[size.Width, size.Height];

            _lineChars = new char?[size.Width, size.Height];

            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    lines[x, y] = !IsInSubconsole(configuration, x, y);
                }
            }

            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    if (lines[x, y])
                    {
                        byte tileConnects = 0;
                        if (x != 0 && lines[x - 1, y])
                        {
                            tileConnects |= connectLeft;
                        }
                        if (y != 0 && lines[x, y - 1])
                        {
                            tileConnects |= connectTop;
                        }
                        if (y != size.Height - 1 && lines[x, y + 1])
                        {
                            tileConnects |= connectBottom;
                        }
                        if (x != size.Width - 1 && lines[x + 1, y])
                        {
                            tileConnects |= connectRight;
                        }

                        _lineChars[x, y] = mapping[tileConnects];
                    }
                    else
                    {
                        _lineChars[x, y] = null;
                    }
                }
            }
        }