using UnityEngine; using System.Globalization; public class DC : MonoBehaviour { public static string Resize(string c25, float W, float H, int nO) { //print("c25======Resize=="+c25);//24_30.25_o_24_30.25_0 //12_30 _p_6_30_1 _p_6_30_1 string[] C = _G.OBJs[nO];//only for less code string[] OC = c25.Split('_');//old code starting string[] NC = OC;//new code = starting float ws = DOIT.ConvertStringToNumber(NC[0]);//wide start float hs = DOIT.ConvertStringToNumber(NC[1]);//height start float he = H;//height end float incH = he - hs;//increase height //total row variable height base on 1.2.V _ 3.F _ 4.V float vht = 0;//height total start from all variable //int indvf = 33;//Number where value is //if (C[26] != "" && c25 == C[26]) indvf = 36;//Number where value is if door 2 //string[] dvf=Get.CabValue(C[1],indvf).Split('_');//door variable or fix from file csv string[] dvf; //print("c25======Resize==vf"+_G.VF); //print("c25======Resize==_G.SC[60]"+_G.SC[60]); if(_G.SC[60] == "Creator" || _G.SC[60] == "RePattern"){dvf=_G.VF.Split('_');} else dvf=UIT.Value(_G.Cab_Labrary_On,C[1],"FV1").Split('_'); _G.SC[60]=""; for (int i = 0; i < dvf.Length; i++) {//Get all variables and caculate if (dvf[i].IndexOf("v") != -1) { int ind = int.Parse((DOIT.ConvertStringToNumber(dvf[i].Split('.')[0]) * 4).ToString()); vht += DOIT.ConvertStringToNumber(NC[ind]); } } float saW = W / ws;//scale wide factor float saH = (incH + vht) / vht;//scale height factor //Set height to code for (int i = 0; i < dvf.Length; i++) { if (dvf[i].IndexOf("v") != -1) { string[] dvfs = dvf[i].Split('.'); for (int k = 0; k < dvfs.Length - 1; k++) { //print("dvfs===="+dvfs[k]); //print("k===="+k); int ind = int.Parse(dvfs[k]); NC[ind * 4] = Addtocode(NC[ind * 4], saH); } } } NC[0] = W.ToString(CultureInfo.InvariantCulture);//set new wide to code NC[1] = H.ToString(CultureInfo.InvariantCulture);//set new height to code for (int i = 3; i < NC.Length; i += 4) { //NC[i]=NV(OC[i],OC[0],W) ;//wide NC[i] = Addtocode(NC[i], saW); } //restring code string NCs = ""; for (int i = 0; i < NC.Length; i++) { if (i != NC.Length - 1) { NCs += NC[i] + "_"; } else NCs += NC[i]; } //print("Code 25 ======="+NCs);//12_30.25_p_12_-Infinity_1 return NCs; } public static string ResizeNew(string c25, float W, float H, string cabmame) { //12_30 _p_6_30_1 _p_6_30_1 //string[] C = _G.OBJs[nO];//only for less code string[] OC = c25.Split('_');//old code starting string[] NC = OC;//new code = starting float ws = DOIT.ConvertStringToNumber(NC[0]);//wide start float hs = DOIT.ConvertStringToNumber(NC[1]);//height start float he = H;//height end float incH = he - hs;//increase height //total row variable height base on 1.2.V _ 3.F _ 4.V float vht = 0;//height total start from all variable //int indvf = 33;//Number where value is //if (Get.CabValue(cabmame, 29) != "" && c25 == Get.CabValue(cabmame, 29)) indvf = 36;//Number where value is if door 2 string[] dvf=UIT.Value(_G.Cab_Labrary_On,cabmame,"FV1").Split('_'); for (int i = 0; i < dvf.Length; i++) {//Get all variables and caculate if (dvf[i].IndexOf("v") != -1) { int ind = int.Parse((DOIT.ConvertStringToNumber(dvf[i].Split('.')[0]) * 4).ToString()); vht += DOIT.ConvertStringToNumber(NC[ind]); } } //vht total row variable height //print("ws===="+ws); //print("W;===="+W); float saW = W / ws;//scale wide factor float saH = (incH + vht) / vht;//scale height factor //Set height to code for (int i = 0; i < dvf.Length; i++) { if (dvf[i].IndexOf("v") != -1) { string[] dvfs = dvf[i].Split('.'); for (int k = 0; k < dvfs.Length - 1; k++) { //print("dvfs===="+dvfs[k]); //print("k===="+k); int ind = int.Parse(dvfs[k]); NC[ind * 4] = Addtocode(NC[ind * 4], saH); } } } NC[0] = W.ToString(CultureInfo.InvariantCulture);//set new wide to code NC[1] = H.ToString(CultureInfo.InvariantCulture);//set new height to code for (int i = 3; i < NC.Length; i += 4) { //NC[i]=NV(OC[i],OC[0],W) ;//wide NC[i] = Addtocode(NC[i], saW); } //restring code string NCs = ""; for (int i = 0; i < NC.Length; i++) { if (i != NC.Length - 1) { NCs += NC[i] + "_"; } else NCs += NC[i]; } //print("Code 25 ======="+NCs);//12_30.25_p_12_-Infinity_1 return NCs; } public static string RedoNew(string c25, float W, float H, string dvfstring) { //12_30 _p_6_30_1 _p_6_30_1 //string[] C = _G.OBJs[nO];//only for less code string[] OC = c25.Split('_');//old code starting string[] NC = OC;//new code = starting float ws = DOIT.ConvertStringToNumber(NC[0]);//wide start float hs = DOIT.ConvertStringToNumber(NC[1]);//height start float he = H;//height end float incH = he - hs;//increase height //total row variable height base on 1.2.V _ 3.F _ 4.V float vht = 0;//height total start from all variable string[] dvf = dvfstring.Split('_');//door variable or fix from file csv for (int i = 0; i < dvf.Length; i++) {//Get all variables and caculate if (dvf[i].IndexOf("v") != -1) { int ind = int.Parse((DOIT.ConvertStringToNumber(dvf[i].Split('.')[0]) * 4).ToString()); vht += DOIT.ConvertStringToNumber(NC[ind]); } } float saW = W / ws;//scale wide factor float saH = (incH + vht) / vht;//scale height factor //Set height to code for (int i = 0; i < dvf.Length; i++) { if (dvf[i].IndexOf("v") != -1) { string[] dvfs = dvf[i].Split('.'); for (int k = 0; k < dvfs.Length - 1; k++) { //print("dvfs===="+dvfs[k]); //print("k===="+k); int ind = int.Parse(dvfs[k]); NC[ind * 4] = Addtocode(NC[ind * 4], saH); } } } NC[0] = W.ToString();//set new wide to code NC[1] = H.ToString(); ;//set new height to code for (int i = 3; i < NC.Length; i += 4) { //NC[i]=NV(OC[i],OC[0],W) ;//wide NC[i] = Addtocode(NC[i], saW); } //restring code string NCs = ""; for (int i = 0; i < NC.Length; i++) { if (i != NC.Length - 1) { NCs += NC[i] + "_"; } else NCs += NC[i]; } //print("Code 25 ======="+NCs);//12_30.25_p_12_-Infinity_1 return NCs; } public static string Addtocode(string cn, float scale) { float v = DOIT.ConvertStringToNumber(cn) * scale; return v.ToString(CultureInfo.InvariantCulture); } //public static string NV(string ws, string oWs, float nW) //{ // float w = DOIT.ConvertStringToNumber(ws); // float oW = DOIT.ConvertStringToNumber(oWs); // float scale = w / oW; // float nw = nW * scale; // return nw.ToString(CultureInfo.InvariantCulture); //} public static string[] DC1(string M, float W, float H, string LR) { string Ws = (W).ToString(CultureInfo.InvariantCulture); string Ws2 = (W / 2).ToString(CultureInfo.InvariantCulture); string Hs = (H).ToString(CultureInfo.InvariantCulture); string Hs2 = (H / 2).ToString(CultureInfo.InvariantCulture); string Hs3 = (H / 3).ToString(CultureInfo.InvariantCulture); string Hs4 = (H / 4).ToString(CultureInfo.InvariantCulture); string Hs5 = (H / 5).ToString(CultureInfo.InvariantCulture); string HsR = (H - _G.smalldrawer).ToString(CultureInfo.InvariantCulture); string HsR2 = ((H - _G.smalldrawer) / 2).ToString(CultureInfo.InvariantCulture); string sdh = _G.smalldrawer.ToString(CultureInfo.InvariantCulture);//small drawer height float CabHeight=DOIT.ConvertStringToNumber( _P.List["BASE_HEIGHT"] ); float dh = CabHeight - _G.caKH - _G.caCH; string bdh = dh.ToString(CultureInfo.InvariantCulture);//base door height string bdh2 = (dh / 2).ToString(CultureInfo.InvariantCulture);//base door height string HsRB = (H - dh).ToString(CultureInfo.InvariantCulture); string HT6 = (H - dh - 15).ToString(CultureInfo.InvariantCulture); string HT9 = (H - dh - 30).ToString(CultureInfo.InvariantCulture); /*string LR3 = "3"; string LR6 = "6"; string LR9 = "9"; string LR7 = "7"; string LRCBL = "3"; string LRCBR = "1"; if (LR == "R") { LR3 = "1"; LR6 = "4"; LR9 = "7"; LR7 = "9"; LRCBL = "0"; LRCBR = "0"; }*/ string[] code = new string[] { "0", "0", "0", "0", "0", "0" }; return code; } public static string[] DC2(string M, float W, float H, string LR) { string Ws = (W).ToString(CultureInfo.InvariantCulture); string Hs = (H).ToString(CultureInfo.InvariantCulture); string LRCBL = "0"; string LRCBR = "0"; string Hs3 = (H / 3).ToString(CultureInfo.InvariantCulture); if (LR == "R") { LRCBL = "1"; LRCBR = "3"; } string[] code = new string[] { "0", "0", "0", "0", "0", "0" }; //Corner base if (M == "BC3") code = new string[] { Ws, Hs, "p", Ws, Hs, LRCBL }; if (M == "BC4") code = new string[] { Ws, Hs, "p", Ws, Hs, LRCBR }; if (M == "BC7") code = new string[] { Ws, Hs, "t", Ws, Hs3, "5", "t", Ws, Hs3, "5", "t", Ws, Hs3, "5", }; if (M == "BC8") code = new string[] { Ws, Hs, "t", Ws, Hs3, "5", "t", Ws, Hs3, "5", "t", Ws, Hs3, "5", }; //Corner wall if (M == "WC3") code = new string[] { Ws, Hs, "p", Ws, Hs, LRCBL }; if (M == "WC4") code = new string[] { Ws, Hs, "p", Ws, Hs, LRCBR }; return code; } public static string FLIP(string Code) { string newcode = ""; string[] cs = Code.Split('_'); for (int i = 5; i < cs.Length; i += 4) { //print("i===="+i); switch (cs[i]) { case "1": cs[i] = "3"; break; case "3": cs[i] = "1"; break; case "4": cs[i] = "6"; break; case "6": cs[i] = "4"; break; case "7": cs[i] = "9"; break; case "9": cs[i] = "7"; break; } } for (int k = 0; k < cs.Length; k++) { if (k != cs.Length - 1) newcode += cs[k] + "_"; else newcode += cs[k]; } return newcode; } public static string FLIPdoor1(string Code) { string newcode = ""; string[] cs = Code.Split('_'); for (int i = 5; i < cs.Length; i += 4) { print("cs.Length==1==" + cs.Length); print("cs[i]==1==" + cs[i]); if (cs[i] == "1" && cs.Length <= 7) { cs[i] = "0"; } } for (int k = 0; k < cs.Length; k++) { if (k != cs.Length - 1) newcode += cs[k] + "_"; else newcode += cs[k]; } return newcode; } public static string FLIPdoor2(string Code) { string newcode = ""; string[] cs = Code.Split('_'); for (int i = 5; i < cs.Length; i += 4) { print("cs.Length===2=" + cs.Length + " _ " + i); if (cs[i] == "3" && cs.Length <= 7) { cs[i] = "0"; } } for (int k = 0; k < cs.Length; k++) { if (k != cs.Length - 1) newcode += cs[k] + "_"; else newcode += cs[k]; } return newcode; } }