// Instantiate Planetoid public PlanetoidBehaviour createPlanetoid() { GameObject new_planetoid_obj = new GameObject("planetoid_" + planetoids.Count); new_planetoid_obj.transform.parent = gameObject.transform; new_planetoid_obj.transform.localPosition = Vector3.zero; PlanetoidBehaviour new_planetoid = new_planetoid_obj.AddComponent <PlanetoidBehaviour>(); new_planetoid.solar_system = this; planetoids.Add(new_planetoid); return(new_planetoid); }
// Instantiate void Start() { // Variables planetoids = new List <PlanetoidBehaviour>(); // Debug PlanetoidBehaviour center_star = createPlanetoid(); center_star.star = true; center_star.planet_size = 1f; float ring_size = 3f; float orbit_spd_av = 1f; int ring_num = Random.Range(6, 8); for (int i = 0; i < ring_num; i++) { float planet_size = Random.Range(0.3f, 0.6f) * orbit_spd_av; float orbit_spd = Random.Range(0.01f, 0.01f) * orbit_spd_av; if (Random.Range(0f, 1f) < 0.5f) { orbit_spd = -orbit_spd; } PlanetoidBehaviour new_planet = createPlanetoid(); new_planet.transform.parent = center_star.transform; new_planet.orbit = true; new_planet.orbit_spd = orbit_spd; new_planet.orbit_size = ring_size; new_planet.planet_size = planet_size; if (Random.Range(0f, 1f) < 0.1f) { new_planet.star = true; } if (planet_size > 0.2f) { if (Random.Range(0f, 1f) < 0.5f) { PlanetoidBehaviour new_orbit_planet = createPlanetoid(); new_orbit_planet.transform.parent = new_planet.transform; new_orbit_planet.orbit = true; new_orbit_planet.orbit_spd = orbit_spd * Random.Range(1.2f, 2.5f); new_orbit_planet.orbit_size = planet_size * 3; new_planet.orbit_size = ring_size + (planet_size * 1.5f); float new_planet_size = Random.Range(0.2f, 0.4f) * planet_size; new_orbit_planet.planet_size = new_planet_size; if (Random.Range(0f, 1f) < 0.4f) { new_orbit_planet.star = true; } ring_size += (planet_size * 3); } } ring_size += (planet_size * 2) + Random.Range(0.8f, 1.5f); orbit_spd_av -= 0.12f; } }