public GridPoint(HouseCreatorBase.PointType PT, Vector3 L) { Type = PT; Location = L; Dir = Vector3.zero; }
public Mesh GetMeshBasedOnPointType(HouseCreatorBase.PointType pointType, bool IsTop = false, bool IsSmall = false) { switch (pointType) { case HouseCreatorBase.PointType.Wall: return(GetRandomFullWall()); case HouseCreatorBase.PointType.HalfWall: return(GetRandomHalfWall()); case HouseCreatorBase.PointType.RoofEnd: if (IsSmall) { return(GetRandomFullRoofTopperEnd()); } if (IsTop) { return(GetRandomFullRoofEndTop()); } else { return(GetRandomFullRoofEnd()); } case HouseCreatorBase.PointType.HalfRoofEnd: if (IsSmall) { return(GetRandomHalfRoofTopperEnd()); } if (IsTop) { return(GetRandomHalfRoofEndTop()); } else { return(GetRandomHalfRoofEnd()); } case HouseCreatorBase.PointType.Roof: if (IsSmall) { return(GetRandomFullRoofTopper()); } if (IsTop) { return(GetRandomFullRoofCenterTop()); } else { return(GetRandomFullRoofCenter()); } case HouseCreatorBase.PointType.HalfRoof: if (IsSmall) { return(GetRandomHalfRoofTopper()); } if (IsTop) { return(GetRandomHalfRoofCenterTop()); } else { return(GetRandomHalfRoofCenter()); } case HouseCreatorBase.PointType.RoofStopper: return(GetRandomFullRoofStopper()); case HouseCreatorBase.PointType.HalfRoofStopper: return(GetRandomHalfRoofStopper()); default: return(null); } }
public GameObject CreateRoof(Transform parent, HouseCreatorCollection collection) { //Outlier in case the roof is one 1x1 if (GetArea() == 1) { return(CreateOneAreaRoof(parent, collection)); } GameObject Roof = new GameObject("roof"); Roof.transform.position = parent.transform.position; List <GridPoint> PointsToSpawn = new List <GridPoint>(); float TestSize; Vector3 NonTestedSize; Vector3 FlipScale = new Vector3(-1, 1, 1); //Takes care of X Directed Roofs if (Dir == new Vector3(1, 0, 0)) { TestSize = Size.x; NonTestedSize = new Vector3(0, 0, Size.z); FlipScale = new Vector3(-1, 1, 1); } else { TestSize = Size.z; NonTestedSize = new Vector3(Size.x, 0, 0); Dir *= -1; if (Upstairs == false) { Origin = Origin + new Vector3(0, 0, Size.z); } } //Generating Roofs on one side for (int i = 0; i <= TestSize - 1f; i++) { HouseCreatorBase.PointType Type = HouseCreatorBase.PointType.Roof; if (i == 0 || i == TestSize - 1) { Type = HouseCreatorBase.PointType.RoofEnd; } GridPoint gp; if (i == 0) { gp = new GridPoint(Type, Origin + Dir * 1f); gp.ForcedScale = FlipScale; } else { gp = new GridPoint(Type, Origin + Dir * i); } gp.Dir = Dir; PointsToSpawn.Add(gp); } if (PointsToSpawn.Count != TestSize) { GridPoint gp = new GridPoint(HouseCreatorBase.PointType.HalfRoofEnd, Origin + Dir * TestSize - Dir * .5f); gp.Dir = Dir; PointsToSpawn.Add(gp); } if (GetWidth() >= 1f) { //Generating Roofs on the other side for (int i = (int)Mathf.Floor(TestSize); i > 0; i--) { HouseCreatorBase.PointType Type = HouseCreatorBase.PointType.Roof; if (i == 1 || (i == Mathf.Floor(TestSize) && Mathf.Floor(TestSize) == TestSize)) { Type = HouseCreatorBase.PointType.RoofEnd; } GridPoint gp; if ((i == Mathf.Floor(TestSize) && Mathf.Floor(TestSize) == TestSize)) { gp = new GridPoint(Type, Origin + NonTestedSize + Dir * (i - 1)); gp.ForcedScale = FlipScale; } else { gp = new GridPoint(Type, Origin + NonTestedSize + Dir * i); } gp.Dir = Dir * -1f; PointsToSpawn.Add(gp); } if (Mathf.Floor(TestSize) != TestSize) { GridPoint gp = new GridPoint(HouseCreatorBase.PointType.HalfRoofEnd, Origin + Dir * TestSize + NonTestedSize - Dir * 0.5f); gp.ForcedScale = FlipScale; gp.Dir = Dir * -1f; PointsToSpawn.Add(gp); } } foreach (GridPoint gp in PointsToSpawn) { if (Upstairs) { gp.IsTop = true; } if (GetWidth() < 1) { gp.IsSmall = true; } gp.CreateGridObject(Roof.transform, collection, false); } CreateSidePices(Roof.transform, collection); CreateUpstairsRoofPlain(Roof.transform, collection); Roof.transform.SetParent(parent); return(Roof); }