private void initBuffer()
        {   
            _width = Console.WindowWidth;
            _height = Console.WindowHeight;

            //_screenBuffer = new char[_width, _height];
            _screenBuffer = new CChar[_width, _height];

            for (int i = 0; i < _height; i++)
            {
                for (int j = 0; j < _width; j++)
                {
                    //_screenBuffer[j, i] = ' ';
                    _screenBuffer[j, i] = new CChar();
                    _screenBuffer[j, i].c = ' ';
                    _screenBuffer[j, i].fc = ConsoleColor.Black;
                    _screenBuffer[j, i].bc = ConsoleColor.Black;
                }
            }
        }
Beispiel #2
0
 public CChar MapTileToCChar()
 {
     CChar c = new CChar();
     c.c = visual;
     c.fc = getTileColor();
     c.bc = ConsoleColor.Black;
     return c;
 }
Beispiel #3
0
        public void draw()
        {
            CChar c = new CChar();
            //draw tiles
            for (int i = 0; i < _height; i++)
            {
                for (int j = 0; j < _width; j++)
                {
                    if (_tiles[j, i].isSeen())
                    {
                        Console.SetCursorPosition(j + _left, i + _top);
                        c.fc = Console.ForegroundColor = _tiles[j, i].getTileColor();
                        c.c = _tiles[j, i].visual;
                        Console.Write(_tiles[j, i].visual);
                        //Game.GC.Buffer.WriteToBuffer(j + _left, i + _top, _tiles[j, i].visual);
                        Game.GC.Buffer.WriteToBuffer(j + _left, i + _top, c);
                    }

                }
            }
            //refresh(list);
        }
Beispiel #4
0
 public void draw(Object character)
 {
     if (!character.isSeen())
     {   
         //if tile is seen but object not draw tile
         floorTile = _tiles[character.getX() - _dx, character.getY() - _dy];
         if (floorTile.isSeen())
         {
             redrawTile(floorTile);
             Game.GC.Buffer.WriteToBuffer(character.getX(), character.getY(), floorTile.MapTileToCChar());
         }
         return;
     }
     //get tile under character
     int left = character.getOldLeft();
     int top = character.getOldTop();
     floorTile = _tiles[left - _dx, top - _dy];
     //draw previous tile if nothing is there
     if (floorTile._objects.Count == 0 && floorTile.isSeen())
     {   
         Console.ForegroundColor = floorTile.getTileColor();
         Console.SetCursorPosition(left, top);
         Console.Write(_tiles[left - _dx, top - _dy].visual);
         //Game.GC.Buffer.WriteToBuffer(left, top, _tiles[left - _dx, top - _dy].visual);
         Game.GC.Buffer.WriteToBuffer(left, top, floorTile.MapTileToCChar());
     }
     //draw character if has been seen and it's on tile that has been seen
     left = character.getX();
     top = character.getY();
     int oleft = character.getOldLeft();
     int otop = character.getOldTop();
     floorTile = _tiles[left - _dx, top - _dy];
     if (floorTile.isSeen())
     {
         //if (left != oleft || top != otop)
         //{
             CChar c = new CChar();
             character.showObject();
             c.c = character.getVisual();
             c.fc = character.getColor();
             //Game.GC.Buffer.WriteToBuffer(left, top, character.getVisual());
             Game.GC.Buffer.WriteToBuffer(left, top, c);
         //}
     }
     //set cursor under character
     Console.SetCursorPosition(character.getX(), character.getY());
 }
Beispiel #5
0
 public static string AddColorCode(CChar c)
 {
     string cc = "";
     ConsoleColor color = c.fc;
     return cc = getColorCode(color);
 }
 public void WriteToBuffer(int left, int top, CChar c)
 {
     _screenBuffer[left, top] = c;
 }