void OnCollisionEnter(Collision collision) { DraggingObs dr = collision.transform.root.GetComponent <DraggingObs>(); if (dr != null) { if (dr.onMouse) { float d = transform.position.y - collision.transform.position.y; if (dr.transform == collision.transform && d > 0.4f) { transform.parent = dr.transform; } else if (collision.transform.root == dr.transform && d > 0.4f) { transform.parent = collision.transform; } } } if (!contactObjects.Contains(collision.transform)) { contactObjects.Add(collision.transform); } if (Manager.Instance.LockObjects) { if (isMoving && collision.transform.CompareTag("Floor")) { minY = 1; } } numOfObjects++; if (collision.transform.CompareTag("Floor")) { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Staks")) { obj.GetComponent <DraggingObs>().RemoveFromList(transform); } isTouchingFloor = true; for (int i = 0; i < LockedObjects.Count; i++) { LockedObjects[i].GetComponent <DraggingObs>().LockedObjects.Clear(); } } }
private IEnumerator OnUpDelay() { yield return(new WaitForRealSeconds(0.05f)); Manager.Instance.SetKinematic(false); if (Manager.Instance.LockObjects) { pv.RPC("MakeObjectsKinematic", RpcTarget.AllBuffered, false); } isMoving = false; lerpAlha = false; Cursor.lockState = CursorLockMode.None; mouseRotationMode = false; gameObject.transform.parent = null; Cursor.visible = true; if (Manager.Instance.LockObjects) { for (int i = 0; i < LockedObjects.Count; i++) { LockedObjects[i].parent = null; } for (int i = 0; i < LockedObjects.Count; i++) { if (LockedObjects[i].GetComponent <DraggingObs>() != null) { otherObj = LockedObjects[i].GetComponent <DraggingObs>(); for (int j = 0; j < otherObj.LockedObjects.Count; j++) { pv.RPC("RemoveObjetFromList", RpcTarget.AllBuffered, otherObj.LockedObjects[j].GetComponent <PhotonView>().ViewID); } } } } }
private void OnMouseDown() { onMouse = true; Manager.Instance.SetKinematic(true); myCamera = Manager.Instance.MyCamRef; if (PlayerArea != null) { if (PlayerArea == Manager.Instance.MyTransformRef.GetComponent <PlayerController>().GetMyArea()) { canMoveObject = true; } else { canMoveObject = false; } } else { canMoveObject = true; } if (canMoveObject) { base.photonView.RequestOwnership(); for (int i = 0; i < LockedObjects.Count; i++) { LockedObjects[i].GetComponent <PhotonView>().RequestOwnership(); if (LockedObjects[i].GetComponent <DraggingObs>().LockedObjects.Count != 0) { for (int j = 0; j < LockedObjects[i].GetComponent <DraggingObs>().LockedObjects.Count; j++) { LockedObjects[i].GetComponent <DraggingObs>().LockedObjects[j].GetComponent <PhotonView>().RequestOwnership(); } } } isFollowingParnt = true; // gameObject.transform.parent = Manager.Instance.MyTransformRef; if (Manager.Instance.LockObjects) { for (int i = 0; i < LockedObjects.Count; i++) { if (LockedObjects[i].GetComponent <DraggingObs>() != null) { otherObj = LockedObjects[i].GetComponent <DraggingObs>(); for (int j = 0; j < otherObj.LockedObjects.Count; j++) { if (!LockedObjects.Contains(otherObj.LockedObjects[j])) { pv.RPC("AddObjectToList", RpcTarget.AllBuffered, otherObj.LockedObjects[j].GetComponent <PhotonView>().ViewID); } } } } for (int i = 0; i < LockedObjects.Count; i++) { LockedObjects[i].GetComponent <Rigidbody>().isKinematic = true; LockedObjects[i].SetParent(transform); LockedObjects[i].GetComponent <Rigidbody>().velocity = Vector3.zero; } } gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero; lerpAlha = true; Cursor.visible = false; x = transform.eulerAngles.x; y = transform.eulerAngles.y; z = transform.eulerAngles.z; } pv.RPC("MakeObjectKinematic", RpcTarget.AllBuffered); }