private void Update() { if (!isPicked) { if (Input.GetMouseButtonDown(0)) { if (player.getRaycastHit().collider != null) { if (player.getRaycastHit().transform.CompareTag("Object")) { pickedObject = player.getRaycastHit().collider.gameObject; originPos = pickedObject.transform.position; originRot = pickedObject.transform.rotation; originPapa = pickedObject.transform.parent; pickedObject.transform.parent = player.GetComponentInChildren <Camera>().transform; pickedObject.tag = "Untagged"; pickedObject.transform.localPosition = Vector3.forward * distance; pickedObject.transform.rotation = Quaternion.Euler(0f, 180f, 0f); player.ChangeMoveRotaState(false); isPicked = true; Time.timeScale = 0.0f; } } } } else // isPicked == true. { if (pickedObject) { if (Input.GetMouseButton(1)) { float h = Input.GetAxis("Mouse Y") * sensitivity; float v = Input.GetAxis("Mouse X") * sensitivity; pickedObject.transform.Rotate(h, v, 0f); } else if (Input.GetMouseButtonDown(0)) { pickedObject.transform.position = originPos; pickedObject.transform.rotation = originRot; pickedObject.transform.parent = originPapa; pickedObject.tag = "Object"; player.ChangeMoveRotaState(true); isPicked = false; pickedObject = null; Time.timeScale = 1f; } } else { isPicked = false; } } }
private void OnTriggerStay(Collider other) // cctv Controller 콜라이더 반경 안에 있을 때. { if (!IsGaming) // cctv 컨트롤 중이 아니라면. { if (Input.GetMouseButtonUp(0)) { if (GameManager.gm.panelOpen == false) { if (player.getRaycastHit().collider != null && player.getRaycastHit().collider.gameObject == gameObject) { // cctv 컨트롤을 위한 위치 세팅. IsGaming = true; gameObject.tag = "Untagged"; player.ChangeMoveRotaState(false); player.transform.SetPositionAndRotation(gamePos.position, Quaternion.AngleAxis(90f, Vector3.up)); player.GetComponentInChildren <Camera>().transform.localRotation = gamePos.rotation; if (!IsCleared) // 미니게임을 클리어하지 않았다면. { SoundManager.instance.Mouse_Click(); gameCanvas.gameObject.SetActive(true); GameObject.Find("ScriptsManager").GetComponent <ObjectScripts>().SetScript("오우야. 이런건 내 전문이지."); } } } } } else { if (IsCleared) { if (Input.GetKeyDown(KeyCode.A)) { if (GameManager.gm.panelOpen == false) { SoundManager.instance.KeyBoard_Touch(); cameras[currentIdx].targetTexture = null; // currentRT를 사용하는 기존의 카메라의 targetTexture를 제거. if (cameras[currentIdx].transform.parent.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.parent.gameObject.SetActive(false); } else if (cameras[currentIdx].transform.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.gameObject.SetActive(false); } if (currentIdx == 0) { currentIdx = maxIdx - 1; } else { currentIdx--; } cameras[currentIdx].targetTexture = currentRT; // idx 변경 후의 카메라의 targetTexture에 currentRT를 할당. if (cameras[currentIdx].transform.parent.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.parent.gameObject.SetActive(true); } else if (cameras[currentIdx].transform.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.gameObject.SetActive(true); } } } else if (Input.GetKeyDown(KeyCode.D)) { if (GameManager.gm.panelOpen == false) { SoundManager.instance.KeyBoard_Touch(); cameras[currentIdx].targetTexture = null; // currentRT를 사용하는 기존의 카메라의 targetTexture를 제거. if (cameras[currentIdx].transform.parent.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.parent.gameObject.SetActive(false); } else if (cameras[currentIdx].transform.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.gameObject.SetActive(false); } if (currentIdx == maxIdx - 1) { currentIdx = 0; } else { currentIdx++; } cameras[currentIdx].targetTexture = currentRT; // idx 변경 후의 카메라의 targetTexture에 currentRT를 할당. if (cameras[currentIdx].transform.parent.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.parent.gameObject.SetActive(true); } else if (cameras[currentIdx].transform.parent.name == "Tree_with_CCTV") { cameras[currentIdx].transform.parent.gameObject.SetActive(true); } } } } // if (IsCleared). END if (Input.GetKeyDown(KeyCode.Tab)) { if (GameManager.gm.panelOpen == false) { if (IsCleared) { if (gameCanvas) { SoundManager.instance.KeyBoard_Touch(); Destroy(gameCanvas.gameObject); gameCanvas = null; // 게임이 클리어 되었을 때 창문 및 캐비닛과 상호작용이 가능하게끔 트리거 콜라이더 활성화. if (GameObject.Find("Handle_Window")) { GameObject tmp = GameObject.Find("Handle_Window"); if (tmp.GetComponent <CapsuleCollider>()) { tmp.GetComponent <CapsuleCollider>().enabled = true; } } if (cabinet) { cabinet.tag = "Handle"; if (cabinet.GetComponent <SphereCollider>()) { cabinet.GetComponent <SphereCollider>().enabled = true; } } scripts.SetScript(1); director = GetComponent <PlayableDirector>(); director.played += TimelinePlayed; director.stopped += TimelineStopped; director.Play(); } } else { gameCanvas.GetComponentInChildren <Bullet>().OnClick(); gameCanvas.gameObject.SetActive(false); } IsGaming = false; gameObject.tag = "Handle"; player.ChangeMoveRotaState(true); GameManager.gm.GetComponent <MouseLock>().ChangeMouseLock(true); } } } } // OnTriggerStay. END