using System.Collections.Generic; using UnityEngine; public class AddShelf : MonoBehaviour { public static void Set(string[] codeD,GameObject BASE,float D,float W, string texself, Vector3 P5, Vector3 P4, Vector3 P3, Vector3 P2, Vector3 P1, float Os,Vector3 CenterBox){ string[] TB = {"T","C","C","C","C","C"}; int indB=(codeD.Length-2)/4; TB[indB-1]="B"; if (_G.Rdiv1.Count != 0) { //o,12,12,0 AddingOnOpeningCorner(BASE, _G.Rdiv1, D, _G.ROWY1[0]+Os, W, texself, P5, P4, P3, P2, P1,TB[0],CenterBox);//T add bn button if(_G.Rdiv1[0]=="o" || _G.Rdiv1[0]=="w"){ if(TB[1]=="B" )TB[1]="TB";else TB[1]="T"; } } if (_G.Rdiv2.Count != 0) {//o,12,12,0 AddingOnOpeningCorner(BASE, _G.Rdiv2, D, _G.ROWY1[1]+Os, W, texself, P5, P4, P3, P2, P1,TB[1],CenterBox);//T add bn button if(_G.Rdiv2[0]=="o" || _G.Rdiv2[0]=="w"){ if(TB[2]=="B" )TB[2]="TB"; else TB[2]="T"; } } if (_G.Rdiv3.Count != 0) {//o,12,12,0 AddingOnOpeningCorner(BASE, _G.Rdiv3, D, _G.ROWY1[2]+Os, W, texself, P5, P4, P3, P2, P1,TB[2],CenterBox); //T add bn button if(_G.Rdiv3[0]=="o" || _G.Rdiv3[0]=="w"){ if(TB[3]=="B" )TB[3]="TB";else TB[3]="T"; } } } // public static void AddingOnOpening(GameObject BASE, List div, float d, float ROWY,float W, string texb){ // float wo; // float ho; // float xp; // if(div.Count>0 ){ // if(div[0]=="o" || div[0]=="w" || div[0]=="c"){ // wo=DOIT.ConvertStringToNumber(div[1])-0.5f; // ho=DOIT.ConvertStringToNumber(div[2]); // xp=-W/2+wo/2; // float xpr=xp+wo/2; // Add(BASE,"S-11t",wo,0.625f,d,xp,ROWY+ho/2, texb); // Add(BASE,"S-11b",wo,0.625f,d,xp,ROWY-ho/2, texb); // if(div.Count>4){Addtoo(BASE,"S-11r",0.625f,ho,d,xpr,ROWY, texb);} // } // } // if(div.Count>4){ // //print("div[4]===="+div[4]); // if(div[4]=="o"|| div[4]=="w"){ // wo=DOIT.ConvertStringToNumber(div[4+1]); // ho=DOIT.ConvertStringToNumber(div[4+2]); // xp=-W/2+wo/2+DOIT.ConvertStringToNumber(div[1]); // Add(BASE,"S-12t",wo,0.625f,d,xp,ROWY+ho/2, texb); // Add(BASE,"S-12b",wo,0.625f,d,xp,ROWY-ho/2, texb); // float xpr=xp+wo/2; // if(div.Count>8){Addtoo(BASE,"S-12r",0.625f,ho,d,xpr,ROWY, texb);} // float xpl=xp-wo/2; // if(div[0]!="o" && div[0]!="w" ){Addtoo(BASE,"S-12l",0.625f,ho,d,xpl,ROWY, texb);} // } // } // if(div.Count>8){ // if(div[8]=="o"|| div[8]=="w"){ // wo=DOIT.ConvertStringToNumber(div[8+1]); // ho=DOIT.ConvertStringToNumber(div[8+2]); // xp=-W/2+wo/2+DOIT.ConvertStringToNumber(div[1])+DOIT.ConvertStringToNumber(div[8+1]); // float xpr=xp+wo/2; // float xpl=xp-wo/2; // Add(BASE,"S-13t",wo,0.625f,d,xp,ROWY+ho/2, texb); // Add(BASE,"S-13b",wo,0.625f,d,xp,ROWY-ho/2, texb); // //Addtoo(BASE,"S-13r",0.625f,ho,d,xpr,ROWY, texb); // //Addtoo(BASE,"S-13l",0.625f,ho,d,xpl,ROWY, texb); // if(div.Count>12){Add(BASE,"S-13r",0.625f,ho,d,xpr,ROWY, texb);} // if(div[4]!="o" && div[4]!="w" ){Addtoo(BASE,"S-13l",0.625f,ho,d,xpl,ROWY, texb);} // } // } // if(div.Count>12){ // if(div[12]=="o"|| div[12]=="w"){ // wo=DOIT.ConvertStringToNumber(div[12+1]); // ho=DOIT.ConvertStringToNumber(div[12+2]); // xp=-W/2+wo/2+DOIT.ConvertStringToNumber(div[1])+DOIT.ConvertStringToNumber(div[4+1])+DOIT.ConvertStringToNumber(div[8+1]); // float xpl=xp-wo/2; // Add(BASE,"S-14t",wo,0.625f,d,xp,ROWY+ho/2, texb); // Add(BASE,"S-14b",wo,0.625f,d,xp,ROWY-ho/2, texb); // if(div[8]!="o" && div[8]!="w" ){Addtoo(BASE,"S-14l",0.625f,ho,d,xpl,ROWY, texb);} // } // } // } public static void Add(GameObject BASE,string n,float w,float h,float d,float x,float y,string texb){ GameObject Cab=GameObject.Find(BASE.name).gameObject; bool Yok=true; for(int i=0; i< BASE.transform.childCount; i++){ Vector3 op=BASE.transform.GetChild(i).transform.position; string name=BASE.transform.GetChild(i).name; float dy=Mathf.Abs(op.y-y); float dx=Mathf.Abs(op.x-x); if(dy<=0.5f && dx<=0.5f && name.Substring(0,2)=="S-"){Yok=false;} if(dy<=0.5f && name=="UNDER"){Yok=false;} if(dy<=0.5f && name=="TOP"){Yok=false;} if(dy<=0.5f && name.IndexOf("K")!=-1){Yok=false;} } if(Yok==true){ GameObject T1 = CreateBoxPnl.Shelf(n, w-0, h, d, x, y, 0, 0, 0, 0, texb); T1.transform.parent = BASE.transform; T1.name=n; } } // public static void AddOnbay(GameObject BASE,string bay, int qty,string n,float w,float h,float d,float x,float y,string texb,float HBay){ // float top=y+HBay*0.5f; // float hdiv=HBay/(qty+1); // for(int i=1; i> divList = new() { _G.Rdiv1, _G.Rdiv2, _G.Rdiv3, _G.Rdiv4, _G.Rdiv5, _G.Rdiv6 }; for (int i = 0; i < _G.RTOT; i++) { List rDiv = divList[i]; int QtyDiv = rDiv.Count / 4 - 1; float posx = -W * 0.5f; for (int j = 0; j < QtyDiv; j++) { int a = j * 4; posx += DOIT.ConvertStringToNumber(rDiv[a + 1]); if (rDiv[a] == "o" || rDiv[a] == "w" || rDiv[a] == "c") { posy = of + _G.ROWY1[i]; if (Get.Bool(Category, "BASE_WALL_TALL")) { Addtoo(BASE, "Seflf Vertical " + i.ToString() + "_" + j.ToString(), 0.65f, DOIT.ConvertStringToNumber(rDiv[a + 2]), DB - t, posx, posy, texshelf, CenterBox); } if (j != 0 && rDiv[a - 4] != "o") { if (Get.Bool(Category, "BASE_WALL_TALL")) { Addtoo(BASE, "Seflf horizontal " + j.ToString(), 0.65f, DOIT.ConvertStringToNumber(rDiv[a + 2]), DB - t, posx - DOIT.ConvertStringToNumber(rDiv[a + 1]), posy, texshelf, CenterBox); } if (Category == "45_Left") CreateCornre45_Shelf_Left_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); if (Category == "45_Right") CreateCornre45_Shelf_Right_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); if (Category == "90_Left") CreateCornre90_Shelf_Left_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); if (Category == "90_Right") CreateCornre90_Shelf_Right_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); } } } posy = of + _G.ROWY1[i] - _G.ROWH1[i] * 0.5f; if (Get.Bool(Category, "BASE_WALL_TALL")) { Addtoo(BASE, "Seflf" + (i + 1).ToString(), W - t * 2, 0.65f, DB - t, 0, posy, texshelf, CenterBox); } if (Category == "45_Left") CreateCornre45_Shelf_Left_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); if (Category == "45_Right") CreateCornre45_Shelf_Right_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); if (Category == "90_Left") CreateCornre90_Shelf_Left_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); if (Category == "90_Right") CreateCornre90_Shelf_Right_Cabinet(BASE, W, DB, posy, E, F, t, texshelf, CenterBox); } } } public static void Addtoo(GameObject BASE,string n,float w,float h,float d, float x,float y,string texb, Vector3 CenterBox){ GameObject T1 = CreateBoxPnl.Shelf(n, w - 0.5f, h, d, CenterBox.x + x, y, CenterBox.z, 0, 0, 0,texb); T1.transform.parent = BASE.transform; T1.name=n; } public static void Interior(GameObject BASE,string Code,float w, float h, float d, string texb, Vector3 CenterBox){ string[] code=Code.Split(); float PositionY = 0; foreach(string s in code){ if (s=="1"){ Addtoo(BASE,"Shelf"+s, w-1,0.5f,d-1, 0,PositionY,texb,CenterBox); } if (s=="2"){ PositionY = h*0.166f; Addtoo(BASE,"Shelf"+s,w-1,0.5f,d-1,0,PositionY,texb,CenterBox); PositionY = -h*0.166f; Addtoo(BASE,"Shelf"+s,w-1,0.5f,d-1,0,PositionY,texb,CenterBox); } if (s=="3"){ PositionY = h*0.25f; Addtoo(BASE,"Shelf"+s,w-1,0.5f,d-1,0,PositionY,texb,CenterBox); PositionY = 0; Addtoo(BASE,"Shelf"+s,w-1,0.5f,d-1,0,PositionY,texb,CenterBox); PositionY = -h*0.25f; Addtoo(BASE,"Shelf"+s,w-1,0.5f,d-1,0,PositionY,texb,CenterBox); } } } ///Corner-------------------------------------------------------------------------------------------------------------Corner ///Corner-------------------------------------------------------------------------------------------------------------Corner ///Corner-------------------------------------------------------------------------------------------------------------Corner public static void AddingOnOpeningCorner(GameObject BASE, List div, float d, float ROWY,float W, string texb, Vector3 P5, Vector3 P4, Vector3 P3, Vector3 P2, Vector3 P1,string TB,Vector3 CenterBox){ float wo; float ho; float xp; if(div.Count>0 ){ if(div[0]=="o" || div[0]=="w" || div[0]=="c"){ wo=DOIT.ConvertStringToNumber(div[1]); ho=DOIT.ConvertStringToNumber(div[2]); xp=-W/2+wo/2; float xpr=xp+wo/2; if(TB!="T" && TB!="TB" )AddCorner(BASE,"S-11t",wo,0.625f,d,xp,ROWY+ho/2, texb,W, P5, P4, P3, P2, P1,CenterBox); if(TB!="B" && TB!="TB" )AddCorner(BASE,"S-11b",wo,0.625f,d,xp,ROWY-ho/2, texb,W, P5, P4, P3, P2, P1,CenterBox); if(div.Count>4){AddtooCorner(BASE,"S-11r",0.625f,ho,d,xpr,ROWY, texb,W, P5, P4, P3, P2, P1,CenterBox);} } } } public static void AddCorner(GameObject BASE,string n,float w,float h,float d,float x,float y,string texb,float W, Vector3 P5, Vector3 P4, Vector3 P3, Vector3 P2, Vector3 P1,Vector3 CenterBox){ //print("BASE.name=="+BASE.name); //GameObject Cab=GameObject.Find(BASE.name); bool Yok=true; for(int i=0; i< BASE.transform.childCount; i++){ Vector3 op=BASE.transform.GetChild(i).transform.position; string name=BASE.transform.GetChild(i).name; float dy=Mathf.Abs(op.y-y); float dx=Mathf.Abs(op.x-x); if(dy<=0.5f && dx<=0.5f && name.Substring(0,2)=="S-"){Yok=false;} if(dy<=0.5f && name=="UNDER"){Yok=false;} if(dy<=0.5f && name=="TOP"){Yok=false;} if(dy<=0.5f && name.IndexOf("K")!=-1){Yok=false;} } if(Yok==true){ Vector3[] Points=new Vector3[5]{P1, P2, P3, P4, P5}; GameObject T1 = MCXMP.MCXV("Shelf",0.625f, Points, texb,"Untagged"); T1.transform.position = new Vector3(CenterBox.x, y, CenterBox.z); T1.transform.parent = BASE.transform; T1.name=n; } } public static void CreateCornre45_Shelf_Left_Cabinet(GameObject BASE,float w, float d, float h, float E,float F, float t,string ShelfTexture, Vector3 CenterBox){//BASE,W, DB, posy, E,F, t,texshelf ) if(E==0)E=t; if(F==0)F=t; Vector3[] Points=new Vector3[5]{ new(-w*0.5f+ t, 0, -d*0.5f+ t), new(-w*0.5f+ t, 0, d*0.5f- t), new(w*0.5f- t, 0, d*0.5f- t), new(w*0.5f- t, 0, d*0.5f- F), new(-w*0.5f+ E, 0, -d*0.5f+ t) }; GameObject Shelf = MCXMP.MCXV("Shelf",t, Points, ShelfTexture,"Untagged"); Shelf .transform.position = new(CenterBox.x, h, CenterBox.z); Shelf .transform.parent = BASE.transform; } public static void CreateCornre45_Shelf_Right_Cabinet(GameObject BASE, float w, float d, float h, float E,float F, float t,string ShelfTexture,Vector3 CenterBox ){//BASE,W, DB, posy, E,F, t,texshelf ) if(E==0)E=t; if(F==0)F=t; Vector3[] Points=new Vector3[5]{ new(-w *0.5f+t, 0, d *0.5f- E), new(-w *0.5f+t, 0, d *0.5f-t), new(w *0.5f-t, 0, d *0.5f-t), new(w *0.5f-t, 0, -d *0.5f), new(w *0.5f- F, 0, -d *0.5f) }; GameObject Shelf = MCXMP.MCXV("Shelf",t, Points, ShelfTexture,"Untagged"); Shelf .transform.position = new(CenterBox.x, h, CenterBox.z); Shelf .transform.parent = BASE.transform; } public static void CreateCornre90_Shelf_Left_Cabinet(GameObject BASE, float w, float d, float h, float E,float F, float t,string ShelfTexture,Vector3 CenterBox ){//BASE,W, DB, posy, E,F, t,texshelf ) if(E==0)E=t; if(F==0)F=t; Vector3[] Points=new Vector3[6]{ new(-w *0.5f+ t, 0, -d *0.5f+ t), new(-w *0.5f+ t, 0, d *0.5f- t), new(w *0.5f- t, 0, d *0.5f- t), new(w *0.5f- t, 0, d *0.5f- F), new(-w *0.5f+ E, 0, d *0.5f- F), new(-w *0.5f+ E, 0, -d *0.5f+ t) }; GameObject Shelf = MCXMP.MCXV("Shelf",t, Points, ShelfTexture,"Untagged"); Shelf.transform.position = new(CenterBox.x, h, CenterBox.z); Shelf.transform.parent = BASE.transform; } public static void CreateCornre90_Shelf_Right_Cabinet(GameObject BASE, float w, float d, float h, float E,float F, float t,string ShelfTexture,Vector3 CenterBox ){//BASE,W, DB, posy, E,F, t,texshelf ) if(E==0)E=t; if(F==0)F=t; Vector3[] Points=new Vector3[6]{ new(-w *0.5f+ t, 0, d *0.5f- E), new(-w *0.5f+ t, 0, d *0.5f- t), new(w *0.5f- t, 0, d *0.5f- t), new(w *0.5f- t, 0, -d *0.5f+ t), new(w *0.5f- F, 0, -d *0.5f+ t), new(w *0.5f- F, 0, d *0.5f- E) }; GameObject Shelf = MCXMP.MCXV("Shelf",t, Points, ShelfTexture,"Untagged"); Shelf.transform.position = new(CenterBox.x, h, CenterBox.z); Shelf .transform.parent = BASE.transform; } public static void AddtooCorner(GameObject BASE,string n,float w,float h,float d,float x,float y,string texb,float W, Vector3 P5, Vector3 P4, Vector3 P3, Vector3 P2, Vector3 P1,Vector3 CenterBox){ GameObject T1 = CreateBoxPnl.Shelf(n, w-1, h, d, CenterBox.x+x, y, CenterBox.z, 0, 0, 0, texb); T1.transform.parent = BASE.transform; T1.name=n; } }