void OnTriggerEnter(Collider other)
    {
        //Debug.Log(other.name);

        if (other.tag == "Robot")
        {
            if (transform.name == "GlassDoorTrigger")
            {
                Debug.Log("Robot detected at door");
                DoorScript2 ds2 = transform.Find("Glass_Door").GetComponent <DoorScript2>();
                if (ds2.isCLosedOrClosing())
                {
                    ds2.buttonPress();
                }
            }
            else if (transform.name == "DoubleDoor")
            {
                Debug.Log("Robot detected at DoubleDoor");
                DoubleRightDoor drd = transform.Find("DoorRight").GetComponent <DoubleRightDoor>();
                DoubleLeftDoor  dld = transform.Find("DoorLeft").GetComponent <DoubleLeftDoor>();
                if (drd.isCLosedOrClosing())
                {
                    drd.buttonPress();
                    dld.buttonPress();
                }
            }
        }
    }
Example #2
0
    void Update()
    {
        Ray        ray = camera.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, interactDistance))
        {
            //print("I'm looking at " + hit.transform.name);
            if (Input.GetKeyDown("e"))
            {
                //Debug.Log("E pressed");

                switch (hit.transform.tag)
                {
                case "KeyNone":
                {
                    //ds2 = hit.transform.findGetChild(0).GetComponent<DoorScript2>();
                    ds2 = hit.transform.GetComponentInChildren <DoorScript2>();
                    //Debug.Log("Calling buttonPress()");
                    ds2.buttonPress();
                    break;
                }

                case "KeyRed":
                    if (ownsKeyRed)
                    {
                        ds2 = hit.transform.GetComponentInChildren <DoorScript2>();
                        //  ds2 = hit.transform.GetChild(0).GetComponent<DoorScript2>();
                        //Debug.Log("Calling buttonPress()");
                        ds2.buttonPress();
                    }
                    else
                    {
                        //Debug.Log("Player missing red key");
                    }
                    break;

                case "DoubleKeyNone":
                    dld = hit.transform.Find("Smaller_Door").GetComponent <DoubleLeftDoor>();
                    drd = hit.transform.Find("Bigger_Door").GetComponent <DoubleRightDoor>();
                    dld.buttonPress();
                    drd.buttonPress();

                    break;

                default:
                {
                    break;
                }
                }
            }
        }

        /*else
         *  print("I'm looking at nothing!");*/
    }