private void createAsteroidCircle(SolarSystem solarSystem, int _circleNo, asteroidCircleTypes _type)
        {
            int           degrees  = 0;
            double        angle    = Math.PI * degrees / 180.0;
            int           x_last   = 0;
            int           y_last   = 0;
            asteroidTypes lastType = 0;

            while (degrees < 360)
            {
                angle = Math.PI * degrees / 180.0;
                int x_new = (int)(centerX + (_circleNo + 2) * Math.Cos(angle));
                int y_new = (int)(centerX + (_circleNo + 2) * Math.Sin(angle));
                if (x_new != x_last || y_new != y_last)
                {
                    x_last = x_new;
                    y_last = y_new;

                    lastType = typeDetector.getAsteroidType(lastType, _type);
                    if (lastType != asteroidTypes.None)
                    {
                        if (!solarSystem.systemElements.Any(e => e.x == x_new && e.y == y_new))
                        {
                            systemElement asteroid = createElement(solarSystem, _circleNo, 0);
                            asteroid.x    = x_new;
                            asteroid.y    = y_new;
                            asteroid.type = typeDetector.asteroidObjectId(lastType);
                            if (x_last == centerX || y_last == centerX)
                            {
                                writeCoords(asteroid);
                            }
                        }
                    }
                }
                degrees += 3;
            }
        }
        public SolarSystem check(bool _paint, bool _text, sunTypes _type, bool _startingSystem, SolarSystem system)
        {
            //?redo if the planets are not distributed evenly?  - if all are clustered in one corner, should the system be kept?
            //code...

            //the system should have at least 2 non gas giant planets?
            //code...

            //redo if it is a starting system and does not contain exactly one habitable planet
            if (startingSystemTypeDetector.habitablePlanetCount != 1 && _startingSystem)
            {
                return(createSystem(_paint, _text, _type, _startingSystem));
            }

            return(system);
        }
        private void createMoons(SolarSystem solarSystem)
        {
            for (int i = 0; i < solarSystem.systemElements.Count; i++)
            {
                if (solarSystem.systemElements[i].circleNo < 2)
                {
                    continue;                                             //innermost circle has no moons
                }
                if (solarSystem.systemElements[i].type == 10 || solarSystem.systemElements[i].type == 11)
                {
                    continue;                                                                                       //no asteroid has moons
                }
                if (solarSystem.systemElements[i].childOf > 0)
                {
                    continue;                                   //moons themselves do not have moons
                }
                int numberOfMoons = randomGenerator.Next(0, 3); //up to two moons
                int firstMoonX    = -10;
                int firstMoonY    = -10;
                for (int j = 0; j < numberOfMoons; j++)
                {
                    int newX = solarSystem.systemElements[i].x;
                    int newY = solarSystem.systemElements[i].y;

                    systemElement dummymoon  = createDummyElement(solarSystem.systemElements[i].circleNo, solarSystem.systemElements[i].id);
                    bool          skip       = false;
                    int           retryCount = 0;
                    while (true)
                    {
                        retryCount++;
                        if (retryCount == 100)
                        {
                            skip = true;
                            break;
                        }

                        newX = randomGenerator.Next(-1, 2) + solarSystem.systemElements[i].x;
                        newY = randomGenerator.Next(-1, 2) + solarSystem.systemElements[i].y;
                        if (newX == solarSystem.systemElements[i].x && newY == solarSystem.systemElements[i].y)
                        {
                            continue;                                                                                     //moon has to be on a diefferent position than its planet
                        }
                        if (newX == firstMoonX && newY == firstMoonY)
                        {
                            continue;                                           //moon has to be on a diefferent position than its sibling-moon (values are set by the first moon
                        }
                        //todo: check that moon is not on same field as asteroid...
                        systemElement coordCheck = solarSystem.findSystemElementsWithCoords(newX, newY);
                        if (coordCheck != null)
                        {
                            continue;
                        }

                        dummymoon.x = newX;
                        dummymoon.y = newY;
                        solarSystem.neighbouringStars.Clear();
                        for (int z = 0; z < solarSystem.systemElements.Count; z++)
                        {
                            if (solarSystem.systemElements[z].type == 10 || solarSystem.systemElements[z].type == 11 || // no asteroids to check
                                solarSystem.systemElements[z].id == solarSystem.systemElements[i].id ||           //not the own motherplanet to check
                                solarSystem.systemElements[z].childOf == solarSystem.systemElements[i].id)        //not the sibling to check
                            {
                                continue;
                            }

                            solarSystem.neighbouringStars.Add(solarSystem.systemElements[z]);
                        }

                        if (dummymoon.checkAgainstNeighbours(solarSystem.neighbouringStars, 2))
                        {
                            break;
                        }
                    }
                    if (skip)
                    {
                        continue;
                    }

                    systemElement moon = solarSystem.createFromDummyElement(dummymoon);
                    firstMoonX = moon.x;
                    firstMoonY = moon.y;
                    moon.type  = typeDetector.getMoonType(solarSystem.systemElements[i].circleNo);
                    writeCoords(moon);
                }
            }
        }
        private void createCircles(SolarSystem solarSystem)
        {
            int preventNewAsteroid = 0;

            for (int i = 1; i < maxCircles; i++)
            {
                var Type = typeDetector.getPlanetType(i);

                if (Type == 0)
                {
                    continue;
                }

                if (solarSystem.StartSystem)
                {
                    if (i > 11)
                    {
                        continue;
                    }

                    switch (Type)
                    {
                    case 9:
                    case 10:
                    case 11:
                    case 12:
                        createAsteroidCircle(solarSystem, i, (asteroidCircleTypes)(Type - 9));
                        AsteroidCirclesCount++;
                        solarSystem.AsteroidCirclesCount++;
                        break;

                    default:
                        createPlanetCircle(solarSystem, i, Type);
                        break;
                    }
                }
                else
                {
                    if (Type > 8 && Type < 13)
                    {
                        //do not place an asteroid circle right beneath another one
                        if (i == preventNewAsteroid + 1)
                        {
                            continue;
                        }

                        preventNewAsteroid = i;
                        AsteroidCirclesCount++;
                        solarSystem.AsteroidCirclesCount++;


                        asteroidCircleTypes asteroidCircleType = (asteroidCircleTypes)randomGenerator.Next(0, 4);

                        createAsteroidCircle(solarSystem, i, asteroidCircleType);


                        if (showText && TextBox != null)
                        {
                            TextBox.Text += " Circle " + i + " Asteroid " + asteroidCircleType.ToString() + Environment.NewLine;
                        }
                    }
                    else
                    {
                        if (showText && TextBox != null)
                        {
                            TextBox.Text += " Circle " + i + " Planet" + Environment.NewLine;
                        }
                        createPlanetCircle(solarSystem, i, Type);

                        preventNewAsteroid = preventNewAsteroid > 0 ? preventNewAsteroid - 1 : 0;
                    }
                }
            }
        }
        private void createSun(SolarSystem solarSystem, sunTypes _type)
        {
            systemElement sun     = createElement(solarSystem, -1, -1);
            int           centerX = (SolarSystem.Size / 2);

            sun.x    = centerX - 1; //11, since coords go from 0->23, and the sun is not a point but two whole coords (11-13)
            sun.y    = centerX - 1;
            sun.size = 2;

            switch (_type)
            {
            case sunTypes.WhiteGiant:
                sun.type = 45;
                break;

            case sunTypes.YellowGiant:
                sun.type = 45;
                break;

            case sunTypes.OrangeGiant:
                sun.type = 45;
                break;

            case sunTypes.RedGiant:
                sun.type = 50;
                break;

            case sunTypes.MSWhite:
                sun.type = 45;
                break;

            case sunTypes.MSBlue:
                sun.type = 45;
                break;

            case sunTypes.MSYellow:
                sun.type = 59;
                break;

            case sunTypes.MSOrange:
                sun.type = 55;
                break;

            case sunTypes.MSRed:
                sun.type = 50;
                break;

            case sunTypes.WhiteDwarfStar:
                sun.type = 45;
                break;

            default:
                sun.type = 55;
                break;
            }

            //sun.type = (randomGenerator.Next(0, 3) * 10) + 45;
            //45	Blauer Riese
            //50	Roter Riese
            //55	Oranger Riese

            writeCoords(sun);
        }