Ejemplo n.º 1
0
        public void PaintCellEllipse(int xStart, int yStart, int xEnd, int yEnd, Cell cell)
        {
            // Draw an ellipse centered in the passed-in coordinates
            float xCenter = (xEnd + xStart) / 2.0f;
            float yCenter = (yEnd + yStart) / 2.0f;
            float radius = Math.Min(xEnd - xStart, yEnd - yStart) / 2.0f;
            float xAxis = (xEnd - xStart) / 2.0f;
            float yAxis = (yEnd - yStart) / 2.0f;
            float majorAxisSquared = (float)Math.Pow(Math.Max(xAxis, yAxis), 2.0);
            float minorAxisSquared = (float)Math.Pow(Math.Min(xAxis, yAxis), 2.0);

            for (int y = yStart; y <= yEnd; y++)
                for (int x = xStart; x <= xEnd; x++)
                {
                    // Only draw if (x,y) is within the ellipse
                    if (Math.Sqrt((x - xCenter) * (x - xCenter) / majorAxisSquared + (y - yCenter) * (y - yCenter) / minorAxisSquared) <= 1.0f)
                        Cells[x, y] = cell;
                }
        }
Ejemplo n.º 2
0
        public void GenerateLevel()
        {
            // Create our Cell map and fill with Granite (we'll dig rooms out of it)
            Cells = new Cell[MapWidth, MapHeight];
            PaintCellRectangle(0, 0, MapWidth - 1, MapHeight - 1, new Cell_Granite(), true);

            rand = new Random(++seed);

            // Choose which type of Dungeon level we want to create.  Only one type for now, but this can
            // be replaced with a random selection between any number of Generators.  Farther out, we can
            // also tie generation of levels together (e.g. a "town" level generator can specify that the
            // next level generator should be a "sewer" level generator).
            DungeonLevelGenerator levelGenerator = new StandardLevelGenerator(this);
            levelGenerator.Generate();

            // Keep a pointer to our level generator for debug rendering purposes.
            _debugLevelGenerator = levelGenerator;
            SaveOnHD(m_filename);
        }
Ejemplo n.º 3
0
 public void PaintCellRectangle(int xStart, int yStart, int xEnd, int yEnd, Cell cell, bool forceDraw)
 {
     for (int y = yStart; y <= yEnd; y++)
         for (int x = xStart; x <= xEnd; x++)
         {
             if (forceDraw || Cells[x, y] == null || Cells[x, y].GetType() == typeof(Cell_Granite))
                 Cells[x, y] = cell;
         }
 }
Ejemplo n.º 4
0
 public void PaintCellIfEmpty(int x, int y, Cell cell)
 {
     if (x >= 0 && x < MapWidth && y >= 0 && y < MapHeight)
         if (Cells[x, y].GetType() == typeof(Cell_Granite))
             Cells[x, y] = cell;
 }