示例#1
0
 /// <summary>
 /// Used for creating stars
 /// </summary>
 /// <param name="_name"></param>
 /// <param name="_solarIndex"></param>
 /// <param name="_solarSubType"></param>
 /// <param name="mass"></param>
 /// <param name="radius"></param>
 /// <param name="orbit"></param>
 /// <param name="_color"></param>
 /// <param name="_surfaceTemp"></param>
 public SolarBody(string _name, List <int> _solarIndex, SolarSubType _solarSubType, double mass, double radius, Orbit orbit, Color _color, double _surfaceTemp)
 {
     this.orbit      = orbit;
     this.mass       = mass;
     this.bodyRadius = radius;
     name            = _name;
     this.solarType  = solarType;
     solarIndex      = _solarIndex;
     color           = _color;
     surfaceTemp     = _surfaceTemp;
     surfacePressure = 1;                                    // In atm
     luminosity      = 3.846e33 / Mathd.Pow(mass / 2e30, 3); // in ergs per sec
     surfaceGravity  = GameDataModel.G * mass / (radius * radius) / 9.81;
     solarType       = SolarType.Star;
     solarSubType    = _solarSubType;
 }
示例#2
0
    public PlanetTile(SolarSubType solarSubType)
    {
        if (solarSubType == SolarSubType.Rocky)
        {
            var rand = Random.value;
            if (rand < .85)
            {
                planetTileType = PlanetTileType.Rocky;
            }
            else if (rand < .9)
            {
                planetTileType = PlanetTileType.Ice;
            }
            else if (rand < .95)
            {
                planetTileType = PlanetTileType.Desert;
            }
            else
            {
                planetTileType = PlanetTileType.Volcanic;
            }
        }
        else if (solarSubType == SolarSubType.EarthLike)
        {
            var rand = Random.value;
            if (rand < .75)
            {
                planetTileType = PlanetTileType.Ocean;
            }
            else if (rand < .85)
            {
                planetTileType = PlanetTileType.Grasslands;
            }
            else if (rand < .88)
            {
                planetTileType = PlanetTileType.Desert;
            }
            else if (rand < .93)
            {
                planetTileType = PlanetTileType.Ice;
            }
            else if (rand < .96)
            {
                planetTileType = PlanetTileType.Rocky;
            }
            else
            {
                planetTileType = PlanetTileType.Volcanic;
            }
        }
        else if (solarSubType == SolarSubType.Ice)
        {
            var rand = Random.value;
            if (rand < .85)
            {
                planetTileType = PlanetTileType.Ice;
            }
            else if (rand < .95)
            {
                planetTileType = PlanetTileType.Rocky;
            }
            else
            {
                planetTileType = PlanetTileType.Ocean;
            }
        }
        else if (solarSubType == SolarSubType.Desert)
        {
            var rand = Random.value;
            if (rand < .85)
            {
                planetTileType = PlanetTileType.Desert;
            }
            else if (rand < .95)
            {
                planetTileType = PlanetTileType.Rocky;
            }
            else
            {
                planetTileType = PlanetTileType.Volcanic;
            }
        }
        else if (solarSubType == SolarSubType.Ocean)
        {
            var rand = Random.value;
            if (rand < .9)
            {
                planetTileType = PlanetTileType.Ocean;
            }
            else if (rand < .95)
            {
                planetTileType = PlanetTileType.Rocky;
            }
            else
            {
                planetTileType = PlanetTileType.Ice;
            }
        }
        else if (solarSubType == SolarSubType.Volcanic)
        {
            var rand = Random.value;
            if (rand < .70)
            {
                planetTileType = PlanetTileType.Volcanic;
            }
            else if (rand < .95)
            {
                planetTileType = PlanetTileType.Rocky;
            }
            else
            {
                planetTileType = PlanetTileType.Desert;
            }
        }
        else
        {
            throw new System.Exception("Unknown Subtype");
        }

        GenerateRawMaterials();
    }
示例#3
0
    public SolarBody(string _name, List <int> _solarIndex, SolarType _solarType, SolarSubType _solarSubType, double mass, double radius, Orbit orbit, Color _color, SolarBody star)
    {
        this.orbit        = orbit;
        this.mass         = mass;
        this.bodyRadius   = radius;
        name              = _name;
        this.solarType    = _solarType;
        this.solarSubType = _solarSubType;
        solarIndex        = _solarIndex;
        color             = _color;
        surfaceGravity    = GameDataModel.G * mass / (radius * radius) / 9.81;
        surfacePressure   = 0; // In atm
        bondAlebo         = Random.value;

        var dist = orbit.sma;

        if (solarIndex.Count == 3)
        {
            dist = star.satelites[solarIndex[1]].orbit.sma;
        }

        if (solarType == SolarType.Moon || solarType == SolarType.DwarfPlanet)
        {
            surfacePressure = Random.Range(.01f, 1);
            greenhouse      = .0137328 * Mathd.Pow(surfacePressure, 2) + .0986267 * surfacePressure;
            if (greenhouse < 0)
            {
                greenhouse = 0;
            }
            surfaceTemp = Mathd.Pow(((1 - bondAlebo) * star.luminosity) / ((16 * Mathd.PI * 5.6705e-8) * Mathd.Pow(orbit.sma, 2)), .25) * Mathd.Pow((1 + .438 * greenhouse * .9), .25);

            var rand = Random.value;

            if (surfaceTemp - 273.15 < -50)
            {
                if (rand < .15)
                {
                    solarSubType = SolarSubType.Ice;
                }
                else if (rand < .2)
                {
                    solarSubType = SolarSubType.Volcanic;
                }
            }
            else if (surfaceTemp - 273.15 > 120)
            {
                if (surfacePressure > .1)
                {
                    if (rand < .75)
                    {
                        solarSubType = SolarSubType.Volcanic;
                    }
                }
                else
                {
                    if (rand < .25)
                    {
                        solarSubType = SolarSubType.Desert;
                    }
                }
            }
            else
            {
                if (surfacePressure > .5)
                {
                    if (rand < .55)
                    {
                        solarSubType = SolarSubType.Ocean;
                    }
                    else if (rand < .85)
                    {
                        solarSubType = SolarSubType.EarthLike;
                    }
                    else if (rand < .95)
                    {
                        solarSubType = SolarSubType.Volcanic;
                    }
                }
                else if (surfacePressure > .25)
                {
                    if (rand < .75)
                    {
                        solarSubType = SolarSubType.EarthLike;
                    }
                    else if (rand < .85)
                    {
                        solarSubType = SolarSubType.Ocean;
                    }
                }
            }
        }
        else if (solarSubType == SolarSubType.GasGiant)
        {
            surfacePressure = Random.Range(10, 100);
            greenhouse      = .0137328 * Mathd.Pow(surfacePressure, 2) + .0986267 * surfacePressure;
            if (greenhouse < 0)
            {
                greenhouse = 0;
            }
            surfaceTemp = Mathd.Pow(((1 - bondAlebo) * star.luminosity) / ((16 * Mathd.PI * 5.6705e-8) * Mathd.Pow(orbit.sma, 2)), .25) * Mathd.Pow((1 + .438 * greenhouse * .9), .25);
        }
        else if (solarType == SolarType.Planet && solarSubType == SolarSubType.Rocky)
        {
            var rand = Random.value;
            if (rand < .75)
            {
                surfacePressure = Random.Range(.01f, 2);
            }
            else
            {
                surfacePressure = Random.Range(.01f, 100);
            }

            greenhouse = .0137328 * Mathd.Pow(surfacePressure, 2) + .0986267 * surfacePressure;
            if (greenhouse < 0)
            {
                greenhouse = 0;
            }
            surfaceTemp = Mathd.Pow(((1 - bondAlebo) * star.luminosity) / ((16 * Mathd.PI * 5.6705e-8) * Mathd.Pow(orbit.sma, 2)), .25) * Mathd.Pow((1 + .438 * greenhouse * .9), .25);

            rand = Random.value;
            if (surfaceTemp - 273.15 < -50)
            {
                if (rand < .25)
                {
                    solarSubType = SolarSubType.Ice;
                }
            }
            else if (surfaceTemp - 273.15 > 120)
            {
                if (surfacePressure > 20)
                {
                    if (rand < .75)
                    {
                        solarSubType = SolarSubType.Volcanic;
                    }
                }
                else
                {
                    if (rand < .25)
                    {
                        solarSubType = SolarSubType.Desert;
                    }
                }
            }
            else
            {
                if (surfacePressure > 40)
                {
                    if (rand < .55)
                    {
                        solarSubType = SolarSubType.Volcanic;
                    }
                    else if (rand < .85)
                    {
                        solarSubType = SolarSubType.Ocean;
                    }
                }
                else if (surfacePressure > 20)
                {
                    if (rand < .55)
                    {
                        solarSubType = SolarSubType.Ocean;
                    }
                    else if (rand < .85)
                    {
                        solarSubType = SolarSubType.EarthLike;
                    }
                    else if (rand < .95)
                    {
                        solarSubType = SolarSubType.Volcanic;
                    }
                }
                else if (surfacePressure > .25)
                {
                    if (rand < .75)
                    {
                        solarSubType = SolarSubType.EarthLike;
                    }
                    else if (rand < .85)
                    {
                        solarSubType = SolarSubType.Ocean;
                    }
                }
            }
        }

        //------------Assigning Colors----------------//
        if (solarSubType == SolarSubType.Rocky)
        {
            color = Color.gray;
        }
        else if (solarSubType == SolarSubType.EarthLike)
        {
            color = Color.green;
        }
        else if (solarSubType == SolarSubType.Ice)
        {
            color = Color.white;
        }
        else if (solarSubType == SolarSubType.Desert)
        {
            color = Color.yellow;
        }
        else if (solarSubType == SolarSubType.Ocean)
        {
            color = Color.blue;
        }
        else if (solarSubType == SolarSubType.Volcanic)
        {
            color = Color.red;
        }

        if (solarType != SolarType.Star && solarSubType != SolarSubType.GasGiant)
        {
            GeneratePlanetTiles();
        }
    }
示例#4
0
    public SolarModel(string _name, int _index, Vector3 _position, Gradient sunSizeColor)
    {
        name             = _name;
        galacticPosition = _position;
        index            = _index;

        // Create star

        SolarSubType starSubType;
        double       sunMass;
        double       temp;
        float        sunDensity;

        float star = Random.value;

        if (star < .5f)
        {
            starSubType = SolarSubType.MainSequence;
            sunMass     = Random.Range(.1f, 60);
            temp        = (42000f / 599f) * sunMass + (1755000 / 599);
            sunMass    *= GameDataModel.sunMassMultiplication; // Sun Mass in solar masses
            sunDensity  = Random.Range(.5f, 4) * Units.k;
        }
        else if (star < .75f)
        {
            starSubType = SolarSubType.GasGiant;
            sunMass     = Random.Range(60f, 100);
            temp        = Random.Range(4000, 45000);
            sunMass    *= GameDataModel.sunMassMultiplication; // Sun Mass in solar masses
            sunDensity  = Random.Range(.1f, 2) * Units.k;
        }
        else
        {
            starSubType = SolarSubType.WhiteDwarf;
            sunMass     = Random.Range(.01f, 1);
            temp        = Random.Range(6000, 30000);
            sunMass    *= GameDataModel.sunMassMultiplication; // Sun Mass in solar masses
            sunDensity  = Random.Range(10f, 2000) * Units.k;
        }
        //float sunColorValue = (float) (sunMass / 100 / GameDataModel.sunMassMultiplication);
        //Color color = sunSizeColor.Evaluate(sunColorValue);
        Color  color      = ColorTempToRGB.TempToRGB((float)temp);
        double sunRadius  = Mathd.Pow(((sunMass / sunDensity) * 3) / (4 * Mathd.PI), 1 / 3d); // In meters
        var    solarIndex = new List <int>();

        solarIndex.Add(_index);

        solar = new SolarBody(_name + " " + starSubType.ToString(), solarIndex, starSubType, sunMass, sunRadius, new Orbit(), color, temp);

        int    numPlanets = (int)Random.Range(0, (float)Mathd.Pow(sunMass / GameDataModel.sunMassMultiplication, .25f) * 20);
        double sunSoi     = solar.SOI(sunMass);

        for (int i = 0; i < numPlanets; i++)
        {
            double sma = Random.Range((float)(solar.bodyRadius) * 1.1f, (float)(sunSoi * .25));
            float  lpe = Random.Range(0, 2 * Mathf.PI);

            float        satType = Random.value;
            double       planetMass;
            float        planetDensity;
            SolarType    planetType    = SolarType.Planet;
            SolarSubType planetSubType = SolarSubType.Rocky;
            float        ecc           = Random.Range(0, .01f);

            if (satType < .4f) //Rock planets
            {
                planetMass    = Random.Range(1f, 100f) * 1e+23;
                planetDensity = Random.Range(3.5f, 7) * Units.k;
            }
            else if (satType < .5f) //Gas Giants
            {
                planetDensity = Random.Range(.5f, 3) * Units.k;
                planetSubType = SolarSubType.GasGiant;
                planetMass    = Random.Range(1, 400) * 1e+25;
            }
            else if (satType < .7f) //Dwarf Planets
            {
                planetType    = SolarType.DwarfPlanet;
                planetDensity = Random.Range(3.5f, 7) * Units.k;
                planetMass    = Random.Range(1, 40) * 1e+21;
                ecc           = Random.Range(0.01f, .5f);
            }
            else //Meteors
            {
                planetDensity = Random.Range(3.5f, 7) * Units.k;
                planetType    = SolarType.Comet;
                planetMass    = Random.Range(1, 100) * 1e+13;
                ecc           = Random.Range(0.5f, 1);
            }

            double planetRadius = Mathd.Pow((((planetMass) / planetDensity) * 3) / (4 * Mathd.PI), 1 / 3d); // In meters



            var planetIndex = new List <int>();
            planetIndex.Add(solarIndex[0]);
            planetIndex.Add(i);

            color = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f));

            solar.satelites.Add(new SolarBody(name + " " + planetType.ToString() + " " + (i + 1), planetIndex, planetType, planetSubType, planetMass, planetRadius, new Orbit(sma, ecc, lpe, 0, lpe), color, solar));

            int   numMoonRange = 0;
            float moonChance   = 0;

            if (planetSubType == SolarSubType.GasGiant)
            {
                numMoonRange = 30;
                moonChance   = 1;
            }
            else if (planetType == SolarType.DwarfPlanet)
            {
                numMoonRange = 2;
                moonChance   = .1f;
            }
            else if (planetSubType == SolarSubType.Rocky)
            {
                numMoonRange = 5;
                moonChance   = .5f;
            }
            int numMoon = Random.Range(0, numMoonRange);

            double soi = solar.satelites[i].SOI(solar.mass);

            if (Random.value < moonChance)
            {
                for (int m = 0; m < numMoon; m++)
                {
                    double moonMass = Random.Range(.0001f, 50) * 1e+22;

                    sma   = Random.Range((float)solar.satelites[i].bodyRadius * 1.2f, (float)(soi * .75f));
                    lpe   = Random.Range(0, 2 * Mathf.PI);
                    color = new Color(Random.Range(0, 1f), Random.Range(0, 1f), Random.Range(0, 1f));
                    float        moonDensity = Random.Range(3.5f, 7) * Units.k;
                    double       moonRadius  = Mathd.Pow((((moonMass) / moonDensity) * 3) / (4 * Mathd.PI), 1 / 3d); // In meters
                    SolarType    moonType    = SolarType.Moon;
                    SolarSubType moonSubType = SolarSubType.Rocky;
                    ecc = Random.Range(0, .02f);
                    if (moonMass < 1e+16)
                    {
                        moonType = SolarType.Asteroid;
                        ecc      = Random.Range(0.02f, .5f);
                    }

                    var moonIndex = new List <int>();
                    moonIndex.AddRange(planetIndex);
                    moonIndex.Add(m);

                    solar.satelites[i].satelites.Add(new SolarBody(name + "Moon " + (i + 1), moonIndex, moonType, moonSubType, moonMass, moonRadius, new Orbit(sma, ecc, lpe, 0, lpe), color, solar));
                }
            }
        }
    }