void SaveBlueprint() { string fileName = "x"; GameObject[] planets = GameObject.FindGameObjectsWithTag("planet"); PlanetSystem planetSystem = new PlanetSystem(fileName, planets.Length); //planetSystem.planetBlueprints = new PlanetBlueprint[planets.Length]; for (int i = 0; i < planets.Length; ++i) { Planet planetScript = planets[i].GetComponent <Planet>(); planetSystem.planetBlueprints[i] = new PlanetBlueprint(planetScript.eccentricity, planetScript.semimajorAxis, planetScript.longitudeOfTheAscendingNode, planetScript.argumentOfPeriapsis, planetScript.trueAnomaly); } string json = JsonUtility.ToJson(planetSystem); string path = "assets/Blueprints/" + fileName + ".json"; if (File.Exists(path)) { File.Delete(path); } File.Create(path).Dispose(); using (StreamWriter streamWriter = new StreamWriter(path, true)) { streamWriter.Write(json); streamWriter.Close(); } }
public void AddHardPoints(PlanetSystem PS, GameObject PlanetGeometry) { float AngularInc = 360 / PS.planet.HardPoints; for (int i = 0; i < PS.planet.HardPoints; i++) { GameObject Blasta = null; if (PS.planet.Name == "Jupitor") { Blasta = Instantiate(Gun2, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; } else { Blasta = Instantiate(Gun, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; } //GameObject cube2 = GameObject.CreatePrimitive(PrimitiveType.Cube); Blasta.transform.parent = PlanetGeometry.transform; Blasta.transform.localPosition = CalculatePathag(0.5f, i * AngularInc); //cube2.transform.Rotate(0.0f, i * AngularInc, 0.0f); Blasta.transform.localRotation = Quaternion.Euler(0.0f, i * AngularInc, 0.0f); Blasta.transform.localScale = new Vector3(0.33f, 0.33f, 0.33f); Blasta.transform.name = "Hardpoint_" + i; } }
Vector3 GetUpdatedPos(Vector3 currentPos, Vector3 currentVel, PlanetSystem planet, float deltaTime) { for (int i = 0; i < ObjectsInSystem.Count; ++i) { if (planet == ObjectsInSystem[i]) { continue; } bool ignore = false; for (int j = 0; j < planet.ignoreThem.Count; ++j) { if (ObjectsInSystem[i] == planet.ignoreThem[j]) { ignore = true; break; } } if (ignore) { continue; } Vector3 dir = ObjectsInSystem[i].transform.position - planet.transform.position; Vector3 acceleration = dir.normalized * GravitationalConstant * ObjectsInSystem[i].Mass / dir.sqrMagnitude; currentVel += acceleration * Time.deltaTime; } Vector3 pos = currentPos + (currentVel * deltaTime); return(pos); }
private void DrawMoonsOrbit(PlanetSystem planetSystem) { GameObject folder = GameObject.Find(folderOrbits); float PointStep = (Mathf.PI * 2 / Settings.LineOrbit.CIRCLES_POINS); float ROrbit; for (int m = 0; m < planetSystem.moonsArray.Length; m++) { Moon moon = planetSystem.moonsArray[m]; ROrbit = (moon.orbitNumber + Settings.LineOrbit.EMPTY_PLANET_ORBITS_COUNT) * Settings.LineOrbit.ORBIT_MOON_SIZE; Vector3[] vec3arr = new Vector3[Settings.LineOrbit.CIRCLES_POINS + 1]; GameObject lineOrbit = new GameObject(); for (int i = 0; i < Settings.LineOrbit.CIRCLES_POINS; i++) { vec3arr[i] = new Vector3((int)ROrbit * Mathf.Cos(i * PointStep), (int)ROrbit * Mathf.Sin(i * PointStep), 0) + planetSystem.planet.position; } vec3arr[vec3arr.Length - 1] = vec3arr[0]; lineOrbit.name = "orbit moon" + moon.name; lineOrbit.AddComponent <ShowOrbitScript>(); lineOrbit.AddComponent <LineRenderer>(); LineRenderer lineRender = lineOrbit.GetComponent <LineRenderer>(); lineRender.positionCount = Settings.LineOrbit.CIRCLES_POINS + 1; lineRender.SetPositions(vec3arr); lineRender.startColor = lineRender.endColor = Settings.LineOrbit.COLOR; lineRender.material = new Material(Shader.Find("Legacy Shaders/Particles/Additive")); lineRender.transform.SetParent(folder.transform); } }
private void DrawMoons(PlanetSystem planetSys, Vector3 planetPos) { float y = 20; int step = 16; float scale = 6f; if (planetSys.moonsArray == null) { return; } for (int i = 0; i < planetSys.moonsArray.Length; i++) { Moon moon = planetSys.moonsArray[i]; GameObject go = GameObject.Instantiate( PrefabService.PlanetSystemMap[moon.type], new Vector3(planetPos.x, planetPos.y - i * step - y, planetPos.z), Quaternion.identity); go.transform.SetParent(folder.transform); go.name = moon.name; go.transform.localScale = new Vector3(scale, scale, scale); GameObject.Destroy(go.GetComponent <PlanetSysMapScr>()); var scr = go.AddComponent <SystemViewerPlanetScr>(); scr.subStarBody = moon; planetsSystemObjects.Add(go); scr.systemObjects = planetsSystemObjects; scr.oldScale = go.transform.localScale; } }
// Use this for initialization void Start() { PlanetSystem PS = new PlanetSystem().Create( "Earth", new Planet().Create(3.0f, 14.0f, 14.0f, 20.0f, 0.0f, 45.0f, 100.0f, Color.clear, 3, 90), new List <Moon> { new Moon().Create("Moon", 0.55f, 4.0f, 4.0f, 60.0f, 0.0f, 0.0f, 10.0f) } ); CreatePlanetSystem(PS); PlanetSystem PS1 = new PlanetSystem().Create( "Mars", new Planet().Create(4.5f, 25.0f, 23.0f, 10.0f, 0.0f, 0.0f, 80.0f, Color.red, 4, 0), new List <Moon> { new Moon().Create("Dres", 0.45f, 6.0f, 6.0f, 100.0f, 0.0f, 0.0f, 10.0f) } ); CreatePlanetSystem(PS1); PlanetSystem PS2 = new PlanetSystem().Create( "Mercury", new Planet().Create(2.0f, 7.0f, 7.0f, 10.0f, 0.0f, 0.0f, 80.0f, Color.blue, 1, 120), new List <Moon> { } ); CreatePlanetSystem(PS2); PlanetSystem PS3 = new PlanetSystem().Create( "Gassssssss", new Planet().Create(5.0f, 35.0f, 35.0f, 10.0f, 0.0f, 0.0f, 80.0f, Color.blue, 6, 120), new List <Moon> { } ); CreatePlanetSystem(PS3); PlanetSystem PS4 = new PlanetSystem().Create( "Jupitor", new Planet().Create(7.0f, 70.0f, 55.0f, 15.0f, 5.0f, 47.0f, 80.0f, Color.blue, 7, 120), new List <Moon> { new Moon().Create("Jup1", 0.4f, 10.0f, 9.0f, 120.0f, 0.0f, 0.0f, 10.0f), new Moon().Create("Jup2", 0.6f, 6.5f, 6.0f, 100.0f, 0.0f, 0.0f, 10.0f), new Moon().Create("Jup3", 0.7f, 7.0f, 7.0f, 60.0f, 0.0f, 0.0f, 10.0f) } ); CreatePlanetSystem(PS4); //set the cameras first view to the extents of the system. eventually set this up to be dynamic: //largest semimajoraxis + largets moons semimajoraxis + 4 - which ever system has the largest GameObject Cam = GameObject.Find("Main Camera"); Cam.camera.orthographicSize = 45; }
public PlanetSystem CreatePlanetSystem(double period,double orbitRadius, double orbitPosition) { PlanetSystem ps = new PlanetSystem(this, orbitRadius, orbitPosition); ps.Movement = new CircularMovementStrategy(period,orbitRadius); ps.Animate(orbitPosition); planetSystems.Add(ps); return ps; }
public PlanetSystem Create(string PlanetName, Planet p, List <Moon> moons) { PlanetSystem PS = new PlanetSystem(); PS.Name = PlanetName + " System"; p.Name = PlanetName; PS.planet = p; PS.Moons = moons; return(PS); }
public static PlanetSystem GetRandomPlanetSystem(int numberPlanet, Star motherStar) { Planet planet = PlanetCreator.CreatePlanet(numberPlanet, motherStar); PlanetSystem planetSystem = new PlanetSystem { planet = planet, moonsArray = MoonCreator.CreateMoonsArray(planet), }; return(planetSystem); }
public PlanetSystemViewer(PlanetSystem planetSystem, OpenView openViewDelegate) { this.openViewDelegate = openViewDelegate; this.planetSystem = planetSystem; this.planetSystem.Moved += new MovedEventHandler(planetSystem_Moved); InitializeComponent(); planetSystem_Moved(planetSystem); }
public GasGiantP(PlanetSystem _ps, string name, Physical phys) { PName = name; PS = _ps; PlanetType = PType.GasGiant; // set physical traits Physical = phys; //Physical.radius = _radius; //Physical.density = _density; //Physical.mass = (Mathf.PI * _radius * _radius * _radius * 4f) / 3f; }
void CreateSol() { var sf = new SF(true); Name = "Sol"; planetSystems = new List <PlanetSystem>(); Debug.Log("In CreateSol"); for (int i = 0; i < SF.names.Length; i++) { PlanetSystem ps = new PlanetSystem(SF.names [i], SF.phys [i], SF.orbits [i], SF.pType [i]); planetSystems.Add(ps); } }
void PlayBlueprint(PlanetSystem planetSystem) { ObjectManager objectManager = GetComponent <ObjectManager>(); for (int i = 0; i < planetSystem.planetBlueprints.Length; ++i) { objectManager.AddNewObject(planetSystem.planetBlueprints[i].eccentricity, planetSystem.planetBlueprints[i].semimajorAxis, planetSystem.planetBlueprints[i].longitudeOfTheAscendingNode, planetSystem.planetBlueprints[i].argumentOfPeriapsis, planetSystem.planetBlueprints[i].trueAnomaly); } }
private static PlanetSystem[] CreatePlanetSystems(Star star) { int planetCount = GetPlanetsAmaunt(star); if (planetCount == 0) { return(null); } PlanetSystem[] arr = new PlanetSystem[planetCount]; for (int i = 0; i < planetCount; i++) { arr[i] = PlanetSystemCreator.GetRandomPlanetSystem(i, star); } return(arr); }
public static void Inspector(PlanetSystem p) { GuiTools.DrawTitleChapter("Planets",12,true,0,Screen.width,Color.white); // Add if (GUILayout.Button(new GUIContent(" Add planet",CosmosInspector.GetIcon(13)))){ Planet[] planetsI = p.GetComponentsInChildren<Planet>(); int j=0; while (j<planetsI.Length){ planetsI[j].inspectorShowProperties = false; j++; } AddPlanet().inspectorShowProperties=true; GuiTools.SetSceneCamera( 0,0); } EditorGUILayout.Space(); // Random planet if (GUILayout.Button(new GUIContent(" Random planet",CosmosInspector.GetIcon(20)))){ RandomPlanet(); } // Random color if (GUILayout.Button(new GUIContent(" Random color",CosmosInspector.GetIcon(14)))){ p.RandomColor(); } GuiTools.DrawSeparatorLine(); Planet[] planets = p.GetComponentsInChildren<Planet>(); int i=0; while (i<planets.Length){ EditorUtility.SetSelectedWireframeHidden( planets[i].planet.GetComponent<Renderer>(),true); EditorUtility.SetSelectedWireframeHidden( planets[i].atmosphere.GetComponent<Renderer>(),true); PlanetProperties( planets[i]); i++; } GuiTools.DrawSeparatorLine(); if (GUILayout.Button( new GUIContent( " Clear",CosmosInspector.GetIcon(12)))){ if (EditorUtility.DisplayDialog( "Clear all planets","Are you sure ?","Delete","Cancel")){ p.ClearPlanets(); } } }
// Use this for initialization void Start() { Debug.Log("Started initialisation"); BaseGeom = GameObject.CreatePrimitive(PrimitiveType.Sphere); // Creates a base geometry to clone from //######################################################################################################################## s1 = new PlanetSystem(1.0f); s1.AddPlanet(1000.0f, new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), true); s1.AddPlanet(1.0f, new Vector3(0.0f, 0.0f, 3.0f), new Vector3(30.0f, 30.0f, 0.0f), false); s1.AddPlanet(10.0f, new Vector3(0.0f, 0.0f, 4.4944f), new Vector3(50.0f, 0.0f, 0.0f), false); s1.AddPlanet(0.2f, new Vector3(0.0f, 0.0f, 6.0913f), new Vector3(54.0f, 0.0f, 0.0f), false); //######################################################################################################################## BaseGeom.SetActive(false); // Hides said base geometry, must be left until last Debug.Log("Booted"); }
// Use this for initialization public void Init(PlanetSystem _ps) { PS = _ps; // assign parent planet System gameObject.name = PS.PName + "_view"; // set unity obj name // fetch planet sprite and set sprite Planet_Sprite = Resources.Load <Sprite> ("planet/" + PS.PName); SpriteRenderer sr = GetComponent <SpriteRenderer> (); sr.sprite = Planet_Sprite; // set initial visual position and size of planet //transform.localPosition = new Vector3 (PS.orbit.radius / 5e5f, 0,0); transform.localPosition = PS.Pos / 5e5f; float scale = Mathf.Sqrt(PS.planet.Physical.radius) / 5f; transform.localScale = new Vector3(scale, scale, 0); }
// Use this for initialization void Start() { body = GetComponent <Rigidbody2D> (); PlanetSystem ps = new PlanetSystem(orbitSpacing, numPlanets, minScale, maxScale); List <Vector2> planets = ps.generatePlanetLocations(); lr.SetVertexCount(circleSegments * numPlanets); int i = -1; foreach (Vector2 p in planets) { GameObject obj = Instantiate(planet); obj.transform.position = new Vector3(p.x, p.y, 10); obj.transform.localScale = Vector3.one * Random.Range(minScale, maxScale); MeshRenderer mr = obj.GetComponent <MeshRenderer> (); CreatePoints(circleSegments, i++ *orbitSpacing, i); } }
private void DrawMoons(PlanetSystem planetSystem) { var existingFolder = GameObject.Find(folderMoons); GameObject folder = existingFolder == null ? new GameObject(folderMoons) : existingFolder; GameObject obj; Moon moon; for (int i = 0; i < planetSystem.moonsArray.Length; i++) { moon = planetSystem.moonsArray[i]; Vector3 moonposition = planetSystem.moonsArray[i].position; obj = Object.Instantiate(PrefabService.PlanetSystemMap[moon.type], moonposition, Quaternion.identity); obj.name = planetSystem.planet.name + " " + (i + 1).ToString(); obj.transform.localScale += new Vector3( moon.mass * Settings.StarSystem.MOON_SCALE, moon.mass * Settings.StarSystem.MOON_SCALE, moon.mass * Settings.StarSystem.MOON_SCALE); obj.transform.SetParent(folder.transform); obj.GetComponent <PlanetSysMapScr>().body = moon; obj.GetComponent <RightClickableObjectSSB>().SetSSB(moon); folder.transform.SetParent(root.transform); } }
public Planet(PlanetSystem planetSystem) { this.planetSystem = planetSystem; }
private Dictionary<string, ArrayList> accumulateSystems() { Dictionary<string, ArrayList> availableSystems = new Dictionary<string, ArrayList>(); ArrayList specialSystems = new ArrayList (); ArrayList emptySystems = new ArrayList (); ArrayList regularSystems = new ArrayList (); foreach(PlanetSystem sys in systems.Values) { for (int i=0; i < systemCounts[sys]; i++) { if (sys.isFixed() && sys.Id == "Mecatol Rex") { //center = sys; } else if (sys.isUnattached() && gameManager.IsActive (Option.WormholeNexus) && sys.Id == "Wormhole Nexus"){ nexus = sys; } else if (sys.isSpecial()) { specialSystems.Add (sys); } else if (sys.isEmpty()) { emptySystems.Add (sys); } else { regularSystems.Add (sys); } } } availableSystems["Special"] = specialSystems; availableSystems["Empty"] = emptySystems; availableSystems["Regular"] = regularSystems; return availableSystems; }
public BoardSection CreateSection(int sectionNum, PlanetSystem[][] sectionArrays, int[] columnArray) { BoardSection section = new BoardSection (sectionNum, sectionArrays, columnArray, calculateNextOrigin (), HexPrefab, hexSize); return section; }
public SceneStateSystemViewer(Location location) { starSystem = Galaxy.StarSystemsArr[location.indexStarSystem]; planetSystem = starSystem.planetSystemsArray[location.indexPlanetSystem]; this.location = location; }
public void SetSystem(PlanetSystem pSystem, int sectionNumber, int row, int col) { hexMap[sectionNumber].SetSystem(pSystem, row, col); }
public void SetSystem(PlanetSystem sys, int row, int col) { //Debug.Log (row + " , " + col + " :::::: " + hexMap.Length + " ::::::::::: " + hexMap[row].Length); Vector2 arrayCoords = axialToArrayCoords(col, row); //Debug.Log (arrayCoords.x + " , " + arrayCoords.y); SystemHex hex = hexMap[(int)arrayCoords.x][(int)arrayCoords.y]; hex.System = sys; hex.SetSection(sectionNumber); hex.SetPosition(new Vector2(row, col)); fileManager = GameObject.Find("Manager").GetComponent<FileManager>(); Material topMaterial = hex.gameObject.transform.FindChild ("Top").renderer.material; topMaterial.mainTexture = fileManager.ReadSystemTexture(sys.Name, sys.Id, hex.gameObject); topMaterial.color = new Color(topMaterial.color.r, topMaterial.color.g, topMaterial.color.b, 1.0f); Material sideMaterial = hex.gameObject.renderer.material; sideMaterial.mainTexture = fileManager.ReadSystemTexture("Empty System 1", "Empty System 1", hex.gameObject); sideMaterial.color = new Color(0.035f, 0.075f, 0.212f, 1.0f); hex.gameObject.transform.FindChild("Top").gameObject.SetActive(true); hex.gameObject.name = hex.System.Name; if (sys.isSpecial()) { foreach (SystemHex iterHex in HexesInRadius(hex.GetPosition(), 1)) { iterHex.NextToSpecial = true; } } hex.IsValidPlacement = false; }
public BoardSection(int section, PlanetSystem[][] inMap, int[] inFirstColumns, Vector3 sectionOrigin, GameObject pHexPrefab, float pHexSize) { sectionNumber = section; origin = sectionOrigin; maxRowSize = inMap [inMap.Length / 2].Length/2; hexSize = pHexSize; firstColumns = inFirstColumns; hexMap = new SystemHex[inMap.Length][]; for(int i=0;i<inMap.Length;i++) { SystemHex[] hexRow = new SystemHex[inMap[i].Length]; for(int j=0;j<inMap[i].Length;j++) { //Create hex object and add systemHex script GameObject hexObject = (GameObject)GameObject.Instantiate(pHexPrefab, GetHexLocation (j,i), Quaternion.identity); SystemHex sysHex = hexObject.AddComponent<SystemHex>(); sysHex.System = inMap[i][j]; sysHex.SetSection(sectionNumber); sysHex.SetPosition(arrayCoordsToAxial(i, j)); hexObject.transform.parent = GameObject.Find("Board").transform; fileManager = GameObject.Find("Manager").GetComponent<FileManager>(); hexObject.transform.FindChild("Top").renderer.material.mainTexture = fileManager.ReadSystemTexture(inMap[i][j].Name, inMap[i][j].Id, hexObject); hexObject.name = inMap[i][j].Name; hexRow[j] = sysHex; } hexMap[i] = hexRow; } }
private BoardSection readMapSection(int sectionNumber, string dataType, string dataText, string fileName, StreamReader reader) { if (dataText == "<{>") { string line = reader.ReadLine().Trim (); // Read "first column" information string[] firstColumnStrings = readTextLine ("", line, fileName).Split (",".ToCharArray()); ArrayList firstCols = new ArrayList(); foreach(string numberString in firstColumnStrings) { firstCols.Add(System.Convert.ToInt32(numberString)); } int[] columnArray = (int[])firstCols.ToArray (typeof(int)); line = reader.ReadLine().Trim (); ArrayList mapGrid = new ArrayList(); do { string[] systemNames = readTextLine ("", line, fileName).Split (",".ToCharArray()); ArrayList systems = new ArrayList(); foreach(string name in systemNames) { systems.Add(gameManager.BoardMgr.GetSystem(name)); //Debug.Log ("Added " + name + ": " + ((PlanetSystem)systems[systems.Count-1]).Name + " , " + ((PlanetSystem)systems[systems.Count-1]).Id); } mapGrid.Add ((PlanetSystem[])systems.ToArray (typeof(PlanetSystem))); line = reader.ReadLine().Trim (); } while (line != "<}>"); // End of outermost block PlanetSystem[][] section = new PlanetSystem[mapGrid.Count][]; for (int i=0; i<mapGrid.Count; i++) { section[i] = (PlanetSystem[])mapGrid[i]; } return gameManager.BoardMgr.CreateSection(sectionNumber, section, columnArray); } else { throw new System.Exception(string.Format("Error reading file {0}:: got \"{1}\" should be <{>", fileName, dataText)); } }
public void CreatePlanetSystem(PlanetSystem PS) { GameObject System = Instantiate(GenericPlanetSystem, new Vector3(PS.planet.SemiMajoraxis, 0, 0), Quaternion.identity) as GameObject; System.name = PS.Name; GameObject P = System.transform.FindChild("Planet").gameObject; P.name = PS.planet.Name; P.GetComponent <EllipticalPathCS1>().Parent = gameObject; P.GetComponent <EllipticalPathCS1>().radiusA = PS.planet.SemiMajoraxis; P.GetComponent <EllipticalPathCS1>().radiusB = PS.planet.SemiMinoraxis; P.GetComponent <EllipticalPathCS1>().speed = PS.planet.OrbitalSpeed; P.GetComponent <EllipticalPathCS1>().eccentricity = PS.planet.LinearEccentricity; P.GetComponent <EllipticalPathCS1>().InclinationAngle = PS.planet.OrbitalInclination; P.GetComponent <EllipticalPathCS1>().angle = PS.planet.StartingPostion; P.transform.localScale = new Vector3(PS.planet.Size, PS.planet.Size, PS.planet.Size); GameObject PlanetGeometry = P.transform.FindChild("PlanetGeo").gameObject; PlanetGeometry.name = PS.planet.Name + "Geo"; PlanetGeometry.GetComponent <PlanetSpin>().spinSpeed = PS.planet.RotationSpeed; AddHardPoints(PS, PlanetGeometry); GameObject PlanetCamera = P.transform.FindChild("PlanetCamera").gameObject; PlanetCamera.camera.name = PS.planet.Name + "Camera"; PlanetCamera.camera.enabled = false; GameObject PlanetText = P.transform.FindChild("PlanetText").gameObject; PlanetText.name = PS.planet.Name + "Text"; TextMesh TM = (TextMesh)PlanetText.GetComponent(typeof(TextMesh)); TM.text = PS.planet.Name; PlanetText.SetActive(false); if (PS.planet._color == Color.clear) { PlanetGeometry.renderer.material = EarthMat; } else { PlanetGeometry.renderer.material = ColorMat; PlanetGeometry.renderer.material.color = PS.planet._color; } foreach (Moon M in PS.Moons) { GameObject Moona = Instantiate(MoonObj, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; Moona.transform.parent = System.transform; Moona.name = M.Name; Moona.transform.localScale = new Vector3(M.Size, M.Size, M.Size); Moona.GetComponent <EllipticalPathCS1>().Parent = P; Moona.GetComponent <EllipticalPathCS1>().radiusA = M.SemiMajoraxis; Moona.GetComponent <EllipticalPathCS1>().radiusB = M.SemiMinoraxis; Moona.GetComponent <EllipticalPathCS1>().eccentricity = M.LinearEccentricity; Moona.GetComponent <EllipticalPathCS1>().speed = M.OrbitalSpeed; Moona.GetComponent <EllipticalPathCS1>().InclinationAngle = M.OrbitalInclination; } }
private PlanetSystem readSystem(string dataText, string fileName, StreamReader reader, bool isHomeSystem) { if (dataText == "<{>") { // Start of block PlanetSystem system = new PlanetSystem(); string name = ""; string line = reader.ReadLine().Trim (); while (line != "<}>") { string[] lineParts; //Split category name from data lineParts = line.Split(":".ToCharArray(), 2); //Remove any extra whitespace from parts & set descriptive variables string newDataType = gameManager.LanguageMgr.StringToDataType(lineParts[0] = lineParts[0].Trim ()); string newDataText = lineParts[1] = lineParts[1].Trim (); if (newDataType == "Name") { name = readTextLine(newDataType, newDataText, fileName); if (name != "") { system.HasRealName = true; } else { system.HasRealName = false; } } else if (newDataType == "Expansion") { system.Expansion = gameManager.LanguageMgr.StringToExpansion(readTextLine(newDataType, newDataText, fileName)); } else if (newDataType == "Type") { string typeString = readTextLine (newDataType, newDataText, fileName); if (typeString != gameManager.LanguageMgr.StringToSTag("Standard") && typeString != gameManager.LanguageMgr.StringToSTag("Empty")) { if (isHomeSystem) { system.SysTypes = new SType[2]{gameManager.LanguageMgr.StringToSType(typeString), SType.Home}; } else { system.SysTypes = new SType[1]{gameManager.LanguageMgr.StringToSType (typeString)}; } } else if (isHomeSystem) { system.SysTypes = new SType[1]{SType.Home}; } } else if (newDataType == "Planets") { Planet[] planets = readPlanetsBlock(newDataType, newDataText, fileName, reader); ArrayList planetsForSystem = new ArrayList(); ArrayList wormholesForSystem = new ArrayList(); foreach(Planet planet in planets){ string[] parts = planet.Name.Split(' '); if (parts.Length == 2 && parts[1] == gameManager.LanguageMgr.StringToSTag ("Wormhole")) { Wormhole wormhole = new Wormhole(); wormhole.Name = planet.Name; wormholesForSystem.Add (wormhole); } else { planetsForSystem.Add (planet); } } system.Planets = (Planet[])planetsForSystem.ToArray(typeof(Planet)); system.Wormholes = (Wormhole[])wormholesForSystem.ToArray(typeof(Wormhole)); } else if (newDataType == "ID") { system.Id = readTextLine (newDataType, newDataText, fileName); } line = reader.ReadLine().Trim (); } // End of block if (system.HasRealName == false) { foreach(Planet planet in system.Planets){ if (name != "") { name += "/"; } name += planet.Name; } foreach(Wormhole wormhole in system.Wormholes) { if (name != "") { name += "/"; } name += wormhole.Name; } if (name == "") { name = gameManager.LanguageMgr.STagToString ("Empty") + " " + gameManager.LanguageMgr.STagToString("System"); } system.Name = name; } else if (system.Planets.Length == 1 && system.SysTypes.Length == 1 && system.SysTypes[0] == SType.Special){ system.Name = system.Planets[0].Name + " " + name; } else { system.Name = name; } if (system.Id == default(string)) { system.Id = system.Name; } return system; } else { throw new System.Exception(string.Format("Error reading file {0}:: got \"{1}\" should be <{>", fileName, dataText)); } }