Example #1
0
 public void PrepareMap()
 {
     for (var row = 0; row < _rows; ++row)
     {
         for (var col = 0; col < _cols; col++)
         {
             if (row == 0 || col == 0 || row == _rows - 1 || col == _cols - 1)
             {
                 _map[row, col] = RCell.Border;
             }
             else
             {
                 _map[row, col] = RCell.Diggable;
             }
         }
     }
     _generators.Get().Generate((int)(_rows / 2d), (int)(_cols / 2d), Direction.Center);
     _map.RecalculateHeatZone();
 }
Example #2
0
        public override void GenerateImpl(int row, int col, Direction dir)
        {
            var topRow  = row;
            var leftCol = col;

            GetTopLeftCorner(ref topRow, ref leftCol, dir);

            var maxRow = topRow + Height;
            var maxCol = leftCol + Width;

            for (var r = topRow; r < maxRow; ++r)
            {
                for (var c = leftCol; c < maxCol; ++c)
                {
                    if (r == topRow || c == leftCol || r == maxRow - 1 || c == maxCol - 1)
                    {
                        Map[r, c] = RCell.Wall | RCell.Important;
                    }
                    else
                    {
                        Map[r, c] = RCell.Floor;
                    }
                }
            }

            var treasureCount = (int)Math.Sqrt(Width * Height);

            for (var i = 0; i < treasureCount; ++i)
            {
                int chestRow;
                int chestCol;
                do
                {
                    chestRow = RHelper.Roll(topRow + 1, maxRow - 2);
                    chestCol = RHelper.Roll(leftCol + 1, maxCol - 2);
                } while (Map[chestRow, chestCol].Is(RCell.Chest));

                Map[chestRow, chestCol] |= RCell.Chest | _rarities.Get() | _sizes.Get();
            }

            if (dir != Direction.Center)
            {
                Map[row, col] = RCell.Door | RCell.Locked | RCell.Closed;
            }
        }