public static void Even2Odd_Connect(HighStoreShelf_Parameter HP, MultiHighBay_Parameter MHP, GameObject OBJ) { //构件偶数高架库与奇数高架库之间的连接 float Width = HP.ColumnWidth + HP.VerticalStanchionWidth; GameObject obj = (GameObject)Resources.Load(Varibles.GlobalVariable.RootName + "/Elevated_Warehouse/Cube2");//加载侧面固定杆 Vector3 size = new Vector3(); size.x = MHP.HookupDistance; size.y = HP.HorizontalStanchionThick; size.z = HP.VerticalStanchionWidth; int Num1 = HP.FloorsNum / 2 + 1; //纵向个数 int Num2 = HP.ColumnsNum + 1; //横向个数 float High = HP.Size.y - HP.Height2Ground / 2; //首层距地高度的一半出开始纵向固定 float Temp_High = High / Num1; //纵向两根之间的高度 GameObject OBJ1 = new GameObject(); for (int i = 0; i < Num2; i++) { for (int j = 0; j <= Num1; j++) { GameObject clone = Instantiate(obj); clone.transform.localScale = size; clone.transform.parent = OBJ1.transform; clone.transform.localPosition = new Vector3(0, HP.Height2Ground / 2 + Temp_High * j - size.y / 2, -i * Width - HP.VerticalStanchionWidth / 2); } } OBJ1.transform.parent = OBJ.transform; OBJ1.transform.localPosition = new Vector3(0, 0, 0); GameObject obj1 = Instantiate(obj); obj1.transform.localScale = new Vector3(size.x, size.y, size.z / 2); obj1.transform.parent = OBJ.transform; obj1.transform.localPosition = new Vector3(0, HP.Size.y - size.y / 2, HP.ColumnWidth + size.z / 4); GameObject obj2 = Instantiate(obj); obj2.transform.localScale = new Vector3(size.x, size.y, size.z / 2); obj2.transform.parent = OBJ.transform; obj2.transform.localPosition = new Vector3(0, HP.Size.y - size.y / 2, -(HP.ColumnWidth + HP.VerticalStanchionWidth) * (HP.ColumnsNum + 1) - size.z / 4); }
public static void ConnectComponent(HighStoreShelf_Parameter HP, MultiHighBay_Parameter MHP, GameObject OBJ) { //增加高架库之间的连)接 int Num1 = (MHP.Num - 1) / 2; //偶数-奇数连接 int Num2 = (MHP.Num + 1) / 2; //奇数-偶数连接 float Depth = HP.Size.x; float TunnelWidth = MHP.TunnelWidth; float HookupDistance = MHP.HookupDistance; //进行奇偶高架库之间的连接 GameObject obj1 = new GameObject(); //奇偶高架库之间的连接部分 GameObject OBJ1 = new GameObject(); //所有奇偶高架库之间的连接部分 Odd2Even_Connect(HP, MHP, obj1); for (int i = 1; i <= Num2; i++) { GameObject clone = Instantiate(obj1); clone.transform.parent = OBJ1.transform; clone.transform.localPosition = new Vector3(-((2 * i - 1) * Depth + TunnelWidth / 2 + (i - 1) * (TunnelWidth + HookupDistance)), 0, 0); } //进行偶奇高架库之间的连接 GameObject obj2 = new GameObject(); //偶奇高架库之间的连接部分 GameObject OBJ2 = new GameObject(); //所有偶奇高架库之间的连接部分 Even2Odd_Connect(HP, MHP, obj2); for (int i = 1; i <= Num1; i++) { GameObject clone = Instantiate(obj2); clone.transform.parent = OBJ2.transform; clone.transform.localPosition = new Vector3(-(HookupDistance / 2 + 2 * i * Depth + i * TunnelWidth + (i - 1) * HookupDistance), 0, 0); } OBJ1.transform.parent = OBJ.transform; OBJ2.transform.parent = OBJ.transform; OBJ1.transform.localPosition = new Vector3(0, HP.Size.y, 0); OBJ2.transform.localPosition = new Vector3(0, 0, 0); DestroyImmediate(obj1); DestroyImmediate(obj2); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(OBJ); }
public static void Odd2Even_Connect(HighStoreShelf_Parameter HP, MultiHighBay_Parameter MHP, GameObject OBJ) { //奇数高架库与偶数高架库之间的连接 float TunnelWidth = MHP.TunnelWidth; GameObject obj1 = (GameObject)Resources.Load(Varibles.GlobalVariable.RootName + "/Elevated_Warehouse/Cube2");//加载侧面固定杆 Vector3 size = new Vector3(); size.x = TunnelWidth; size.y = HP.HorizontalStanchionThick; size.z = HP.VerticalStanchionWidth; GameObject obj1_1 = Instantiate(obj1); obj1_1.transform.localScale = size; //GameObject OBJ1 = new GameObject(); for (int i = 0; i <= HP.ColumnsNum; i++) { GameObject clone = Instantiate(obj1_1); clone.transform.parent = OBJ.transform; clone.transform.localPosition = new Vector3(0, -size.y / 2, -size.z / 2 - i * (HP.ColumnWidth + HP.VerticalStanchionWidth)); } //GameObject OBJ2 = new GameObject(); GameObject obj1_2 = Instantiate(obj1); obj1_2.transform.localScale = new Vector3(size.x, size.y, size.z / 2); //obj1_2.transform.parent = OBJ.transform; obj1_2.transform.localPosition = new Vector3(size.x, size.y, size.z / 2); GameObject obj1_3 = Instantiate(obj1); obj1_3.transform.localScale = new Vector3(size.x, size.y, size.z / 2); //obj1_3.transform.parent = OBJ.transform; obj1_3.transform.localPosition = new Vector3(size.x, size.y, size.z / 2); //OBJ1.transform.parent = OBJ.transform; obj1_2.transform.parent = OBJ.transform; obj1_3.transform.parent = OBJ.transform; obj1_2.transform.localPosition = new Vector3(0, -size.y / 2, HP.ColumnWidth + size.z / 4); //OBJ1.transform.localPosition = new Vector3(0, 0, -HP.ColumnWidth); obj1_3.transform.localPosition = new Vector3(0, -size.y / 2, -(HP.ColumnWidth + HP.VerticalStanchionWidth) * (HP.ColumnsNum + 1) - size.z / 4); //OBJ2.transform.parent = OBJ.transform;//重新调整坐标 //OBJ2.transform.localPosition = new Vector3(0, 0, (HP.ColumnWidth * (HP.ColumnsNum + 2)) / 2); DestroyImmediate(obj1_1); }
public static void Create_EndShelf(HighStoreShelf_Parameter HSSP, int i, GameObject EndShelf) { //水平支柱 GameObject obj = (GameObject)Resources.Load(Varibles.GlobalVariable.RootName + "/HighBay/Cube"); //竖直支柱 GameObject obj2 = Instantiate(obj); //竖直支柱 Vector3 obj2_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.FloorsHigh[i], HSSP.VerticalStanchionWidth); obj2.transform.localScale = obj2_size; GameObject obj2_2 = Instantiate(obj2); float temp_value1 = (HSSP.Size.x - HSSP.VerticalStanchionWidth) / 2; //侧面倾斜支柱 float TempValue1 = HSSP.Size.x - HSSP.VerticalStanchionWidth; float TempValue2 = (HSSP.FloorsHigh[i] - HSSP.HorizontalStanchionThick) / 2; float TempValue3 = Mathf.Sqrt(TempValue1 * TempValue1 + TempValue2 * TempValue2);//侧面倾斜支柱的长度 Vector3 SideStanchion_size = new Vector3(HSSP.VerticalStanchionWidth / 2, TempValue3, HSSP.VerticalStanchionWidth / 2); float angle = Mathf.Atan(TempValue1 / TempValue2) * 180 / Mathf.PI; GameObject obj3_1 = Instantiate(obj); obj3_1.transform.localScale = SideStanchion_size; obj3_1.transform.Rotate(0, 0, angle); GameObject obj3_2 = Instantiate(obj); obj3_2.transform.localScale = SideStanchion_size; obj3_2.transform.Rotate(0, 0, -angle); //组合 obj2.transform.parent = EndShelf.transform; obj2_2.transform.parent = EndShelf.transform; obj2.transform.localPosition = new Vector3(temp_value1, HSSP.FloorsHigh[i] / 2 - HSSP.HorizontalStanchionThick, 0); obj2_2.transform.localPosition = new Vector3(-temp_value1, HSSP.FloorsHigh[i] / 2 - HSSP.HorizontalStanchionThick, 0); obj3_1.transform.parent = EndShelf.transform; obj3_2.transform.parent = EndShelf.transform; obj3_1.transform.localPosition = new Vector3(0, (obj2_size.y - HSSP.HorizontalStanchionThick) / 4, 0); obj3_2.transform.localPosition = new Vector3(0, 3 * (obj2_size.y - HSSP.HorizontalStanchionThick) / 4, 0); }
//创建高架库 #region Create_HighBays public static void Create_HighBays(HighStoreShelf_Parameter HP, MultiHighBay_Parameter MHP, GameObject OBJ) { //HP单个高架库设计尺寸参数 //HSP高架库组合设计的参数 //根据单个高架库设计参数生成高架库 GameObject HighBay = new GameObject(); string name = "HighBay"; HighBay.name = name; // Subassembly.Create_HighStoreShelf(HP, HighBay); HighBay.transform.Rotate(0, 180, 0); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(HighBay); //Debug.Log(00); //根据高架库组合设计的参数生成高架库组合 GameObject HighBayGroup = new GameObject(); HighBayGroup.name = "HighBayGroup"; for (int i = 0; i < MHP.Num; i++) { GameObject clone = Instantiate(HighBay); clone.transform.parent = HighBayGroup.transform; clone.name = name + (i + 1).ToString(); float TempValue = -(HP.Size.x / 2 + i * HP.Size.x + ((i + 1) / 2) * MHP.TunnelWidth + (i / 2) * MHP.HookupDistance); clone.transform.localPosition = new Vector3(TempValue, 0, 0); } //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(HighBayGroup); GameObject OBJ1 = new GameObject(); OBJ1.name = "ConnectPart"; ConnectComponent(HP, MHP, OBJ1); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(OBJ1); HighBayGroup.transform.parent = OBJ.transform; HighBayGroup.transform.localPosition = new Vector3(0, 0, 0); OBJ1.transform.parent = OBJ.transform; OBJ1.transform.localPosition = new Vector3(0, 0, 0); DestroyImmediate(HighBay); }
public static void Create_Foot(HighStoreShelf_Parameter HSSP, GameObject Foot) { GameObject obj = (GameObject)Resources.Load(Varibles.GlobalVariable.RootName + "/HighBay/Cube"); GameObject obj1 = Instantiate(obj); Vector3 obj1_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.Height2Ground - HSSP.HorizontalStanchionThick, HSSP.VerticalStanchionWidth); obj1.transform.localScale = obj1_size; GameObject obj2 = Instantiate(obj); Vector3 obj2_size = new Vector3(3 * HSSP.VerticalStanchionWidth, 0.01f, 2 * HSSP.VerticalStanchionWidth); obj2.transform.localScale = obj2_size; GameObject OBJ = new GameObject(); obj1.transform.parent = OBJ.transform; obj2.transform.parent = OBJ.transform; obj1.transform.localPosition = new Vector3(0, obj1_size.y / 2, 0); obj2.transform.localPosition = new Vector3(0, obj2_size.y / 2, 0); GameObject obj3 = Instantiate(obj); obj3.transform.localScale = new Vector3(HSSP.Size.x, HSSP.VerticalStanchionWidth, HSSP.VerticalStanchionWidth); GameObject OBJ2 = Instantiate(OBJ); OBJ.transform.parent = Foot.transform; OBJ2.transform.parent = Foot.transform; obj3.transform.parent = Foot.transform; OBJ.transform.localPosition = new Vector3((HSSP.Size.x - HSSP.VerticalStanchionWidth) / 2, 0, 0); OBJ2.transform.localPosition = new Vector3(-(HSSP.Size.x - HSSP.VerticalStanchionWidth) / 2, 0, 0); obj3.transform.localPosition = new Vector3(0, HSSP.Height2Ground / 2, 0); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(Foot); }
public static void Create_TopShelf(HighStoreShelf_Parameter HSSP, GameObject TopShelf) { GameObject obj = (GameObject)Resources.Load(Varibles.GlobalVariable.RootName + "/HighBay/Cube"); //水平支柱 GameObject obj1 = Instantiate(obj); //水平支柱 Vector3 obj1_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.HorizontalStanchionThick, HSSP.ColumnWidth + 2 * HSSP.VerticalStanchionWidth); obj1.transform.localScale = obj1_size; GameObject obj1_2 = Instantiate(obj1); //水平交叉支柱 float TempValue1 = HSSP.Size.x - HSSP.VerticalStanchionWidth; float TempValue4 = HSSP.ColumnWidth - HSSP.VerticalStanchionWidth; float TempValue5 = Mathf.Sqrt(TempValue1 * TempValue1 + TempValue4 * TempValue4);//水平交叉支柱的长度 float angle1 = Mathf.Atan(TempValue1 / TempValue4) * 180 / Mathf.PI; Vector3 CrossStanchion_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.HorizontalStanchionThick / 2, TempValue5); GameObject obj2_1 = Instantiate(obj); obj2_1.transform.localScale = CrossStanchion_size; obj2_1.transform.Rotate(0, angle1, 0); GameObject obj2_2 = Instantiate(obj); obj2_2.transform.localScale = CrossStanchion_size; obj2_2.transform.Rotate(0, -angle1, 0); //组合 obj1.transform.parent = TopShelf.transform; obj1_2.transform.parent = TopShelf.transform; float temp_value1 = HSSP.Size.x / 2 - HSSP.VerticalStanchionWidth / 2; float temp_value2 = -(HSSP.ColumnWidth + HSSP.VerticalStanchionWidth) / 2; obj1.transform.localPosition = new Vector3(temp_value1, -HSSP.HorizontalStanchionThick / 2, 0); obj1_2.transform.localPosition = new Vector3(-temp_value1, -HSSP.HorizontalStanchionThick / 2, 0); obj2_1.transform.parent = TopShelf.transform; obj2_2.transform.parent = TopShelf.transform; obj2_1.transform.localPosition = new Vector3(0, -obj1_size.y + CrossStanchion_size.y / 2, 0); obj2_2.transform.localPosition = new Vector3(0, -obj1_size.y + CrossStanchion_size.y / 2, 0); }
public static void Create_TopShelf1(HighStoreShelf_Parameter HSSP, GameObject TopShelf) { GameObject obj = (GameObject)Resources.Load(Varibles.GlobalVariable.RootName + "/HighBay/Cube"); //水平支柱 GameObject obj1 = Instantiate(obj); //水平支柱 Vector3 obj1_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.HorizontalStanchionThick, HSSP.ColumnWidth + HSSP.VerticalStanchionWidth / 2); obj1.transform.localScale = obj1_size; GameObject obj1_2 = Instantiate(obj1); //水平交叉支柱 float TempValue1 = HSSP.Size.x - HSSP.VerticalStanchionWidth; float TempValue4 = HSSP.ColumnWidth - HSSP.VerticalStanchionWidth; float TempValue5 = Mathf.Sqrt(TempValue1 * TempValue1 + TempValue4 * TempValue4);//水平交叉支柱的长度 float angle1 = Mathf.Atan(TempValue1 / TempValue4) * 180 / Mathf.PI; Vector3 CrossStanchion_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.HorizontalStanchionThick / 2, TempValue5); GameObject obj2_1 = Instantiate(obj); obj2_1.transform.localScale = CrossStanchion_size; obj2_1.transform.Rotate(0, angle1, 0); GameObject obj2_2 = Instantiate(obj); obj2_2.transform.localScale = CrossStanchion_size; obj2_2.transform.Rotate(0, -angle1, 0); // GameObject obj3 = Instantiate(obj); Vector3 obj3_size = new Vector3(HSSP.Size.x, HSSP.HorizontalStanchionThick, HSSP.VerticalStanchionWidth / 2); obj3.transform.localScale = obj3_size; //倾斜固定 GameObject obj4 = Instantiate(obj); float tempvalue1 = HSSP.FloorsHigh[HSSP.FloorsNum - 1]; float tempvalue2 = HSSP.ColumnWidth; float tempvalue3 = Mathf.Sqrt(tempvalue1 * tempvalue1 + tempvalue2 * tempvalue2); Vector3 obj4_size = new Vector3(HSSP.VerticalStanchionWidth, HSSP.VerticalStanchionWidth, tempvalue3); obj4.transform.localScale = obj4_size; float angle2 = Mathf.Atan(tempvalue1 / tempvalue2) * 180 / Mathf.PI; obj4.transform.Rotate(-angle2, 0, 0); GameObject obj5 = Instantiate(obj4); //组合 obj1.transform.parent = TopShelf.transform; obj1_2.transform.parent = TopShelf.transform; float temp_value1 = HSSP.Size.x / 2 - HSSP.VerticalStanchionWidth / 2; float temp_value2 = -(HSSP.ColumnWidth + HSSP.VerticalStanchionWidth) / 2; obj1.transform.localPosition = new Vector3(temp_value1, -HSSP.HorizontalStanchionThick / 2, obj1_size.z / 2); obj1_2.transform.localPosition = new Vector3(-temp_value1, -HSSP.HorizontalStanchionThick / 2, obj1_size.z / 2); obj2_1.transform.parent = TopShelf.transform; obj2_2.transform.parent = TopShelf.transform; obj2_1.transform.localPosition = new Vector3(0, -obj1_size.y + CrossStanchion_size.y / 2, HSSP.ColumnWidth / 2 + HSSP.VerticalStanchionWidth); obj2_2.transform.localPosition = new Vector3(0, -obj1_size.y + CrossStanchion_size.y / 2, HSSP.ColumnWidth / 2 + HSSP.VerticalStanchionWidth); obj3.transform.parent = TopShelf.transform; obj3.transform.localPosition = new Vector3(0, -obj3_size.y / 2, obj1_size.z - obj3_size.z / 2); obj4.transform.parent = TopShelf.transform; obj5.transform.parent = TopShelf.transform; obj4.transform.localPosition = new Vector3(temp_value1, -tempvalue1 / 2 - obj1_size.y / 2, tempvalue2 / 2); obj5.transform.localPosition = new Vector3(-temp_value1, -tempvalue1 / 2 - obj1_size.y / 2, tempvalue2 / 2); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(TopShelf); }
public static void Create_HighStoreShelf(HighStoreShelf_Parameter HSSP, GameObject HighStoreShelf) { float TempValue1 = HSSP.ColumnWidth + HSSP.VerticalStanchionWidth; float TempValue2 = HSSP.ColumnWidth / 2 + HSSP.VerticalStanchionWidth; float TempValue3 = HSSP.Height2Ground; for (int i = 0; i < HSSP.FloorsNum; i++) { GameObject MainShelf = new GameObject(); MainShelf.name = "MainShelf"; Create_MainShelf(HSSP, i, MainShelf); for (int j = 0; j < HSSP.ColumnsNum; j++) { GameObject clone = Instantiate(MainShelf); clone.name = MainShelf.name + "_" + (i + 1).ToString() + "_" + (j + 1).ToString(); clone.transform.parent = HighStoreShelf.transform; clone.transform.localPosition = new Vector3(0, TempValue3, TempValue2 + j * TempValue1); } GameObject EndShelf = new GameObject(); EndShelf.name = "EndShelf" + (i + 1).ToString(); Create_EndShelf(HSSP, i, EndShelf); //MyClass.Create2(EndShelf); EndShelf.transform.parent = HighStoreShelf.transform; EndShelf.transform.localPosition = new Vector3(0, TempValue3, HSSP.ColumnsNum * TempValue1 + HSSP.VerticalStanchionWidth / 2); TempValue3 = TempValue3 + HSSP.FloorsHigh[i]; DestroyImmediate(MainShelf); } GameObject Foot = new GameObject(); Foot.name = "Foot"; Create_Foot(HSSP, Foot); GameObject TopShelf = new GameObject(); TopShelf.name = "TopShelf"; Create_TopShelf(HSSP, TopShelf); //MyClass.Create2(TopShelf); for (int i = 0; i < HSSP.ColumnsNum; i++) { GameObject clone1 = Instantiate(Foot); clone1.name = Foot.name + (i + 1).ToString(); clone1.transform.parent = HighStoreShelf.transform; clone1.transform.localPosition = new Vector3(0, 0, HSSP.VerticalStanchionWidth / 2 + i * TempValue1); GameObject clone2 = Instantiate(TopShelf); clone2.name = TopShelf.name + (i + 1).ToString(); clone2.transform.parent = HighStoreShelf.transform; clone2.transform.localPosition = new Vector3(0, TempValue3, TempValue2 + i * TempValue1); } Foot.name = Foot.name + (HSSP.ColumnsNum + 1).ToString(); Foot.transform.parent = HighStoreShelf.transform; Foot.transform.localPosition = new Vector3(0, 0, HSSP.ColumnsNum * TempValue1 + HSSP.VerticalStanchionWidth / 2); GameObject TopShelf0 = new GameObject(); TopShelf0.name = TopShelf.name + 0.ToString(); Create_TopShelf1(HSSP, TopShelf0); GameObject TopShelf1 = Instantiate(TopShelf0); TopShelf1.name = TopShelf.name + (HSSP.ColumnsNum + 1).ToString(); TopShelf1.transform.Rotate(0, 180, 0); TopShelf0.transform.parent = HighStoreShelf.transform; TopShelf1.transform.parent = HighStoreShelf.transform; TopShelf0.transform.localPosition = new Vector3(0, TempValue3, HSSP.ColumnsNum * TempValue1 + HSSP.VerticalStanchionWidth); TopShelf1.transform.localPosition = new Vector3(0, TempValue3, 0); DestroyImmediate(TopShelf); }
public static void Create_MainShelf(HighStoreShelf_Parameter HSSP, int i, GameObject MainShelf) { GameObject TopShelf = new GameObject(); Create_TopShelf(HSSP, TopShelf); GameObject EndShelf = new GameObject(); Create_EndShelf(HSSP, i, EndShelf); TopShelf.transform.parent = MainShelf.transform; TopShelf.transform.localPosition = new Vector3(0, 0, 0); EndShelf.transform.parent = MainShelf.transform; EndShelf.transform.localPosition = new Vector3(0, 0, -(HSSP.ColumnWidth + HSSP.VerticalStanchionWidth) / 2); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(MainShelf); }