public string ExportNode() { string contents = "{\n"; contents += "name:" + gameObject.name + "\n"; contents += "position:" + MeshMaker.ExportVector(gameObject.transform.position) + "\n"; contents += "unit:" + System.Enum.GetName(System.Type.GetType("UnitType"), unitNode.unitType) + "\n"; contents += "unit-displace:" + MeshMaker.ExportVector(unitNode.gameObject.transform.position - gameObject.transform.position) + "\n"; string slinks = "link-to:"; foreach (CLink link in links) { CNode otherNode = link.nodes.Find(x => x != this); if (otherNode.GetType() == System.Type.GetType("CountryNode")) { CountryNode country = otherNode as CountryNode; slinks += country.country.countryName + "[" + country.country.nodes.IndexOf(country).ToString() + "]"; if (links.IndexOf(link) != links.Count - 1) { slinks += ","; } //e.g. Moscow[0] would be Moscow's base node - the number really only matters for coasts, which have multiple nodes } } slinks += "\n"; contents += slinks; contents += "}\n"; return(contents); }
public string ExportTerritory() { string contents = "<\n"; contents += "land:" + land.ToString() + "\n"; contents += "position:" + MeshMaker.ExportVector(gameObject.transform.position) + "\n"; string points = "points:"; Vector3[] vertices = gameObject.GetComponent <MeshFilter> ().mesh.vertices; for (int i = 0; i < vertices.Length; i++) { Vector3 vertex = vertices[i]; points += MeshMaker.ExportVector(vertex); if (i != vertices.Length - 1) { points += " "; } } contents += points + "\n"; contents += ">\n"; return(contents); }