public void CreateUpstairsRoofPlain(Transform parent, HouseCreatorCollection collection) { if (GetWidth() > 1f) { Vector3 ScaleDir; if (Dir == new Vector3(1, 0, 0)) { ScaleDir = new Vector3(0, 0, 1); } else { ScaleDir = new Vector3(1, 0, 0); } //TODO: Magic number deciding Roof height Vector3 NewOrigin = Origin + ScaleDir * .5f + Vector3.up * .75f; Vector3 NewSize = Size - ScaleDir; RoofPlane newRoofPlane = new RoofPlane(NewOrigin, NewSize, true); newRoofPlane.CreateRoof(parent, collection); } }
void GenerateRoofPlanes() { roofPlanes = new List <RoofPlane>(); List <GridPoint> ValidRoofPoints = new List <GridPoint>(); foreach (GridPoint gp in Grid) { if (!gp.IsWallType()) { ValidRoofPoints.Add(gp); } } foreach (GridPoint vrp in ValidRoofPoints) { //X --> Y int x = 0; int y = 0; bool Loop = true; while (Loop) { if (!CheckSquare(vrp, ValidRoofPoints, new Vector3(x, 0, y) * .5f)) { Loop = false; break; } x++; bool LoopY = true; while (LoopY) { if (x == 0) { y++; break; } for (int i = 0; i < x; i++) { if (!CheckSquare(vrp, ValidRoofPoints, new Vector3(i, 0, y) * .5f)) { LoopY = false; break; } } if (!LoopY) { break; } y++; } RoofPlane rp = new RoofPlane(vrp.Location, new Vector3(x, 0, y) * .5f); roofPlanes.Add(rp); y = 0; } //Y --> X x = 0; y = 0; Loop = true; while (Loop) { if (!CheckSquare(vrp, ValidRoofPoints, new Vector3(x, 0, y) * .5f)) { Loop = false; break; } y++; bool LoopY = true; while (LoopY) { if (y == 0) { x++; break; } for (int i = 0; i < y; i++) { if (!CheckSquare(vrp, ValidRoofPoints, new Vector3(x, 0, i) * .5f)) { LoopY = false; break; } } if (!LoopY) { break; } x++; } RoofPlane rp = new RoofPlane(vrp.Location, new Vector3(x, 0, y) * .5f); roofPlanes.Add(rp); x = 0; } } roofPlanes = roofPlanes.OrderByDescending(o => o.GetArea()).ToList(); }
Rect CreateRectFromRoofPlane(RoofPlane rp) { return(new Rect(rp.Origin.x, rp.Origin.z, rp.Size.x, rp.Size.z)); }