private void PlaceRoof(int x, int y, int level, Transform wingFolder, RoofType type, RoofDirection direction, Vector3 scale) { Transform r; r = Instantiate( roofPrefab[(int)type], wingFolder.TransformPoint( new Vector3( x * -3f + rotationOffset[(int)direction].x, level * 2.5f + (type == RoofType.Point ? -0.3f : 0f), y * -3f + rotationOffset[(int)direction].z ) ), Quaternion.Euler(0f, rotationOffset[(int)direction].y, 0f) ); r.localScale = new Vector3(scale.x, Mathf.Min(Mathf.Min(scale.x, scale.z), 2f), scale.z); r.SetParent(wingFolder); Material[] materials = r.GetChild(0).GetComponent <MeshRenderer>().materials; if (type == RoofType.Slope) { materials[2].SetColor("_Color", bldgColor); } else if (type == RoofType.Point) { materials[1].SetColor("_Color", bldgColor); } else if (type == RoofType.Peak) { materials[3].SetColor("_Color", bldgColor); } }
private void PlaceRoof(int x, int y, int topLevel, Transform wingParent, RoofType type, RoofDirection direction) { Transform roof = Instantiate( roofPrefab[(int)type], wingParent.TransformPoint( new Vector3( x, topLevel, y ) ), Quaternion.Euler(0f, rotationOffset[(int)direction].y, 0f) ); roof.SetParent(wingParent); }