Beispiel #1
0
 void Start()
 {
     if (planetPosition == null)
     {
         planetPosition = new PlanetPosition(gameObject);
         planetPosition.GenerateSeed();
     }
     else
     {
         planetPosition.SetParent(gameObject);
     }
     if (Data == null)
     {
         return;
     }
     if (Data.IsEmpty())
     {
         Create();
     }
     else
     {
         Visualize();
     }
     EcoZone = Star.EcosphereZone(this);
 }
Beispiel #2
0
    public void Create()
    {
        GameObject star = Instantiate(StarPrefab, this.transform.position, Quaternion.identity);

        star.transform.SetParent(this.transform);
        star.GetComponent <Star>().Create();
        ecoZone = Star.EcosphereZone(star);

        PlanetPosition planetPosition = new PlanetPosition(star);

        planetPosition.GenerateSeed();
        List <float> positions      = planetPosition.Positions();
        float        creationChance = (1f / positions.Count) * 3f;

        foreach (var position in positions)
        {
            //if (Random.Range(0f, 1f) < creationChance)
            //if (Random.Range(0f, 1f) < 0.4f)
            {
                float      radius = ((SpaceMath.AU * position) / SpaceMath.Unit);
                Vector3    pos    = new Vector3(1, 0, 0).normalized *radius *DistanceMult;
                GameObject planet = Instantiate(PlanetPrefab, this.transform.position + pos, Quaternion.identity);
                planet.transform.SetParent(star.transform);
                Zone planetZone = PlanetPositionZone(position);
                planet.GetComponent <Planet>().Create(planetZone);
            }
        }
    }
Beispiel #3
0
 public void DestroyPlanets()
 {
     for (int i = this.transform.childCount - 1; i >= 0; i--)
     {
         if (Application.isEditor)
         {
             DestroyImmediate(this.transform.GetChild(i).gameObject);
         }
         else
         {
             Destroy(this.transform.GetChild(i).gameObject);
         }
     }
     planetPosition.GenerateSeed();
 }