/// <summary> /// Spawns a planet /// </summary> public void SpawnPlanet(int seed, CelestialBody host = null) { bool hasHost = host != null; System.Random random = new System.Random(seed); GameObject go = new GameObject(); go.transform.parent = systemScale.transform; CelestialBody body; CelestialType type = hasHost ? CelestialType.GetRandomPlanetTypeExceptGas(random) : CelestialType.GetRandomPlanetType(random); if (type is CelestialType.GasPlanet) { body = new GasPlanet(controller, go, seed, host); int satellites = (int)Utility.GetRandomBetween(random, 1, 2.9); for (int i = 0; i < satellites; i++) { SpawnPlanet(seed + 100 + i, body); } } else if (type is CelestialType.WaterPlanet) { body = new WaterPlanet(controller, go, seed, host); AddAtmosphere(body); } else if (type is CelestialType.RockPlanet) { body = new RockPlanet(controller, go, seed, host); AddAtmosphere(body); } else if (type is CelestialType.MoltenPlanet) { body = new MoltenPlanet(controller, go, seed, host); AddAtmosphere(body); } else { body = new IcePlanet(controller, go, seed, host); AddAtmosphere(body); } if (host == null && random.NextDouble() < 0.3) { GameObject rings = new GameObject("rings"); rings.transform.parent = go.transform; var ringsScript = rings.AddComponent <PlanetRings>(); ringsScript.Init(controller, body); } controller.celestials.Add(body); }
private void OnEnable() { planet = (GasPlanet)target; }