Пример #1
0
        public void MoveBufferArea( int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop )
        {
            Commands.Add( new {
            command = FormatCommand( Command.MoveBufferArea ),
            sourceLeft,
            sourceTop,
            sourceWidth,
            sourceHeight,
            targetLeft,
            targetTop
              } );

              for( var y = sourceTop; y < sourceTop + sourceHeight; y++ ) {
            for( var x = sourceLeft; x < sourceLeft + sourceWidth; x++ ) {
              var sourceCell = GetCell( x, y );
              var targetCell = new ConsoleCell {
            BackgroundColor = sourceCell.BackgroundColor,
            Char = sourceCell.Char,
            ForegroundColor = sourceCell.ForegroundColor,
            X = targetLeft + ( x - sourceCell.X ),
            Y = targetTop + ( y - sourceCell.Y )
              };
              sourceCell.Char = ' ';
              SetCell( sourceCell );
              SetCell( targetCell );
            }
              }

              if( OnMoveBufferArea != null ) OnMoveBufferArea( sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop );
        }
Пример #2
0
 protected void SetCell( ConsoleCell cell )
 {
     Cells[ cell.X, cell.Y ] = cell;
 }
Пример #3
0
        public List<object> Tick(string command)
        {
            var oldLocation = new Point(_map.Location.X, _map.Location.Y);
              ExecuteAction(command);
              if (!_map.Noise.Bounds.InBounds(_map.PlayerLocation) || _map.BlocksPlayer[_map.PlayerLocation])
              {
            _map.Location = new Point(oldLocation.X, oldLocation.Y);
              }
              _map.Fov = (Grid<bool>)_map.BlocksSight.Fov(10, _map.PlayerLocation);

              _map.Seen.SetEach((seen, point) =>
            seen || _map.Fov[point]
              );

              var viewportGrid = _map.Noise.Copy(_map.Viewport);

              viewportGrid.ForEach(p =>
              {
            var point = new Point(p.X + _map.Location.X, p.Y + _map.Location.Y);

            var foregroundColor = GetForegroundColor(p, point);
            var backgroundColor = GetBackgroundColor(point);
            var value = (p.Equals(_map.Center) ? "@" : GetTile(point))[0];

            var cell = Console.GetCell(p.X, p.Y);
            var newCell = new ConsoleCell { ForegroundColor = foregroundColor, BackgroundColor = backgroundColor, Char = value, X = p.X, Y = p.Y };

            if (!cell.Equals(newCell))
            {
              Console.SetCursorPosition(p.X, p.Y);
              Console.ForegroundColor = foregroundColor;
              Console.BackgroundColor = backgroundColor;
              Console.Write(value.ToString());
            }
              });

              return Console.Flush();
        }