using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System; using System.Reflection.Emit; public class CONTROL : MonoBehaviour { public void DELETE() { Delete(); } public static void Delete() { CommandHandler.Instance?.AddToHistory(new DeleteCommand(GameObject.Find(SceneModeManager.SelectedName))); } public void HIDEOBJECT() { //print("---------Hight reach--------------"); GameObject selectedObject = GameObject.Find("SCENE").transform.Find(SceneModeManager.SelectedName).gameObject; //if (Get.o1("btnHIDE").GetComponent().color == _G.colorButton) if (selectedObject.activeSelf) { CommandHandler.Instance?.AddToHistory(new HideCommand(SceneModeManager.SelectedName, false)); _G.SELECEDLIST = new(); DOIT.AllSelOff(); DOIT.CloseALLPNL(); } else { CommandHandler.Instance?.AddToHistory(new HideCommand(SceneModeManager.SelectedName, true)); } } public void UnHIDEOBJECT() { if (_G.HIDELIST.Count > 0 || _G.SELECEDLIST.Count > 0) { CommandHandler.Instance?.AddToHistory(new HideCommand(_G.HIDELIST, true)); _G.SELECEDLIST.Clear(); HIDE_OBJECT.Category("SELECTEDLIST", ""); DOIT.AllSelOff(); DOIT.CloseALLPNL(); } } public void CENTEROBJ() { /*Vector3 pos = GameObject.Find(SceneModeManager.SelectedName).transform.position; float posx=0; float posz=0; int nO=Get.getint(SceneModeManager.SelectedName); string[] C=_G.OBJs[nO]; if(C[22]!="floor" && C[22]!="ceil"){ int wnum = int.Parse( C[22].Replace("w","") ); float ww=_G. WallsWidth[wnum-1]; float wO=DOIT.ConvertStringToNumber(C[6]); float lpos=(ww-wO)/2; print("lpos===="+lpos); Reposition.centerOnWall(lpos); } else{GameObject.Find(SceneModeManager.SelectedName).transform.position = new Vector3(posx, pos.y, posz);} TopControl.ShowMesure(); DOIT.setPosObj(SceneModeManager.SelectedName); */ ///----------------------------new GameObject objectToMove = GameObject.Find(SceneModeManager.SelectedName); Vector3 pos = objectToMove.transform.position; Quaternion rot = objectToMove.transform.rotation; float posx = 0; float posz = 0; int nO = Get.GetObjectIndex(SceneModeManager.SelectedName); string[] C = _G.OBJs[nO]; if (C[22] != "floor" && C[22] != "ceil") { int wnum = int.Parse(C[22].Replace("w", "")); float ww = _G. WallsWidth[wnum - 1]; float wO = DOIT.ConvertStringToNumber(C[6]); float lpos = (ww - wO) / 2; print("lpos====" + lpos); Reposition.centerOnWall(lpos); } else { string beforeAttachedTo =CommandHandler.Instance.BeforeDataTemp[22]; string afterAttachedTo = C[22]; CommandHandler.Instance.AddToHistory(new MoveCommand(objectToMove, pos, rot, beforeAttachedTo, new Vector3(posx, pos.y, posz), objectToMove.transform.rotation, afterAttachedTo)); } } public void ROTATEOBJ() { //print("----rotate object------"); GameObject obj = GameObject.Find(SceneModeManager.SelectedName); if (obj == null) { Debug.Assert(obj != null, "Object is inactive or missing."); return; } Vector3 beforeRotation = obj.transform.eulerAngles; Vector3 beforePos = obj.transform.position; Vector3 pos = obj.transform.eulerAngles; if (this.name == "btnROTATE_R") { pos.y -= _G.AngleStep; } if (this.name == "btnROTATE_L") { pos.y += _G.AngleStep; } if (pos.y >= 360) pos.y = 0; if (this.name == "btnROTATE_R" || this.name == "btnROTATE_L") { CommandHandler.Instance.AddToHistory(new RotationCommand(obj, beforeRotation, beforePos, pos, obj.transform.position)); } } public void ROTATEOBJZ() { float sens=1; if(name=="btnROTATE_Z-")sens=-1; //print("----rotate object-----ZZZZZ-"); GameObject obj = GameObject.Find(SceneModeManager.SelectedName); if (obj == null) { Debug.Assert(obj != null, "Object is inactive or missing."); return; } Vector3 beforeRotation = obj.transform.eulerAngles; Vector3 beforePos = obj.transform.position; Vector3 pos = obj.transform.eulerAngles; pos.z -= _G.AngleStep*sens; if (pos.z >= 360) pos.z = 0; CommandHandler.Instance.AddToHistory(new RotationCommand(obj, beforeRotation, beforePos, pos, obj.transform.position)); } public void LOCK() { int nO = int.Parse(SceneModeManager.SelectedName.Substring(4, SceneModeManager.SelectedName.Length - 4)); if (_G.OBJs[nO][3] == "UNLOCK") { CommandHandler.Instance?.AddToHistory(new LockCommand(SceneModeManager.SelectedName, true)); } else if (_G.OBJs[nO][3] == "LOCK") { CommandHandler.Instance?.AddToHistory(new LockCommand(SceneModeManager.SelectedName, false)); } else { Debug.LogError("Missing object or unassigned lock state."); } } public void SNAPON() { GameObject.Find("HIDER").transform.Find("CONTROL").gameObject.SetActive(false); _G.NAVIGATE = true; _M.PH(8, 200, "ffffff", 1, 1); SceneModeManager.Instance.SetSceneMode(SceneModes.SnapOn); _G.addOBJ = ""; } public void ALIGN() { GameObject.Find("HIDER").transform.Find("CONTROL").gameObject.SetActive(false); _M.PH(8, 0, "ffffff", 1, 1); SceneModeManager.Instance.SetSceneMode(SceneModes.Align); _G.addOBJ = ""; } public void FLIP() { int nO = Get.GetObjectIndex(SceneModeManager.SelectedName); string[] C = _G.OBJs[nO]; print("C[23]==1=" + C[23]); if (C[23] == "R" ) C[23] = "L"; else C[23] = "R"; if (C[2] == "Cabinet" && C[23] != "F" && C[23] != "FR" && C[23] != "FL") { if (C[26] == "") { C[25] = DC.FLIP(C[25]); //DOIT.REDOCAB(nO); } if (C[26] != "") { string s25 = C[26]; string s26 = C[25]; if (s25.Split('_').Length < 7) s25 = DC.FLIP(s25); if (s26.Split('_').Length < 7) s26 = DC.FLIP(s26); if (C[4] == "B2" || C[4] == "W2") { C[25] = DC.FLIPdoor1(s25); C[26] = DC.FLIPdoor2(s26); } //DOIT.REDOCAB(nO); } if(C[4] =="B9" ){ C[4] = "B10"; C[83] = Swap(C[83],0,3); C[78] = Swap(C[78],0,3); (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="B10"){ C[4] = "B9"; C[83] = Swap(C[83],0,3); C[78] = Swap(C[78],0,3); (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="B4" ){ C[4] = "B5"; C[83] = Swap(C[83],0,3); C[78] = Swap(C[78],0,3); (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="B5"){ C[4] = "B4"; C[83] = Swap(C[83],0,3); C[78] = Swap(C[78],0,3); (C[29] , C[28] )=(C[28] , C[29] ); } if(C[4] =="W9" ){ C[4] = "W10"; C[83] = Swap(C[83],0,3); (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="W10"){ C[4] = "W9"; C[83] = Swap(C[83],0,3); (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="B2" ){ C[4] = "B3"; (C[29] , C[28] )=(C[28] , C[29] ); (C[25] , C[26] )=(C[26] , C[25] ); } else if(C[4] =="B3"){ C[4] = "B2"; (C[29] , C[28] )=(C[28] , C[29] ); (C[25] , C[26] )=(C[26] , C[25] ); } else if(C[4] =="W2" ){ C[4] = "W3"; (C[29] , C[28] )=(C[28] , C[29] ); (C[25] , C[26] )=(C[26] , C[25] ); } else if(C[4] =="W3"){ C[4] = "W2"; (C[29] , C[28] )=(C[28] , C[29] ); (C[25] , C[26] )=(C[26] , C[25] ); } else if(C[4] =="W4" ){ C[4] = "W5"; (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="W5"){ C[4] = "W4"; (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="W6" ){ C[4] = "W7"; (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="W7" ){ C[4] = "W6"; (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="B6" ){ C[4] = "B7"; (C[29] , C[28] )=(C[28] , C[29] ); } else if(C[4] =="B7" ){ C[4] = "B6"; (C[29] , C[28] )=(C[28] , C[29] ); } //Grouping C[89]=C[0]; //_G.nO=nO; DOIT.REDOCAB(nO); } if (C[4] == "frid") { Destroy(GameObject.Find(SceneModeManager.SelectedName)); ConstructFRIDGE.AddFridge(nO); } if (C[2] == "Door") { Destroy(GameObject.Find(SceneModeManager.SelectedName)); ConstructDoor.AddDoor(nO); } if (C[5] == "SLIDER") { Destroy(GameObject.Find(SceneModeManager.SelectedName)); ConstructSlider.AddSlider(nO); } if (C[2] == "Toilet" || C[2] == "Bath" || C[2] == "Shower" || C[2] == "Bloc") { Vector3 Scale = GameObject.Find(SceneModeManager.SelectedName).transform.localScale; Scale.x = Scale.x * -1; GameObject.Find(SceneModeManager.SelectedName).transform.localScale = new Vector3(Scale.x, Scale.y, Scale.z); C[6] = Scale.x.ToString(); } Invoke("refresh", 0.5f); } private string Swap(string Code,int Value1, int Value2) { string[] code=Code.Split("_"); (code[Value1], code[Value2])=(code[Value2], code[Value1]); Code=""; for(int i=0; i