private LayoutVar LayoutManager(LayoutVar layoutVar) { int x = layoutVar.x; int z = layoutVar.z; int level = layoutVar.level; int size = layoutVar.size; if (x == z && level != size) { level += 1; z += 1; x = 0; } else if (z > x) { int temp = x; x = z; z = temp; } else if (z < x) { int temp = z; z = x; x = temp + 1; } layoutVar.x = x; layoutVar.z = z; layoutVar.level = level; return(layoutVar); }
private void PositionObjectsRadial(CityObject node) { LayoutVar variables = new LayoutVar(); Debug.Log("Size: " + GetArraySize(node)); variables.size = GetArraySize(node); GameObject[,] layout = new GameObject[variables.size, variables.size]; distance = distance * 1.3 / node.width; foreach (CityObject child in node.children) { layout[variables.z, variables.x] = child.form; Debug.Log(variables.x + " und " + variables.z); float xPos; float zPos; if (variables.x == 0 && variables.z == 0) { xPos = 1 - child.form.transform.localScale.x - (float)distance; zPos = 1 - child.form.transform.localScale.z - (float)distance; } else if (variables.x == 0 && variables.z != 0) { xPos = 1 - child.form.transform.localScale.x - (float)distance; zPos = layout[variables.z - 1, variables.x].transform.position.z - layout[variables.z - 1, variables.x].transform.localScale.z - child.form.transform.localScale.z - (float)distance * 2f; } else if (variables.x != 0 && variables.z == 0) { xPos = layout[variables.z, variables.x - 1].transform.position.x - layout[variables.z, variables.x - 1].transform.localScale.x - child.form.transform.localScale.x - (float)distance * 2f; zPos = 1 - child.form.transform.localScale.z - (float)distance; } else { xPos = layout[variables.z - 1, variables.x].transform.position.x - (float)distance * 2f; zPos = layout[variables.z, variables.x - 1].transform.position.z - (float)distance * 2f; } float yPos = 1.025f + (0.5f * child.height / 100) + (node.form.transform.localScale.y); child.form.transform.position = new Vector3(xPos, yPos, zPos); if (IsScope(child)) { float planeHeight = plane.transform.localScale.y / 2; child.form.transform.position += new Vector3(0, planeHeight, 0); PositionChildrenRadial(child); } LayoutManager(variables); } }