private void FillGalaxyWithStars(int numberOfStars, int minPlanets, int maxPlanets, bool[][] grid, Random r)
{
starSystems = new List<StarSystem>();
_quickLookupSystem = new Dictionary<int, StarSystem>();
StarNode starTree = new StarNode(0, 0, grid.Length - 1, grid.Length - 1);
//Set area where stars can be placed (circle, random, star, etc shaped galaxy)
for (int i = 0; i < grid.Length; i++)
{
for (int j = 0; j < grid[i].Length; j++)
{
if (!grid[i][j])
{
starTree.RemoveNodeAtPosition(i, j);
}
}
}
int starId = 0;
while (starTree.nodes.Count > 0 && numberOfStars > 0)
{
int x;
int y;
starTree.GetRandomStarPosition(r, out x, out y);
//int newSize = r.Next(3) + 2;
Color starColor = Color.White;
string description = string.Empty;
int randNum = r.Next(100);
if (randNum < 30)
{
starColor = Color.Red;
}
else if (randNum < 55)
{
starColor = Color.Green;
}
else if (randNum < 70)
{
starColor = Color.Yellow;
}
else if (randNum < 85)
{
starColor = Color.Blue;
}
else if (randNum < 95)
{
starColor = Color.White;
}
else
{
starColor = Color.Purple;
}
var newStarsystem = new StarSystem(NameGenerator.GetStarName(r), starId, x * PARSEC_SIZE_IN_PIXELS + (r.Next(PARSEC_SIZE_IN_PIXELS)), y * PARSEC_SIZE_IN_PIXELS + (r.Next(PARSEC_SIZE_IN_PIXELS)), starColor, description, minPlanets, maxPlanets, r);
starSystems.Add(newStarsystem);
_quickLookupSystem.Add(newStarsystem.ID, newStarsystem);
bool[][] invalidatedArea = Utility.CalculateDisc(2, 1);
for (int i = 0; i < invalidatedArea.Length; i++)
{
for (int j = 0; j < invalidatedArea.Length; j++)
{
int xToInvalidate = (x - 2) + i;
int yToInvalidate = (y - 2) + j;
starTree.RemoveNodeAtPosition(xToInvalidate, yToInvalidate);
}
}
numberOfStars--;
starId++;
}
}