public Runway(isOpen, type, length)
 {
     this.isOpen = isOpen;
     this.type   = type;
     this.length = length;
 }
Example #2
0
    void Update()
    {
        //ray = Camera.main.ScreenPointToRay(ScreenPosition);
        ray = Camera.main.ViewportPointToRay(ViewportPosition);
        //hit.point = new Vector3(0.0f, 0.0f, 0.0f);
        printHeadAngle();
        text.enabled = false;
        aim.enabled  = true;



        //실제 Raycast 계산
        /// 태그가 Untagged가 아닐 때에만 작동

        int layerMask = 1 << 8;

        if (Physics.Raycast(ray, out hit, MAX_RAY_DIS + fDist_Epsilon, ~layerMask) && hit.transform.gameObject.tag != "Untagged")
        {
            print(hit.transform.gameObject.tag); //타겟의 태그가 무엇인지 프린트함(160519)
            text.enabled = true;                 //Action이 가능한 상태라는 메세지 띄어줌
            //Debug.Log(hit.point);
            Debug.DrawLine(ray.origin, hit.point, Color.green);
            if (Input.GetMouseButtonDown(0))
            {
                //Raycast의 hit된 대상을 target으로 지정
                target = GetObject();
                /// 태그가 GrabObject 일 때
                if (target.tag == "GrabObject")
                {
                    if (isGrab == true && hit.transform.parent == this.transform)
                    {
                        hit.transform.SetParent(null);
                    }
                    else
                    {
                        //hit.transform.gameObject.transform.Rotate(0, 10, 0);
                        //hit.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
                        hit.transform.SetParent(this.transform);
                    }
                    isGrab = !isGrab;
                }
                /// 태그가 Door 일 때
                if (target.tag == "Door")
                {
                    Animation dAni = hit.transform.gameObject.GetComponent <Animation>();
                    dAni.Play("opendoor");
                }
                /// 태그가 OutDoor 일 때 (160525)
                if (target.tag == "OutDoor")
                {
                    //비밀번호를 맞추고 돌아오면 문이 열림(160526)
                    if (CNextStage.OnPlay == true)
                    {
                        Animation dAni = hit.transform.gameObject.GetComponent <Animation>();
                        dAni.Play("opendoor");
                    }
                    //아니라면 Password_input Scene호출(160526)
                    else
                    {
                        target.GetComponent <CNextStage>().ask_pass(transform.position);
                    }
                }
                /// 태그가 OpenObjectR 일 때
                if (target.tag == "OpenObjectR")
                {
                    isOpen    tmp        = target.GetComponent <isOpen>();
                    Animation dAni       = hit.transform.gameObject.GetComponent <Animation>();
                    bool      tmp_isOpen = tmp.return_isOpen();
                    bool      tmp_YGTWN  = tmp.YGTWN(Code_Key);
                    if (tmp_YGTWN == false)
                    {
                        if (tmp_isOpen == false)
                        {
                            source.PlayOneShot(OpenDoor);
                            dAni.Play("cabinetOpen01");
                            target.GetComponent <isOpen>().cnt_isOpen();
                        }
                        else
                        {
                            source.PlayOneShot(CloseDoor);
                            dAni.Play("cabinetClose01");
                            target.GetComponent <isOpen>().cnt_isOpen();
                        }
                    }
                    else
                    {
                        source.PlayOneShot(Cant);
                    }
                }
                /// 태그가 OpenObjectL 일 때
                if (target.tag == "OpenObjectL")
                {
                    if (target.transform.FindChild("ShowNum"))
                    {
                        target.GetComponentInChildren <shownum>().SetShowNum(); // 타겟의 shownum 세팅(160602)
                    }
                    isOpen    tmp        = target.GetComponent <isOpen>();
                    Animation dAni       = hit.transform.gameObject.GetComponent <Animation>();
                    bool      tmp_isOpen = tmp.return_isOpen();
                    bool      tmp_YGTWN  = tmp.YGTWN(Code_Key);
                    if (tmp_YGTWN == false)
                    {
                        if (tmp_isOpen == false)
                        {
                            source.PlayOneShot(OpenDoor);
                            dAni.Play("cabinetOpen02");
                            target.GetComponent <isOpen>().cnt_isOpen();
                        }
                        else
                        {
                            source.PlayOneShot(CloseDoor);
                            dAni.Play("cabinetClose02");
                            target.GetComponent <isOpen>().cnt_isOpen();
                        }
                    }
                    else
                    {
                        source.PlayOneShot(Cant);
                    }
                }
                /// 태그가 SlideObject
                if (target.tag == "SlideObject")
                {
                    target.GetComponent <isOpen>().move = true;
                }
                /// 태그가 Keys(160519)
                if (target.tag == "Keys")
                {
                    Code_Key.Add(target.GetComponent <KeySet>().Get_Code_Key());
                    target.gameObject.SetActive(false);
                }
            }
        }
        else
        {
            Debug.DrawLine(ray.origin, ray.GetPoint(MAX_RAY_DIS + fDist_Epsilon), Color.red);
            text.enabled = false;

            //잡고있던 물체를 쳐다보지 않으면 나에게서 놓은것으로 간주함
            if (isGrab == true)
            {
                target.transform.SetParent(null);
                isGrab = !isGrab;
            }
        }
    }