예제 #1
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);
 }
예제 #2
0
    private void OnTriggerStay(Collider other)
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (GameManager.gm.panelOpen == false)
            {
                if (other.CompareTag("Player"))
                {
                    if (tag == "Handle")
                    {
                        // 타임라인이 실행중이 아닐 때.
                        if (director.state != PlayState.Playing)
                        {
                            // 플레이어의 이동 및 회전 잠금.
                            FirstPersonCamera.player.ChangeMoveRotaState(false);

                            if (director && In)
                            {
                                director.playableAsset = In;
                                director.SetGenericBinding((director.playableAsset as TimelineAsset).GetOutputTrack(1), GameObject.FindWithTag("Player"));
                                director.played  += In_Played;
                                director.stopped += In_Stopped;
                                director.Play();
                            }
                        }
                    }
                    else if (tag == "Outline" && isOpened == false)
                    {
                        scripts.SetScript(0);
                        FirstPersonCamera.player.ChangeMoveRotaState(false);
                        GetComponent <SphereCollider>().enabled = false;
                        director.stopped += search_Stopped;
                        director.Play();
                    }
                }
            }
        }
    }
예제 #3
0
    private void ComeOut_stopped(PlayableDirector obj)
    {
        if (timeline != null)
        {
            // 보스닥터 타임라인용 스크립트로 설정.
            scripts.SetScript(2);
            scripts = null;

            // 보스닥터 타임라인에 이벤트 추가 및 재생.
            timeline.played  += BossAndDoctor_play;
            timeline.stopped += BossAndDoctor;
            timeline.Play();
        }

        // 디렉터에 추가해줬던 이벤트 제거.
        comeOut.played  -= ComeOut_played;
        comeOut.stopped -= ComeOut_stopped;
        comeOut          = null;
    }
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GameManager.gm.panelOpen == false)
                {
                    if (inven.Circle1 == true)
                    {
                        if (player.getRaycastHit().transform == transform)
                        {
                            GameObject.Find("Electric_House").GetComponent <AudioSource>().enabled   = false;
                            GameObject.Find("_Environments").GetComponent <BackSound>().back.enabled = true;
                            // 타임라인 실행.
                            scripts.SetScript(2);
                            director.GetComponent <PlayableDirector>().Play();

                            StartCoroutine("Timer");

                            // 아웃라인 처리를 위해 태그 변경, 콜라이더 제거 및 스크립트 제거.
                            gameObject.tag = "Untagged";
                            var tmp = GetComponents <BoxCollider>();
                            for (int i = 0; i < tmp.Length; i++)
                            {
                                if (tmp[i].isTrigger)
                                {
                                    Destroy(tmp[i]);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
예제 #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.
예제 #6
0
    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