public void GenerateSystem(int seed, int numberOfPlanets, bool hasAsteroidBelt, StarType starType) { GameObject newSystem = StarSystemGenerator.CreateSystem(seed, numberOfPlanets, hasAsteroidBelt, starType); newSystem.transform.parent = transform; Vector3 particlePosition = Random.insideUnitSphere * 200; particlePosition.y = Random.Range(-350, -500); ps [1].transform.position = particlePosition; for (int i = 0; i < ps.Length; i++) { ps[i].randomSeed = (uint)Random.Range(0, 99999); ps[i].Play(); } }
public StarSystemGenerator.StarSystemInfo GenerateSystem(StarSystem _starSystem, bool _active) { GameObject newSystem = StarSystemGenerator.CreateSystem(_starSystem.seed); newSystem.transform.parent = transform; //StarSystemGenerator.CreateSystemEdgeRing (seed).transform.parent = transform.GetChild(1); for (int i = 0; i < _starSystem.anomaliEvent.Length; i++) { GameObject newPoint = new GameObject("Anomali Event"); newPoint.transform.parent = newSystem.transform; newPoint.transform.localScale = new Vector3(2, 2, 2); newPoint.AddComponent <MeshFilter> ().mesh = SolarBodyGeneration.GetTorusMesh(); newPoint.AddComponent <MeshRenderer> ().material.mainTexture = new Texture(); newPoint.GetComponent <MeshRenderer> ().material.color = Color.white; GameObject newPoint2 = new GameObject(); newPoint2.transform.parent = newPoint.transform; newPoint2.transform.rotation = new Quaternion(-180, 0, 0, 0); newPoint2.transform.position = new Vector3(0, 6, 0); newPoint2.transform.localScale = new Vector3(2, 2, 2); newPoint2.AddComponent <MeshFilter> ().mesh = SolarBodyGeneration.GetConeMesh(); newPoint2.AddComponent <MeshRenderer> ().material.mainTexture = new Texture(); newPoint2.GetComponent <MeshRenderer> ().material.color = Color.white; //newPoint.transform.position = StarSystemGenerator.GetRandomPoint (StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed)); //Vector3 newPos = Random.insideUnitSphere * StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed); //newPos.y = 25; newPoint.transform.position = GetRandomNonCollidingPoint(StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed)); newPoint.tag = "EventPoint"; newPoint.AddComponent <SphereCollider> (); newPoint.AddComponent <EventPoint> ().eventNumber = i; newPoint.GetComponent <EventPoint> ().eventListNumber = Random.Range(0, 23); } if (_starSystem.mainEvent) { GameObject newPoint = new GameObject("Main Event"); newPoint.transform.parent = newSystem.transform; newPoint.transform.localScale = new Vector3(2, 2, 2); newPoint.AddComponent <MeshFilter> ().mesh = SolarBodyGeneration.GetTorusMesh(); newPoint.AddComponent <MeshRenderer> ().material.mainTexture = new Texture(); newPoint.GetComponent <MeshRenderer> ().material.color = Color.yellow; GameObject newPoint2 = new GameObject(); newPoint2.transform.parent = newPoint.transform; newPoint2.transform.rotation = new Quaternion(-180, 0, 0, 0); newPoint2.transform.position = new Vector3(0, 6, 0); newPoint2.transform.localScale = new Vector3(2, 2, 2); newPoint2.AddComponent <MeshFilter> ().mesh = SolarBodyGeneration.GetConeMesh(); newPoint2.AddComponent <MeshRenderer> ().material.mainTexture = new Texture(); newPoint2.GetComponent <MeshRenderer> ().material.color = Color.yellow; //newPoint.transform.position = StarSystemGenerator.GetRandomPoint (StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed)); //Vector3 newPos = Random.insideUnitSphere * StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed); //newPos.y = 25; //newPoint.transform.position = newPos; newPoint.transform.position = GetRandomNonCollidingPoint(StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed)); newPoint.tag = "MainEventPoint"; newPoint.AddComponent <SphereCollider> (); } if (_starSystem.trader) { GameObject newPoint = new GameObject("Trader"); newPoint.transform.parent = newSystem.transform; GameObject ob = Instantiate(traderGameObject [Random.Range(0, traderGameObject.Length)], new Vector3(0, -12, 0), traderGameObject [Random.Range(0, traderGameObject.Length)].transform.rotation, newPoint.transform); newPoint.transform.position = GetRandomNonCollidingPoint(StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed)); newPoint.tag = "Trader"; newPoint.AddComponent <SphereCollider> (); } if (_starSystem.researchOutpost) { GameObject newPoint = new GameObject("Research Outpost"); newPoint.transform.parent = newSystem.transform; GameObject ob = Instantiate(researchGameObject [Random.Range(0, researchGameObject.Length)], new Vector3(0, -12, 0), researchGameObject [Random.Range(0, researchGameObject.Length)].transform.rotation, newPoint.transform); newPoint.transform.position = GetRandomNonCollidingPoint(StarSystemGenerator.GetStarSystemEdgeDistance(_starSystem.seed)); newPoint.tag = "ResearchOutpost"; newPoint.AddComponent <SphereCollider> (); } Vector3 particlePosition = Random.insideUnitSphere * 200; particlePosition.y = Random.Range(-350, -500); ps [1].transform.position = particlePosition; ParticleSystem.MainModule mainP = ps [1].main; mainP.startColor = new ParticleSystem.MinMaxGradient(NebulaColour.GetColour(Random.Range(0, 4))); for (int i = 0; i < ps.Length; i++) { ps[i].Stop(); ps[i].Clear(); ps[i].randomSeed = (uint)Random.Range(0, 99999); ps[i].Play(); } newSystem.SetActive(_active); return(StarSystemGenerator.GetStarSystemInfo(_starSystem.seed)); }