Exemplo n.º 1
0
        public void Clear(int x, int y)
        {
            var mut = new GridMutation();

            mut.AddSource(x, y);
            Render(mut);
        }
Exemplo n.º 2
0
        public void Render(int x, int y, char symbol, int color = DrawablePoint.DefaultForeColor, char d = ' ')
        {
            var dp = new DrawablePoint(x, y, color, symbol, d);
            var m  = new GridMutation();

            m.AddTarget(dp);
            Render(m);
        }
Exemplo n.º 3
0
        public static GridMutation Create(IEnumerable <Point> sources, IEnumerable <DrawablePoint> targets)
        {
            var m = new GridMutation();

            m.AddSources(sources);
            m.AddTargets(targets);

            return(m);
        }
Exemplo n.º 4
0
        public static GridMutation Create(Point source, DrawablePoint target)
        {
            var m = new GridMutation();

            m.AddSource(source);
            m.AddTarget(target);

            return(m);
        }
Exemplo n.º 5
0
        public void Render(int x, int y, char symbol, int oldX, int oldY, int color = DrawablePoint.DefaultForeColor, char d = ' ')
        {
            var @new = new DrawablePoint(x, y, color, symbol, d);
            var old  = new Point(oldX, oldY);
            var mut  = new GridMutation();

            mut.AddSource(old);
            mut.AddTarget(@new);
            Render(mut);
        }
Exemplo n.º 6
0
        public void ProcessUpdates(CancellationToken cancellationToken)
        {
            while (true)
            {
                GridMutation m = _mutations.Take();
                // Clears blocks after move
                foreach (var p in m.SourcePositions)
                {
                    if (p.X < 0 || p.Y < 0)
                    {
                        continue;
                    }

                    Console.SetCursorPosition(p.X, p.Y);
                    Console.Write(' ');
                }
                // Renders the block on the new position
                foreach (var p in m.TargetPositions)
                {
                    if (p.X < 0 || p.Y < 0)
                    {
                        continue;
                    }

                    if (Console.ForegroundColor != (ConsoleColor)p.ForeColor)
                    {
                        Console.ForegroundColor = (ConsoleColor)p.ForeColor;
                    }
                    Console.SetCursorPosition(p.X, p.Y);
                    Console.Write(_settings.Debug ? p.Debug : p.Symbol);
                }
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }
            }
        }
Exemplo n.º 7
0
 public void Render(GridMutation mutation)
 => _mutations.Add(mutation);