Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit = player.getRaycastHit();    // 플레이어 객체에서 RaycastHit 정보를 받아온다.

        if (hit.transform != null)                  // 레이가 무언가와 충돌했다면.
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GameManager.gm.panelOpen == false)
                {
                    if (hit.transform.name == "Safe")
                    {
                        if (SafeCamera == false)
                        {
                            safe.convex = false;
                            GameObject.Find("MainCamera").GetComponent <Camera>().fieldOfView = 7;
                            GameObject.Find("MainCamera").GetComponent <Camera>().transform.LookAt(posit);
                            SafeCamera = true;
                            mouse.ChangeMouseLock(false);
                            player.ChangeMoveRotaState(false);
                        }
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (GameManager.gm.panelOpen == false)
            {
                if (SafeCamera == true)
                {
                    if (unlock)
                    {
                        safe.convex = false;
                    }
                    else
                    {
                        safe.convex = true;
                    }
                    GameObject.Find("MainCamera").GetComponent <Camera>().fieldOfView = 60;
                    SafeCamera = false;
                    mouse.ChangeMouseLock(true);
                    player.ChangeMoveRotaState(true);
                }
            }
        }

        if (doorani.GetCurrentAnimatorStateInfo(0).IsName("OpenDoor"))
        {
            if (dooranicheck == true)
            {
                unlock      = true;
                safe.convex = false;
                mouse.ChangeMouseLock(true);
                dooranicheck = false;
                player.ChangeMoveRotaState(true);
            }
        }
    }
Beispiel #2
0
    void Update()
    {
        Ani();

        // 도끼를 든 상태로 -> 문을 클릭했을 때 -> 4초가 지난다면 도끼-문과 관련된 모든 것들을 삭제
        if (time >= 4)
        {
            Destroy(arms2);
            Destroy(AxeAni);
            Destroy(jaildoor);

            if (sound == false)
            {
                SoundManager.instance.Broken_Door();
                GameObject.Find("_Environments").GetComponent <BackSound>().back.enabled = true;
                GameObject.Find("Player").GetComponent <FirstPersonCamera>().In          = false;
                sound = true;
            }

            AxeCheck = false;

            // 도끼로 문을 부순 후 대사가 나온다.
            if (storycheck == true)
            {
                GameObject.Find("Ch1_Story").GetComponent <Ch1_Script>().Ch1Script.SetActive(true);
                storycheck = false;
            }
            player2.ChangeMoveRotaState(true);
            Destroy(this, 2f);
        }
    }
Beispiel #3
0
 private void NuclearFire()
 {
     scripts.SetScript(3);
     player.ChangeMoveRotaState(false);
     director.Play(nuclear);
     director.SetGenericBinding(nuclear.GetOutputTrack(0), Camera.main.gameObject);
     Invoke("gameover", 2.5f);
 }
Beispiel #4
0
    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;
            }
        }
    }
Beispiel #5
0
    private void Update()
    {
        // 클리어 조건을 충족 후 타임라인이 실행되는 동안.
        if (timelinePlaying)
        {
            timer += Time.deltaTime;

            if (timer > timelineDuration)
            {
                TimelineStopped();
            }

            return;
        }

        if (isGaming == false)  // 상호작용 중이 아닐 때.
        {
            if (player)
            {
                if (player.getRaycastHit().collider != null &&
                    player.getRaycastHit().collider.gameObject == this.gameObject)
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (GameManager.gm.panelOpen == false)
                        {
                            Transform tmp = this.cam.transform;
                            originPos = tmp.localPosition;
                            originRot = tmp.localRotation;

                            player.ChangeMoveRotaState(false);
                            tmp.position = setPos.position;
                            tmp.rotation = setPos.rotation;
                            GameManager.gm.GetComponent <MouseLock>().ChangeMouseLock(false);

                            tag = "Untagged";
                            GetComponent <Collider>().enabled = false;
                            rigid.angularDrag = 0.1f;
                            isGaming          = true;
                        }
                    }
                }
            }
        }
        else    // isGaming == true. 상호작용 중일 때.
        {
            if (isClear)
            {
                rigid.angularDrag = 1f;
                Destroy(GetComponent <Collider>());
                Destroy(GetComponent <QuickOutline>());
                GameManager.gm.GetComponent <MouseLock>().ChangeMouseLock(true);
                isGaming = false;

                scripts.SetScript(0);
                timer           = 0f;
                timelinePlaying = true;
                zoomIn.Play();

                Handle.enabled = false;
                SoundManager.instance.Ch5RockS();

                return;
            }

            if (Input.GetKeyDown(KeyCode.Tab))  // 상호작용 종료 키를 'Tab'으로.
            {
                if (GameManager.gm.panelOpen == false)
                {
                    // 클리어와 상관없이 상호작용 종료 후 세팅.
                    GetComponent <Collider>().enabled = true; // 상호작용 오브젝트의 콜라이더를 다시 활성화.
                    tag               = "Handle";             // 태그 설정.
                    isGaming          = false;
                    rigid.angularDrag = 1f;                   // 회전이 빨리 멈추도록 상호작용 오브젝트의 회전 저항값을 크게 준다.

                    // 플레이어의 위치 원복 및 이동 가능.
                    Transform tmp = cam.transform;
                    tmp.localPosition = originPos;
                    tmp.localRotation = originRot;
                    GameManager.gm.GetComponent <MouseLock>().ChangeMouseLock(true);
                    player.ChangeMoveRotaState(true);

                    Handle.enabled = false;

                    return;
                }
            }

            if (!isClear)
            {
                if (GameManager.gm.panelOpen == false)
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        timer = 0f;

                        // 마우스의 버튼을 누른 순간의 위치 정보를 저장.
                        beforePoint = Input.mousePosition;
                    }
                    else if (Input.GetMouseButton(0))
                    {
                        // beforePoint에 이전 프레임의 마우스 위치 정보가 입력되지 않았을 때.
                        if (beforePoint == Vector2.zero)
                        {
                            beforePoint = Input.mousePosition;
                            return;
                        }

                        timer += Time.deltaTime;

                        float value = 0f;
                        if (timer > 0.2f)
                        {
                            Handle.enabled = true;

                            // 상호작용 오브젝트의 회전 속도값이 클리어 조건값보다 커졌을 때.
                            if (rigid.angularVelocity.magnitude > clearedVelocity)
                            {
                                isClear = true;
                                return;
                            }

                            Vector2 nowPoint = Input.mousePosition;
                            nowPoint    = (nowPoint - midPoint).normalized;           // 중점에서 현재 마우스 위치로 향하는 노멀벡터.
                            beforePoint = (beforePoint - midPoint).normalized;        // 중점에서 이전 마우스 위치로 향하는 노멀벡터.
                            float dot = Vector2.Dot(nowPoint, beforePoint);           // 두 벡터를 내적.
                            dot = dot / (nowPoint.magnitude * beforePoint.magnitude); // 내적 값을 두 벡터의 크기곱으로 나누면 cos값이 나온다.

                            // cos값의 범위는 1 ~ -1. 값의 부호에 따른 value(회전에 가하는 힘)를 계산.
                            if (dot >= 0f)
                            {
                                value = (((dot - 1f) * -1f) * 90f) * (accelerateValue * 0.1f);
                            }
                            else
                            {
                                value = (((dot * -1f) * 90f) + 90f) * (accelerateValue * 0.1f);
                            }

                            if (Vector3.Cross(beforePoint, nowPoint).z > 0f)
                            {
                                value = -value;
                            }

                            beforePoint = Vector2.zero; // 이전 마우스 위치값을 초기화.
                            timer       = 0f;           // 타이머 초기화.
                        }
                        else
                        {
                            return;
                        }

                        // value값이 존재하면 회전력을 가한다.
                        if (value != 0f)
                        {
                            rigid.AddTorque(value, 0f, 0f, ForceMode.Force);
                        }
                    }
                    else if (Input.GetMouseButtonUp(0))
                    {
                        // 버튼을 뗀 순간 위치 정보 초기화.
                        beforePoint = Vector2.zero;
                    }
                }
            } // if(!isClear) END.
        }
    }         // Update() END.
    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