public GameObject loadStarSystem(OrbitalDetails orbitalDetails) { GameObject centreMass = Instantiate(systemCentreMass, new Vector3(0, 0, 0), Quaternion.identity); centreMass.name = "CentreMass"; CelestialBody centreMassBody = ((CelestialBody)centreMass.GetComponent(typeof(CelestialBody))); centreMassBody.loadDetails(orbitalDetails.getRadius(), orbitalDetails.getMass()); for (int i = 0; i < orbitalDetails.getOrbitingBodies().Count; i++) { GameObject planet = Instantiate(planetPrefab, centreMass.transform); planet.name = "Planet-" + i; OrbitingBody planetBody = ((OrbitingBody)planet.GetComponent(typeof(OrbitingBody))); planetBody.loadDetails(orbitalDetails.getOrbitingBodies()[i]); //moon generation for current planet for (int j = 0; j < orbitalDetails.getOrbitingBodies()[i].getOrbitingBodies().Count; j++) { GameObject moon = Instantiate(moonPrefab, planet.transform); moon.name = "Planet-" + i + "-Moon-" + j; OrbitingBody moonBody = ((OrbitingBody)moon.GetComponent(typeof(OrbitingBody))); moonBody.loadDetails(orbitalDetails.getOrbitingBodies()[i].getOrbitingBodies()[j]); } } return(centreMass); }
getPlanet(OrbitingBody orbitingBody) { GameObject BodyObj = PlanetRegistry[(int)orbitingBody]; var BodyBackgroundObj = BodyObj.GetComponent <OrbitingBodyBackgroundGameObject>(); return(BodyBackgroundObj); }
public void Should_have_name() { var planet = new OrbitingBody() { Name = "Test" }; Assert.That(planet.ToString(), Is.EqualTo("Planet Test")); }
// This method will be used to create star system manually, or to customize it. public void AddBodyTo(string parentBody, BodyProperties body, OrbitProperties orbit, string bodyName) { // This will be added to the root of the system, // Stars and main planets will belong to this level. GameObject newBody = CreateNewBody(bodyName, body); OrbitingBody orbitScript = CreateNewOrbit(bodyName, parentBody, orbit); orbitScript.AddBody(newBody, body); }
/// <summary> /// This is fine to use in code /// </summary> /// <param name="newFocus"></param> public void SetPlanetFocus(OrbitingBody newFocus) { MyContract.RequireFieldNotNull( PlanetCameraController, "PlanetCameraController" ); MyContract.RequireFieldNotNull( OrreryManager, "OrreryManager" ); PlanetCameraController.FollowTransform = OrreryManager.GetOrbitingBodyTransform(newFocus); ResetCamera(); }
public OrbitalDetails getOrbitalDetails(GameObject baseObject) { CelestialBody centreMassBody = ((CelestialBody)baseObject.GetComponent(typeof(CelestialBody))); OrbitalDetails orbitalDetails = new OrbitalDetails(centreMassBody.radius, centreMassBody.mass, new List <OrbitalDetails>()); foreach (Transform transform in baseObject.transform) { OrbitingBody planetBody = ((OrbitingBody)transform.gameObject.GetComponent(typeof(OrbitingBody))); OrbitalDetails planetOrbitalDetails = new OrbitalDetails(planetBody.radius, planetBody.mass, planetBody.getSemiMinorAxis(), planetBody.getSemiMajorAxis(), planetBody.getEccentricity(), planetBody.getFoci1(), planetBody.getFoci2(), planetBody.getCentre(), planetBody.getLocalCentreVector(), planetBody.getCurrentTheta(), planetBody.getCosineEllipseRotation(), planetBody.getSineEllipseRotation(), planetBody.getDistanceFromFoci(), new List <OrbitalDetails>()); foreach (Transform subTransform in transform) { OrbitingBody moonBody = ((OrbitingBody)subTransform.gameObject.GetComponent(typeof(OrbitingBody))); OrbitalDetails moonOrbitalDetails = new OrbitalDetails(moonBody.radius, moonBody.mass, moonBody.getSemiMinorAxis(), moonBody.getSemiMajorAxis(), moonBody.getEccentricity(), moonBody.getFoci1(), moonBody.getFoci2(), moonBody.getCentre(), moonBody.getLocalCentreVector(), moonBody.getCurrentTheta(), moonBody.getCosineEllipseRotation(), moonBody.getSineEllipseRotation(), moonBody.getDistanceFromFoci(), new List <OrbitalDetails>()); planetOrbitalDetails.addOrbitingBody(moonOrbitalDetails); } orbitalDetails.addOrbitingBody(planetOrbitalDetails); } return(orbitalDetails); }
public void Should_have_list_of_orbiting_bodies() { var planet = new OrbitingBody() { Name = "Test" }; Assert.That(planet.OrbitingBodies, Is.InstanceOf <IEnumerable <IOrbitingBody> >()); planet.AddPlanet(new OrbitingBody() { Name = "moon" }); Assert.That(planet.OrbitingBodies.Count, Is.EqualTo(1)); Assert.That(planet.OrbitingBodies.First(p => p.Name == "moon"), Is.InstanceOf <IOrbitingBody>()); }
public override void Init() { orbitingBody = sceneManager.user.selectedObject.GetComponent <OrbitingBody>(); if (!orbitingBody) { Debug.LogError("ERROR: NO ORBITING BODY SELECTED"); } base.Init(); next.next = this; next.previous = this; previous.next = this; previous.previous = this; /**/ }
public void Should_have_list_of_orbits_back_to_centre() { var sun = new OrbitingBody() { Name = "Sun" }; var earth = new OrbitingBody() { Name = "Earth" }; var moon = new OrbitingBody() { Name = "Moon" }; sun.AddPlanet(earth); earth.AddPlanet(moon); Assert.That(moon.Orbits, Is.InstanceOf <IEnumerable <IOrbitingBody> >()); }
public void Should_calculate_orbit_depth() { var sun = new OrbitingBody() { Name = "Sun" }; var earth = new OrbitingBody() { Name = "Earth" }; var moon = new OrbitingBody() { Name = "Moon" }; sun.AddPlanet(earth); earth.AddPlanet(moon); Assert.That(moon.OrbitDepth, Is.EqualTo(2)); }
public static OrbitingBodyMathematics generate_planet(OrbitingBody planet) { switch (planet) { case OrbitingBody.SUN: throw new Exception("Tried to generate the Sun as an OrbitingBody"); case OrbitingBody.MERCURY: return(generate_mercury()); case OrbitingBody.VENUS: return(generate_venus()); case OrbitingBody.EARTH: return(generate_earth()); case OrbitingBody.MOON: return(generate_moon(generate_earth())); case OrbitingBody.MARS: return(generate_mars()); case OrbitingBody.JUPITER: return(generate_jupiter()); case OrbitingBody.SATURN: return(generate_saturn()); case OrbitingBody.URANUS: return(generate_uranus()); case OrbitingBody.NEPTUNE: return(generate_neptune()); default: // cannot happen - this is an enum! throw new ArgumentException("Dropped out of generate_planet enum - shouldn't ever happen."); } }
public GameObject generateStarSystem(GameObject baseObject) { GameObject centreMass = Instantiate(systemCentreMass, new Vector3(0, 0, 0), Quaternion.identity, baseObject != null ? baseObject.transform : gameObject.transform); centreMass.name = "CentreMass"; float currentMinBodySeparation = Random.Range(initialMinBodySeparation, initialMaxBodySeparation); int totalPlanets = (int)Random.Range(minPlanetGeneration, maxPlanetGeneration); for (int i = 0; i < totalPlanets; i++) { GameObject planet = Instantiate(planetPrefab, centreMass.transform); planet.name = "Planet-" + i; OrbitingBody planetBody = ((OrbitingBody)planet.GetComponent(typeof(OrbitingBody))); planetBody.minBodySeparation = currentMinBodySeparation; planetBody.setupOrbit(); currentMinBodySeparation = planetBody.getDistanceFromFoci() + minBodySeparation; //moon generation for current planet float currentMinMoonSeparation = Random.Range(initialMinMoonSeparation, initialMaxMoonSeparation); int totalMoons = (int)Random.Range(minMoonGeneration, maxMoonGeneration); for (int j = 0; j < totalMoons; j++) { GameObject moon = Instantiate(moonPrefab, planet.transform); moon.name = "Planet-" + i + "-Moon-" + j; OrbitingBody moonBody = ((OrbitingBody)moon.GetComponent(typeof(OrbitingBody))); moonBody.minBodySeparation = currentMinMoonSeparation; moonBody.setupOrbit(); currentMinMoonSeparation = moonBody.getDistanceFromFoci() + minMoonSeparation; } } return(centreMass); }
void Setup() { rotationFlag = false; if (tidalLock == true) { speedCorrection = 0.0f; } else { rotationFlag = true; if (periodInMinutes > 0.0f) { rotationSpeed = 6.0f / periodInMinutes; } // Get orbital rotation period OrbitingBody script = transform.parent.gameObject.GetComponent <OrbitingBody>(); if (script != null) { float orbitalPeriod = script.periodInMinutes; if (orbitalPeriod > 0.0f) { speedCorrection = -6.0f / orbitalPeriod; } else { speedCorrection = 0.0f; } rotationSpeed += speedCorrection; } else { rotationFlag = false; } } }
public Transform GetOrbitingBodyTransform(OrbitingBody target) { return(PlanetRegistry[(int)target].transform); }
CalculateOrbitForPlanetAtDistance (OrbitingBody planetNumber, double distance) { return(new Vector3(0, 0, 0)); }
public void setNearestPlanet(OrbitingBody nearest_planet) { throw new NotImplementedException("setNearestPlanet disabled until it's actually used"); //current_nearest_orbiting_body = nearest_planet; }
public void warpTo(OrbitingBody orbiting_body) { WarpTo(getPlanet(orbiting_body)); }
/* adds a satellite in orbit around an existing body */ public void AddSatellite(CelestialType type) { /* * TODO: * 1) get larger radius of primary's furthest orbital path * 2) min valid orbit rad = furthestOrbit.region.upperLimit + minDist (for now) * 3) add satellite at some radius s.t. not overlapping with former furthest */ if (!_sceneIsEditable) { return; } CelestialBody primary; if (!user || !user.isActiveAndEnabled) { if (debugMode && debugSelectedObject) { primary = debugSelectedObject; } else { primary = initialStar; } } else if ((primary = user.selectedObject.GetComponent <CelestialBody> ()) == null) { return; } float furthestRegionLimit; if (primary.NumSatellites <= 0) { furthestRegionLimit = primary.naturalMaxSize / 2; } else { furthestRegionLimit = primary.FurthestSatellite.Region.Max; } float orbitRadius = furthestRegionLimit + CelestialBody.MinimumSeparatingDistance + templates[type].naturalMaxSize / 2; OrbitPath path = Instantiate(orbitPathTemplate); Debug.Log("orbit radius is " + orbitRadius); /* * TODO: spawn satellite at path's north position * set satellite's path * add satellite to SM's list of CBs */ OrbitingBody satellite = Instantiate(templates[type]); satellite.InitSatellite(primary, path, orbitRadius, orbitRadius); bodies.Add(satellite); primary.AddOrbitingBody(satellite); if (debugMode) { UpdateDisplayInfo(); } }