void SetStartAndEnd() { List <Planetoid> Planets = new List <Planetoid>(); for (int i = 1; i < PlanetoidLayerList.Count; i++) { Planets = Planets.Concat(PlanetoidLayerList[i]).ToList(); } start = Planets[0]; start.name = "START"; List <float> distances = new List <float>(); foreach (var p in Planets) { Vector3 s = start.transform.position - p.transform.position; distances.Add(s.magnitude); } int furthestPlanet = distances.IndexOf(distances.Max()); if (furthestPlanet != 0) { end = Planets[furthestPlanet]; end.name = "END"; end = Planets[furthestPlanet]; Planetoid endPlanet = end.GetComponent <Planetoid>(); endPlanet.myOutline.enabled = true; } }
void LandOnPlanet(Transform planet) { Debug.Log("Rocket landed on " + planet.name); transform.SetParent(planet, worldPositionStays: true); transform.SetPositionAndRotation(planet.position, Quaternion.identity); parentPlanet = planet.GetComponent <Planetoid>(); parentPlanet.UpdateColors(myColor); parentPlanet.mySparks.Play(); parentPlanet.myOutline.enabled = true; // attractableBodies.Remove(parentPlanet); parentPlanet.GetComponent <Collider2D>().enabled = false; TogglePhysics(false); }
// Use this for initialization void Start() { planetSR = targetPlanetoid.GetComponent <SpriteRenderer>(); planetoidOrigColor = planetSR.color; infoText = this.transform.GetChild(0).GetComponent <Text>(); }