Improved level generation algorithm, fixed invisible hulls, turret projectile fix, fabricators work in mp

This commit is contained in:
Regalis
2016-02-11 21:37:37 +02:00
parent 5a38c4b1ef
commit 4f54e04c8c
32 changed files with 435 additions and 161 deletions

View File

@@ -176,7 +176,7 @@ namespace Barotrauma
Vector2 start = connection.Locations[0].MapPosition;
Vector2 end = connection.Locations[1].MapPosition;
int generations = (int)(Math.Sqrt(Vector2.Distance(start, end) / 10.0f));
connection.CrackSegments = GenerateCrack(start, end, generations);
connection.CrackSegments = MathUtils.GenerateJaggedLine(start, end, generations, 5.0f);
}
}
@@ -200,39 +200,6 @@ namespace Barotrauma
}
}
private List<Vector2[]> GenerateCrack(Vector2 start, Vector2 end, int generations)
{
List<Vector2[]> segments = new List<Vector2[]>();
segments.Add(new Vector2[] {start, end});
float offsetAmount = 5.0f;
for (int n = 0; n < generations; n++)
{
for (int i = 0; i < segments.Count; i++)
{
Vector2 startSegment = segments[i][0];
Vector2 endSegment = segments[i][1];
segments.RemoveAt(i);
Vector2 midPoint = (startSegment + endSegment) / 2.0f;
Vector2 normal = Vector2.Normalize(endSegment - startSegment);
normal = new Vector2(-normal.Y, normal.X);
midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, false);
segments.Insert(i, new Vector2[] { startSegment, midPoint });
segments.Insert(i+1, new Vector2[] { midPoint, endSegment });
i++;
}
}
return segments;
}
public void MoveToNextLocation()
{
currentLocation = selectedLocation;