Exemplo n.º 1
0
    //detects what the player is looking at, and does stuff based on that. Happens once every game update
    void Update()
    {
        ray             = Camera.main.ScreenPointToRay(Input.mousePosition);
        playerText.text = "";
        if (Physics.Raycast(ray, out hit))
        {
            GameObject rayobject = hit.collider.gameObject;
            print(hit.collider.name);
            if (rayobject.CompareTag(INTERACTABLE_TAG))
            {
                switch (rayobject.name)
                {
                // removed first few cases for size issues...
                case "FrontDoor":
                {
                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        DoorRotate rotator = (DoorRotate)rayobject.GetComponent <DoorRotate>();
                        if (rotator == null)
                        {
                            rotator             = (DoorRotate)rayobject.AddComponent <DoorRotate>();
                            rotator.finalDegree = 90;
                        }

                        else
                        {
                            rotator.ChangeDirection();
                        }
                    }
                    break;
                }
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    //print("e");
                }
            }
        }
    }
Exemplo n.º 2
0
    //detects what the player is looking at, and does stuff based on that. Happens once every game update
    void Update()
    {
        ray             = Camera.main.ScreenPointToRay(Input.mousePosition);
        playerText.text = "";
        if (Physics.Raycast(ray, out hit))
        {
            GameObject rayobject = hit.collider.gameObject;
            print(hit.collider.name);
            if (rayobject.CompareTag(INTERACTABLE_TAG))
            {
                switch (rayobject.name)
                {
                case "test1":
                {
                    print("Is Test1");
                    break;
                }

                case "button1":
                {
                    if (Input.GetKey(KeyCode.E))
                    {
                        print("Button 1");
                        SetButton(0);
                        DoorRotate rotator = (DoorRotate)lockedDoor1.AddComponent <DoorRotate>();
                        rotator.finalDegree = 90;
                        playerText.text     = "What was that noise?";
                    }

                    break;
                }

                case "button2":
                {
                    print("Button 2");
                    if (Input.GetKey(KeyCode.E))
                    {
                        SetButton(1);
                        if (buttonStatus[1])
                        {
                            playerText.text = "A noise came from upstairs!";
                            if (trickBookShelf != null)
                            {
                                Destroy(trickBookShelf);
                            }
                        }
                    }

                    break;
                }

                case "button3":
                {
                    print("Button 3");
                    SetButton(2);
                    break;
                }

                case "button4":
                {
                    print("Button 4");
                    SetButton(3);
                    break;
                }

                case "button5":
                {
                    print("Button 5");
                    SetButton(4);
                    break;
                }

                case "test2":
                {
                    print("Is Test2");
                    break;
                }

                case "Button1Door":
                {
                    if (Input.GetKey(KeyCode.E))
                    {
                        playerText.text = "I can't open this door like this...";
                    }

                    break;
                }

                case "FrontDoor":
                {
                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        DoorRotate rotator = (DoorRotate)rayobject.GetComponent <DoorRotate>();
                        if (rotator == null)
                        {
                            rotator             = (DoorRotate)rayobject.AddComponent <DoorRotate>();
                            rotator.finalDegree = 90;
                        }

                        else
                        {
                            rotator.ChangeDirection();
                        }
                    }
                    break;
                }
                }
                if (Input.GetKeyDown(KeyCode.E))
                {
                    //print("e");
                }
            }
        }
    }