//void Start() //{ // lr = GetComponent<LineRenderer>(); // if (a > b) // { // c = Mathf.Sqrt((a * a) - (b * b)); // center = new Vector3(focus1.position.x + c, 0, focus1.position.z); // } // else // { // c = Mathf.Sqrt((b * b) - (a * a)); // center = new Vector3(focus1.position.x, 0, focus1.position.z + c); // } // orbit = new Orbit(a, b, center); // DrawOrbit(); // SetOrbitalPosition(); // StartCoroutine(AnimateOrbit()); //} public void Init(string _name, float perigee, float apogee, float inclination, float period, Transform focus, int index, SatelliteObject obj) { this.name = _name; this.a = perigee; this.b = apogee; this.Inclination = inclination; this.orbitPeriod = period; this.focus1 = focus; this.index = index; this.satelliteObject = obj; lr = GetComponent <LineRenderer>(); if (a > b) { c = Mathf.Sqrt((a * a) - (b * b)); center = new Vector3(focus1.position.x + c, 0, focus1.position.z); } else { c = Mathf.Sqrt((b * b) - (a * a)); center = new Vector3(focus1.position.x, 0, focus1.position.z + c); } orbit = new Orbit(a, b, center); SatelliteName.text = name; DrawOrbit(); //transform.SetParent(focus1); SetOrbitalPosition(); //StartCoroutine(AnimateOrbit()); SpotLight.GetComponent <Light>().color = StormColorCode.Instance.Mat[Random.Range(0, 12)].GetColor("_TintColor"); }
IEnumerator HideInfo() { yield return(new WaitForSeconds(3)); if (obj == null) { obj = satellitePhysics.satelliteObject; } textMesh.text = obj.name; }
IEnumerator CreateSatellitBasedOnTime(int count, double dt) { if (count < SatelliteDictionary.Count) { SatelliteObject obj = SatelliteDictionary.ElementAt(count).Value; float diff = (float)(obj.TimeStamp - dt) / (10000000); //yield return new WaitForSeconds(diff/SatellitePhysics.speedConstant); yield return(new WaitForSeconds(.5f)); obj.CreateSatellite(count); StartCoroutine(CreateSatellitBasedOnTime(++count, obj.TimeStamp)); } else { StopCoroutine(CreateSatellitBasedOnTime(count, 0)); PasueOrPlay(); } }
public void ShowInfo() { string info = ""; if (obj == null) { obj = satellitePhysics.satelliteObject; } else { info = "Name : " + obj.name + "\n Epoch : " + obj.epoch + "\n Perigee : " + obj.perigee + "\n Apogee : " + obj.apogee + "\n Inclination : " + obj.inclination + "\n Mass : " + obj.mass + "\n Life : " + obj.life + "\n Plane : " + obj.plane + "\n Slot : " + obj.slot; } textMesh.text = info; StartCoroutine(HideInfo()); }
public void RegisterSatellite(SatelliteObject obj) { this.currSatellite = obj; }
void PopulateData() { row = grid.GetUpperBound(0); col = grid.GetUpperBound(1); for (int i = 1; i < col; i++) { int perigee = 0; int apogee = 0; int mass = 1600; int life = 777; if (!int.TryParse(grid[4, i], out perigee)) { Debug.Log("Error in input string : " + grid[4, i]); } if (!int.TryParse(grid[5, i], out apogee)) { Debug.Log("Error in input string : " + grid[5, i]); } if (!int.TryParse(grid[8, i], out mass)) { Debug.Log("Error in input string : " + grid[8, i]); } if (!int.TryParse(grid[9, i], out life)) { Debug.Log("Error in input string : " + grid[9, i] + ", Satellite name : " + grid[0, i]); } float inclination = float.Parse(grid[6, i]); float period = float.Parse(grid[7, i]); string planeSlot = grid[13, i].Trim(); string plane = planeSlot[0].ToString(); int slot = int.Parse(planeSlot[1].ToString()); SatelliteObject satellite = new SatelliteObject(SatellitePrefab, EarthGameObject, grid[0, i], perigee, apogee, grid[3, i], inclination, period, grid[12, i], plane, slot); satellite.otherName = grid[1, i]; satellite.launchTime = grid[2, i]; satellite.rocket = grid[10, i]; satellite.block = grid[11, i]; satellite.prn = grid[12, i]; satellite.life = life; satellite.mass = mass; if (!SatelliteDictionary.ContainsKey(satellite.TimeStamp)) { SatelliteDictionary.Add(satellite.TimeStamp, satellite); } else { Debug.Log("Time stamp repeated : new " + satellite.name + ", old : " + SatelliteDictionary[satellite.TimeStamp].name); } } // SatelliteDictionary.Values.First(); //foreach (KeyValuePair<double, SatelliteObject> entry in SatelliteDictionary) //{ // Debug.Log(entry.Value.name + " launched at " + entry.Value.LaunchAtOrbitTime); //} StartCoroutine(CreateSatellitBasedOnTime(0, SatelliteDictionary.Values.First().TimeStamp)); }