using UnityEngine.UI; using System.Collections.Generic; using UnityEngine; public class Collision : MonoBehaviour { public static void check(int nO) { bool Reel = true; for (int k = 0; k < _G.GHOSTLIST.Count; k++) { if (_G.GHOSTLIST[k] == _G.OBJs[nO][0]) { Reel = false; } } CameraAround.Show(); GameObject Sel = GameObject.Find(_G.OBJs[nO][0]).gameObject; if (_G.Redflag == true && Reel) { Sel.GetComponent().material = _G.INV; if (checkBool(nO)) { Sel.GetComponent().material = _G.GRT; } if (checkBoolOut(nO)) { Sel.GetComponent().material = _G.GRT; } } else { Sel.GetComponent().material = _G.INV; } } public static bool checkBoolOut(int On) { bool TF = false; if (_G.OBJs[On][2] == "Cabinet" || _G.OBJs[On][2] == "Panel" | _G.OBJs[On][4] == "frid" || _G.OBJs[On][4] == "wine" || _G.OBJs[On][4] == "stov" || _G.OBJs[On][4] == "dish" || _G.OBJs[On][0].Substring(0, 4) == "wadr") { CameraAround.Show(); GameObject O = GameObject.Find(_G.OBJs[On][0]); Vector3 OP = O.transform.position; Vector3 OB = O.GetComponent().bounds.size; if (OP.x + (OB.x - 0.6f) / 2 > _G.WIDE / 2 || OP.x - (OB.x - 0.6f) / 2 < -_G.WIDE / 2) { TF = true; } if (OP.z + (OB.z - 0.6f) / 2 > _G.DEPTH / 2 || OP.z - (OB.z - 0.6f) / 2 < -_G.DEPTH / 2) { TF = true; } } return TF; } public static void checkALL() { List OBJS = DOLIST.OBJLIST(); foreach (GameObject O in OBJS) { //print(O.name); O.GetComponent().material = _G.INV; Collision.check(Get.GetObjectIndex(O.name)); } DOIT.AllSelOff(); } public static bool checkBool(int On) { GameObject RR = Get.o1("RR"); for (int i = 0; i < RR.transform.childCount; i++) { RR.transform.GetChild(i).SetParent(SceneModeManager.Scene); } bool TF = false; Transform Sel = SceneModeManager.GetObjectInScene(_G.OBJs[On][0]); int nOS = Get.GetObjectIndex(Sel.name); float Ry = DOIT.ConvertStringToNumber(_G.OBJs[nOS][19]); List OBJS = DOLIST.OBJLIST(); for (int k = 0; k < _G.GHOSTLIST.Count; k++) { if (_G.GHOSTLIST[k] == _G.OBJs[On][0]) { Get.o1(_G.OBJs[On][0]).GetComponent().material = _G.GBT; } } foreach (GameObject O in OBJS) { string OKsel = ""; string OKObj = ""; string sels = Sel.name[..4]; string Os = O.name[..4]; if (sels == "cabi" || sels == "stov" || sels == "frid" || sels == "hood" || sels == "wine" || sels == "dish" || sels == "bloc" || sels == "oven" || sels == "pane") { OKsel = "OK"; } if (Os == "cabi" || Os == "stov" || Os == "frid" || Os == "hood" || Os == "wine" || Os == "dish" || Os == "bloc" || Os == "oven" || Os == "pane") { OKObj = "OK"; } int nO = Get.GetObjectIndex(O.name); if (Os == "stov" && _G.OBJs[nO][1][..4] != "BUIL") { OKObj = "OK"; } for (int k = 0; k < _G.GHOSTLIST.Count; k++) { if (_G.GHOSTLIST[k] == Sel.name || _G.GHOSTLIST[k] == O.name) { OKsel = ""; OKObj = ""; } } if (O.name != Sel.name && OKsel == "OK" && OKObj == "OK") { Sel.transform.SetParent(RR.transform); O.transform.SetParent(RR.transform); RR.transform.localRotation = Quaternion.Euler(0, Ry, 0); Vector3 Ov = O.transform.lossyScale; Vector3 Sv = Sel.transform.lossyScale; Vector3 PO = O.transform.position; Vector3 PS = Sel.transform.position; float dx = Mathf.Abs(PO.x - PS.x); float dy = Mathf.Abs(PO.y - PS.y); float dz = Mathf.Abs(PO.z - PS.z); float wx = Ov.x / 2 + Sv.x / 2; float wy = Ov.y / 2 + Sv.y / 2; float wz = Ov.z / 2 + Sv.z / 2; if (dx < wx - 0.75f && dy < wy - 1.0f && dz < wz - 0.75f) TF = true; RR.transform.localRotation = Quaternion.Euler(0, 0, 0); Sel.transform.SetParent(SceneModeManager.Scene); O.transform.SetParent(SceneModeManager.Scene); } } return TF; } }