- level generation refactoring: moved most of the generation logic to a static GaveGenerator class + some minor cleanup

- WIP method for splitting the voronoi cells to smaller ones and carving a small cave through them
This commit is contained in:
Regalis
2016-04-02 16:03:41 +03:00
parent 2a2ba80f9c
commit 39c9c78266
7 changed files with 745 additions and 557 deletions

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Voronoi2;
namespace Barotrauma
{
@@ -157,6 +158,33 @@ namespace Barotrauma
{
Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition;
var cells = level.GetCells(GameMain.GameScreen.Cam.WorldViewCenter, 2);
foreach (VoronoiCell cell in cells)
{
GUI.DrawRectangle(spriteBatch, new Vector2(cell.Center.X - 10.0f, -cell.Center.Y-10.0f), new Vector2(20.0f, 20.0f), Color.Cyan, true);
GUI.DrawLine(spriteBatch,
new Vector2(cell.edges[0].point1.X, -cell.edges[0].point1.Y),
new Vector2(cell.Center.X, -cell.Center.Y),
Color.White);
foreach (GraphEdge edge in cell.edges)
{
//GUI.DrawLine(spriteBatch,
// new Vector2(edge.point1.X, -edge.point1.Y),
// new Vector2(cell.Center.X, -cell.Center.Y),
// Color.White);
GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y),
new Vector2(edge.point2.X, -edge.point2.Y), Color.White);
}
foreach (Vector2 point in cell.bodyVertices)
{
GUI.DrawRectangle(spriteBatch, new Vector2(point.X, -point.Y), new Vector2(10.0f, 10.0f), Color.White, true);
}
}
if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 512) return;
pos.X = GameMain.GameScreen.Cam.WorldView.X -512.0f;
@@ -169,6 +197,8 @@ namespace Barotrauma
Color.White, 0.0f,
Vector2.Zero,
SpriteEffects.None, 0.0f);
}